Add a way to add a kind-value string pair to an attribute.
authorBill Wendling <isanbard@gmail.com>
Thu, 25 Jul 2013 18:34:24 +0000 (18:34 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 25 Jul 2013 18:34:24 +0000 (18:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187138 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Attributes.h
include/llvm/IR/Function.h
lib/IR/Attributes.cpp

index 0bf59cf1f61a3690b1d57b2f4f633056454e07cc..2183758fbcbaca55b8c7b8241b7e93b80b514d25 100644 (file)
@@ -250,6 +250,8 @@ public:
   /// attribute sets are immutable, this returns a new set.
   AttributeSet addAttribute(LLVMContext &C, unsigned Index,
                             StringRef Kind) const;
+  AttributeSet addAttribute(LLVMContext &C, unsigned Index,
+                            StringRef Kind, StringRef Value) const;
 
   /// \brief Add attributes to the attribute set at the given index. Since
   /// attribute sets are immutable, this returns a new set.
index 970e7f8fd1275a03b285ade45f6446fa8cd3d270..0e51c6f7565e915198028464a54db61380051253 100644 (file)
@@ -190,6 +190,11 @@ public:
       AttributeSets.addAttribute(getContext(),
                                  AttributeSet::FunctionIndex, Kind));
   }
+  void addFnAttr(StringRef Kind, StringRef Value) {
+    setAttributes(
+      AttributeSets.addAttribute(getContext(),
+                                 AttributeSet::FunctionIndex, Kind, Value));
+  }
 
   /// @brief Return true if the function has the attribute.
   bool hasFnAttribute(Attribute::AttrKind Kind) const {
index 48743fae692d52122c691a2b7f5ca4e2674e5f77..894ff7dda1fe2c503439956d9f9380f0ae8fba52 100644 (file)
@@ -645,6 +645,13 @@ AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index,
   return addAttributes(C, Index, AttributeSet::get(C, Index, B));
 }
 
+AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index,
+                                        StringRef Kind, StringRef Value) const {
+  llvm::AttrBuilder B;
+  B.addAttribute(Kind, Value);
+  return addAttributes(C, Index, AttributeSet::get(C, Index, B));
+}
+
 AttributeSet AttributeSet::addAttributes(LLVMContext &C, unsigned Index,
                                          AttributeSet Attrs) const {
   if (!pImpl) return Attrs;