diff options
| author | Bill Wendling <isanbard@gmail.com> | 2013-07-25 18:34:24 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2013-07-25 18:34:24 +0000 |
| commit | 9e2ef7780b91d8e01a9ab172f80272fc94f6956b (patch) | |
| tree | 423c9eb78ab648f090a38aca6ae2e5f29fe2ed6e | |
| parent | 4c9d299d80f367a7fa1e97084613565a5956532f (diff) | |
| download | external_llvm-9e2ef7780b91d8e01a9ab172f80272fc94f6956b.zip external_llvm-9e2ef7780b91d8e01a9ab172f80272fc94f6956b.tar.gz external_llvm-9e2ef7780b91d8e01a9ab172f80272fc94f6956b.tar.bz2 | |
Add a way to add a kind-value string pair to an attribute.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187138 91177308-0d34-0410-b5e6-96231b3b80d8
| -rw-r--r-- | include/llvm/IR/Attributes.h | 2 | ||||
| -rw-r--r-- | include/llvm/IR/Function.h | 5 | ||||
| -rw-r--r-- | lib/IR/Attributes.cpp | 7 |
3 files changed, 14 insertions, 0 deletions
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 0bf59cf..2183758 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -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. diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index 970e7f8..0e51c6f 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -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 { diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 48743fa..894ff7d 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -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; |
