[PATCH] D144202: [ADT] Alternative way to declare enum type as bitmask
Serge Pavlov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 16 10:03:51 PST 2023
sepavloff created this revision.
sepavloff added reviewers: jlebar, sammccall, labath.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a project: LLVM.
If an enumeration represents 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144202
Files:
llvm/include/llvm/ADT/BitmaskEnum.h
llvm/unittests/ADT/BitmaskEnumTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144202.498060.patch
Type: text/x-patch
Size: 5562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/c675179f/attachment.bin>
More information about the llvm-commits
mailing list