From b3ce98ac7c650c62a724611e2b7a27213cf1bcdc Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 14 Dec 2018 13:51:20 +0000 Subject: [PATCH] Mark Permissions as a bitmask enum this allows one to use bitwise operators on the variables of this type without complicated casting. The gotcha here is that the combinations of these enums were being used in some constexpr contexts such as case labels (case ePermissionsWritable | ePermissionsExecutable:), which is not possible if the user-defined operator| is not constexpr. So, this commit also marks these operators as constexpr. I am committing this as a small standalone patch so it can be easily reverted if some compiler has an issue with this. llvm-svn: 349149 --- lldb/include/lldb/lldb-enumerations.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 0ed6340..604f83c 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -17,17 +17,17 @@ // you mark Enum with LLDB_MARK_AS_BITMASK_ENUM(Enum), however, you can simply // write Enum a = eFoo | eBar. #define LLDB_MARK_AS_BITMASK_ENUM(Enum) \ - inline Enum operator|(Enum a, Enum b) { \ + constexpr Enum operator|(Enum a, Enum b) { \ return static_cast( \ static_cast::type>(a) | \ static_cast::type>(b)); \ } \ - inline Enum operator&(Enum a, Enum b) { \ + constexpr Enum operator&(Enum a, Enum b) { \ return static_cast( \ static_cast::type>(a) & \ static_cast::type>(b)); \ } \ - inline Enum operator~(Enum a) { \ + constexpr Enum operator~(Enum a) { \ return static_cast( \ ~static_cast::type>(a)); \ } \ @@ -395,6 +395,7 @@ LLDB_MARK_AS_BITMASK_ENUM(SymbolContextItem) FLAGS_ENUM(Permissions){ePermissionsWritable = (1u << 0), ePermissionsReadable = (1u << 1), ePermissionsExecutable = (1u << 2)}; +LLDB_MARK_AS_BITMASK_ENUM(Permissions) enum InputReaderAction { eInputReaderActivate, // reader is newly pushed onto the reader stack -- 2.7.4