aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorAmaury Sechet <deadalnix@gmail.com>2016-06-15 17:50:39 +0000
committerAmaury Sechet <deadalnix@gmail.com>2016-06-15 17:50:39 +0000
commit6100adfeb541b6bdb27cd0f6f58cbe70c754fc04 (patch)
tree315ea358751051499d3b26c57665ce738cddb42b /llvm/lib/IR/Attributes.cpp
parentcd5fe14d89e895b068eab56c77f5a7de3930e041 (diff)
downloadllvm-6100adfeb541b6bdb27cd0f6f58cbe70c754fc04.zip
llvm-6100adfeb541b6bdb27cd0f6f58cbe70c754fc04.tar.gz
llvm-6100adfeb541b6bdb27cd0f6f58cbe70c754fc04.tar.bz2
Add support for string attributes in the C API.
Summary: As per title. This completes the C API Attribute support. Reviewers: Wallbraker, whitequark, echristo, rafael, jyknight Subscribers: mehdi_amini Differential Revision: http://reviews.llvm.org/D21365 llvm-svn: 272811
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 3675bad..b470fac 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -807,6 +807,14 @@ AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index,
return get(C, Attrs);
}
+AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index,
+ ArrayRef<StringRef> Kinds) {
+ SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
+ for (StringRef K : Kinds)
+ Attrs.push_back(std::make_pair(Index, Attribute::get(C, K)));
+ return get(C, Attrs);
+}
+
AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) {
if (Attrs.empty()) return AttributeSet();
if (Attrs.size() == 1) return Attrs[0];
@@ -935,6 +943,12 @@ AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Index,
return removeAttributes(C, Index, AttributeSet::get(C, Index, Kind));
}
+AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Index,
+ StringRef Kind) const {
+ if (!hasAttribute(Index, Kind)) return *this;
+ return removeAttributes(C, Index, AttributeSet::get(C, Index, Kind));
+}
+
AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Index,
AttributeSet Attrs) const {
if (!pImpl) return AttributeSet();