[llvm] [IR][Attribute] Add support for intersecting AttributeLists; NFC (PR #109719)

Jan Voung via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 09:27:03 PDT 2024


================
@@ -208,8 +212,15 @@ class Attribute {
   /// Return true if the target-dependent attribute is present.
   bool hasAttribute(StringRef Val) const;
 
+  /// Returns true if the attribute's kind can be represented as an enum (Enum,
+  /// Integer, Type, ConstantRange, or ConstantRangeList attribute).
+  bool hasKindAsEnum() const {
+    return isEnumAttribute() || isIntAttribute() || isTypeAttribute() ||
+           isConstantRangeAttribute() || isConstantRangeListAttribute();
+  }
+
   /// Return the attribute's kind as an enum (Attribute::AttrKind). This
-  /// requires the attribute to be an enum, integer, or type attribute.
+  /// requires the attribute be representable as an enum (see: `hasKindAsEnum`).
----------------
jvoung wrote:

nit: the getKindAsEnum() has an assert(isEnumAttribute() || ...) -- can that be assert(hasKindAsEnum()) now?

https://github.com/llvm/llvm-project/pull/109719


More information about the llvm-commits mailing list