[PATCH] D10872: Add getters to access string attributes of arguments/return values

Artur Pilipenko apilipenko at azulsystems.com
Thu Jul 9 04:02:32 PDT 2015


apilipenko retitled this revision from "Support custom string attributes for function arguments/return values" to "Add getters to access string attributes of arguments/return values".
apilipenko updated the summary for this revision.
apilipenko updated this revision to Diff 29314.
apilipenko added a comment.

Split into two patches. Parser part is moved to http://reviews.llvm.org/D11058.


http://reviews.llvm.org/D10872

Files:
  include/llvm/IR/Argument.h
  include/llvm/IR/Function.h
  lib/IR/Function.cpp

Index: lib/IR/Function.cpp
===================================================================
--- lib/IR/Function.cpp
+++ lib/IR/Function.cpp
@@ -198,6 +198,14 @@
                                                getArgNo() + 1, B));
 }
 
+Attribute Argument::getAttr(StringRef Kind) const {
+  return getParent()->getAttribute(getArgNo()+1, Kind);
+}
+
+bool Argument::hasAttr(StringRef Kind) const {
+  return getParent()->hasAttribute(getArgNo()+1, Kind);
+}
+
 /// removeAttr - Remove attributes from an argument.
 void Argument::removeAttr(AttributeSet AS) {
   assert(AS.getNumSlots() <= 1 &&
Index: include/llvm/IR/Function.h
===================================================================
--- include/llvm/IR/Function.h
+++ include/llvm/IR/Function.h
@@ -274,6 +274,16 @@
     return AttributeSets.getDereferenceableOrNullBytes(i);
   }
   
+  /// \brief Return the attribute object that exists at the given index.
+  Attribute getAttribute(unsigned i, StringRef Kind) const {
+    return AttributeSets.getAttribute(i, Kind);
+  }
+
+  /// \brief Return true if attribute exists at the given index.
+  bool hasAttribute(unsigned i, StringRef Kind) const {
+    return AttributeSets.hasAttribute(i, Kind);
+  }
+
   /// @brief Determine if the function does not access memory.
   bool doesNotAccessMemory() const {
     return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Index: include/llvm/IR/Argument.h
===================================================================
--- include/llvm/IR/Argument.h
+++ include/llvm/IR/Argument.h
@@ -121,6 +121,13 @@
   /// \brief Add a Attribute to an argument.
   void addAttr(AttributeSet AS);
 
+  /// \brief Return the attribute object for the given attribute kind.
+  Attribute getAttr(StringRef Kind) const;
+
+  /// \brief Return true if this argument has the attribute of the
+  /// specified kind.
+  bool hasAttr(StringRef Kind) const;
+
   /// \brief Remove a Attribute from an argument.
   void removeAttr(AttributeSet AS);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10872.29314.patch
Type: text/x-patch
Size: 2000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150709/6a58715e/attachment.bin>


More information about the llvm-commits mailing list