[AttrBuilder] Assert correct attribute kind

Make sure that addAttribute() is only used with simple enum
attributes. Integer and type attributes need to provide an
additional value/type.
This commit is contained in:
Nikita Popov 2021-07-20 20:21:08 +02:00
parent 2a7711f33a
commit a465f07cf9
1 changed files with 2 additions and 3 deletions

View File

@ -846,9 +846,8 @@ public:
AttrBuilder &addAttribute(Attribute::AttrKind Val) {
assert((unsigned)Val < Attribute::EndAttrKinds &&
"Attribute out of range!");
// TODO: This should really assert isEnumAttrKind().
assert(!Attribute::isIntAttrKind(Val) &&
"Adding integer attribute without adding a value!");
assert(Attribute::isEnumAttrKind(Val) &&
"Adding integer/type attribute without an argument!");
Attrs[Val] = true;
return *this;
}