Author: labath
Date: Fri Dec 14 05:51:20 2018
New Revision: 349149

URL: http://llvm.org/viewvc/llvm-project?rev=349149&view=rev
Log:
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.

Modified:
    lldb/trunk/include/lldb/lldb-enumerations.h

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=349149&r1=349148&r2=349149&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Dec 14 05:51:20 2018
@@ -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<Enum>(                                                  
\
         static_cast<std::underlying_type<Enum>::type>(a) |                     
\
         static_cast<std::underlying_type<Enum>::type>(b));                     
\
   }                                                                            
\
-  inline Enum operator&(Enum a, Enum b) {                                      
\
+  constexpr Enum operator&(Enum a, Enum b) {                                   
\
     return static_cast<Enum>(                                                  
\
         static_cast<std::underlying_type<Enum>::type>(a) &                     
\
         static_cast<std::underlying_type<Enum>::type>(b));                     
\
   }                                                                            
\
-  inline Enum operator~(Enum a) {                                              
\
+  constexpr Enum operator~(Enum a) {                                           
\
     return static_cast<Enum>(                                                  
\
         ~static_cast<std::underlying_type<Enum>::type>(a));                    
\
   }                                                                            
\
@@ -395,6 +395,7 @@ LLDB_MARK_AS_BITMASK_ENUM(SymbolContextI
 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


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to