@@ -134,25 +134,27 @@ getAllBitsUnsetCase(llvm::ArrayRef<EnumAttrCase> cases) {
134
134
135
135
// Emits the following inline function for bit enums:
136
136
//
137
- // inline <enum-type> operator|(<enum-type> a, <enum-type> b);
138
- // inline <enum-type> operator&(<enum-type> a, <enum-type> b);
139
- // inline <enum-type> bitEnumContains(<enum-type> a, <enum-type> b);
137
+ // inline constexpr <enum-type> operator|(<enum-type> a, <enum-type> b);
138
+ // inline constexpr <enum-type> operator&(<enum-type> a, <enum-type> b);
139
+ // inline constexpr bool bitEnumContains(<enum-type> a, <enum-type> b);
140
140
static void emitOperators (const Record &enumDef, raw_ostream &os) {
141
141
EnumAttr enumAttr (enumDef);
142
142
StringRef enumName = enumAttr.getEnumClassName ();
143
143
std::string underlyingType = std::string (enumAttr.getUnderlyingType ());
144
- os << formatv (" inline {0} operator|({0} lhs, {0} rhs) {{\n " , enumName)
144
+ os << formatv (" inline constexpr {0} operator|({0} lhs, {0} rhs) {{\n " ,
145
+ enumName)
145
146
<< formatv (" return static_cast<{0}>("
146
147
" static_cast<{1}>(lhs) | static_cast<{1}>(rhs));\n " ,
147
148
enumName, underlyingType)
148
149
<< " }\n " ;
149
- os << formatv (" inline {0} operator&({0} lhs, {0} rhs) {{\n " , enumName)
150
+ os << formatv (" inline constexpr {0} operator&({0} lhs, {0} rhs) {{\n " ,
151
+ enumName)
150
152
<< formatv (" return static_cast<{0}>("
151
153
" static_cast<{1}>(lhs) & static_cast<{1}>(rhs));\n " ,
152
154
enumName, underlyingType)
153
155
<< " }\n " ;
154
156
os << formatv (
155
- " inline bool bitEnumContains({0} bits, {0} bit) {{\n "
157
+ " inline constexpr bool bitEnumContains({0} bits, {0} bit) {{\n "
156
158
" return (static_cast<{1}>(bits) & static_cast<{1}>(bit)) != 0;\n " ,
157
159
enumName, underlyingType)
158
160
<< " }\n " ;
0 commit comments