[PATCH] D22279: [ADT] Add FlagsEnum, used to enable bitwise operations on enums without static_cast.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 11:18:07 PDT 2016
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.
Nit picks below, but LGTM. I think we should ship this. We can iterate on it further if folks want in post-commit, this already seems really nice.
================
Comment at: include/llvm/ADT/BitmaskEnum.h:19
@@ +18,3 @@
+
+/// \brief LLVM_MARK_AS_BITMASK_ENUM lets you opt in an individual enum type so
+/// you can perform bitwise operations on it without putting static_cast
----------------
We have auto-brief, so no '\brief' needed.
================
Comment at: include/llvm/ADT/BitmaskEnum.h:40
@@ +39,3 @@
+/// The parameter to LLVM_MARK_AS_BITMASK_ENUM should be the largest individual
+/// value in your enum. All of the enum's values must be non-negative.
+#define LLVM_MARK_AS_BITMASK_ENUM(LargestValue) \
----------------
As mentioned in IRC, maybe put the last sentence in its own paragraph so it stands out a bit more.
================
Comment at: include/llvm/ADT/BitmaskEnum.h:67-75
@@ +66,11 @@
+
+/// Traits class to determine whether an enum has a
+/// LLVM_BITMASK_LARGEST_ENUMERATOR enumerator.
+template <typename E, typename Enable = void>
+struct is_bitmask_enum : std::false_type {};
+
+template <typename E>
+struct is_bitmask_enum<
+ E, typename std::enable_if<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >=
+ 0>::type> : std::true_type {};
+
----------------
Any particular reason to not provide the is_bitmask_enum in the llvm namespace for general use?
http://reviews.llvm.org/D22279
More information about the llvm-commits
mailing list