Skip to content

Commit

Permalink
[AttrBuilder] Assert correct attribute kind
Browse files Browse the repository at this point in the history
Make sure that addAttribute() is only used with simple enum
attributes. Integer and type attributes need to provide an
additional value/type.
  • Loading branch information
nikic committed Jul 20, 2021
1 parent 2a7711f commit a465f07
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions llvm/include/llvm/IR/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,8 @@ class AttrBuilder {
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;
}
Expand Down

0 comments on commit a465f07

Please sign in to comment.