[llvm] a465f07 - [AttrBuilder] Assert correct attribute kind
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 20 12:16:31 PDT 2021
Author: Nikita Popov
Date: 2021-07-20T21:16:23+02:00
New Revision: a465f07cf99b3cc210f4c2a7691dd5027857f117
URL: https://github.com/llvm/llvm-project/commit/a465f07cf99b3cc210f4c2a7691dd5027857f117
DIFF: https://github.com/llvm/llvm-project/commit/a465f07cf99b3cc210f4c2a7691dd5027857f117.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/IR/Attributes.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 165e50e833eb..6033efd978fb 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -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;
}
More information about the llvm-commits
mailing list