[AttrBuilder] Assert correct attribute kind
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 20 Jul 2021 18:21:08 +0000 (20:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 20 Jul 2021 19:16:23 +0000 (21:16 +0200)
Make sure that addAttribute() is only used with simple enum
attributes. Integer and type attributes need to provide an
additional value/type.

llvm/include/llvm/IR/Attributes.h

index 165e50e..6033efd 100644 (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;
   }