[llvm] r267057 - Add utility function to manipulate attributes on CallSite. NFC

Amaury Sechet via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 14:29:10 PDT 2016


Author: deadalnix
Date: Thu Apr 21 16:29:10 2016
New Revision: 267057

URL: http://llvm.org/viewvc/llvm-project?rev=267057&view=rev
Log:
Add utility function to manipulate attributes on CallSite. NFC

Summary: As per title. This will help work on the C API.

Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael

Subscribers: joker.eph, llvm-commits

Differential Revision: http://reviews.llvm.org/D19173

Modified:
    llvm/trunk/include/llvm/IR/CallSite.h
    llvm/trunk/include/llvm/IR/Instructions.h
    llvm/trunk/lib/IR/Instructions.cpp

Modified: llvm/trunk/include/llvm/IR/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/CallSite.h?rev=267057&r1=267056&r2=267057&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/CallSite.h (original)
+++ llvm/trunk/include/llvm/IR/CallSite.h Thu Apr 21 16:29:10 2016
@@ -305,6 +305,22 @@ public:
     CALLSITE_DELEGATE_SETTER(setAttributes(PAL));
   }
 
+  void addAttribute(unsigned i, Attribute::AttrKind attr) {
+    CALLSITE_DELEGATE_SETTER(addAttribute(i, attr));
+  }
+
+  void addAttribute(unsigned i, StringRef Kind, StringRef Value) {
+    CALLSITE_DELEGATE_SETTER(addAttribute(i, Kind, Value));
+  }
+
+  void removeAttribute(unsigned i, Attribute::AttrKind attr) {
+    CALLSITE_DELEGATE_SETTER(removeAttribute(i, attr));
+  }
+
+  void removeAttribute(unsigned i, Attribute attr) {
+    CALLSITE_DELEGATE_SETTER(removeAttribute(i, attr));
+  }
+
   /// \brief Return true if this function has the given attribute.
   bool hasFnAttr(Attribute::AttrKind A) const {
     CALLSITE_DELEGATE_GETTER(hasFnAttr(A));

Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=267057&r1=267056&r2=267057&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Thu Apr 21 16:29:10 2016
@@ -1604,6 +1604,9 @@ public:
   void addAttribute(unsigned i, StringRef Kind, StringRef Value);
 
   /// removeAttribute - removes the attribute from the list of attributes.
+  void removeAttribute(unsigned i, Attribute::AttrKind attr);
+
+  /// removeAttribute - removes the attribute from the list of attributes.
   void removeAttribute(unsigned i, Attribute attr);
 
   /// \brief adds the dereferenceable attribute to the list of attributes.
@@ -3542,6 +3545,9 @@ public:
   void addAttribute(unsigned i, Attribute::AttrKind attr);
 
   /// removeAttribute - removes the attribute from the list of attributes.
+  void removeAttribute(unsigned i, Attribute::AttrKind attr);
+
+  /// removeAttribute - removes the attribute from the list of attributes.
   void removeAttribute(unsigned i, Attribute attr);
 
   /// \brief adds the dereferenceable attribute to the list of attributes.

Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=267057&r1=267056&r2=267057&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Thu Apr 21 16:29:10 2016
@@ -343,6 +343,12 @@ void CallInst::addAttribute(unsigned i,
   setAttributes(PAL);
 }
 
+void CallInst::removeAttribute(unsigned i, Attribute::AttrKind attr) {
+  AttributeSet PAL = getAttributes();
+  PAL = PAL.removeAttribute(getContext(), i, attr);
+  setAttributes(PAL);
+}
+
 void CallInst::removeAttribute(unsigned i, Attribute attr) {
   AttributeSet PAL = getAttributes();
   AttrBuilder B(attr);
@@ -663,6 +669,12 @@ void InvokeInst::addAttribute(unsigned i
   setAttributes(PAL);
 }
 
+void InvokeInst::removeAttribute(unsigned i, Attribute::AttrKind attr) {
+  AttributeSet PAL = getAttributes();
+  PAL = PAL.removeAttribute(getContext(), i, attr);
+  setAttributes(PAL);
+}
+
 void InvokeInst::removeAttribute(unsigned i, Attribute attr) {
   AttributeSet PAL = getAttributes();
   AttrBuilder B(attr);




More information about the llvm-commits mailing list