[ADT] Alternative way to declare enum type as bitmask
If an enumeration represents a set of bit flags, using the macro LLVM_MARK_AS_BITMASK_ENUM can make operations with such enumeration more convenient. It however brings problems if the enumeration is non-scoped. As the macro adds an item LLVM_BITMASK_LARGEST_ENUMERATOR to the enumeration type, only one such type may be declared as bitmask. This problem could be solved by convertion of the enumeration to scoped, but it requires static_casts in new places and the convenience can be eliminated. This change introduces a new macro LLVM_DECLARE_ENUM_AS_BITMASK, which allows non-invasive convertion of an enumeration into bitmask. It provides specialization to trait classes, which previously were built based on presence of LLVM_BITMASK_LARGEST_ENUMERATOR in the enumeration. The macro must be specified in global or llvm namespace because the trait classes are declared in llvm namespace. Differential Revision: https://reviews.llvm.org/D144202
Loading
Please sign in to comment