Add the target-dependent (string) attributes from the AttrBuilder to the AttributeSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174467 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index d61bd09..dc1a657 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -126,8 +126,13 @@
return pImpl ? pImpl->getValueAsString() : StringRef();
}
-bool Attribute::hasAttribute(AttrKind Val) const {
- return (pImpl && pImpl->hasAttribute(Val)) || (!pImpl && Val == None);
+bool Attribute::hasAttribute(AttrKind Kind) const {
+ return (pImpl && pImpl->hasAttribute(Kind)) || (!pImpl && Kind == None);
+}
+
+bool Attribute::hasAttribute(StringRef Kind) const {
+ if (!isStringAttribute()) return false;
+ return pImpl && pImpl->hasAttribute(Kind);
}
/// This returns the alignment field of an attribute as a byte alignment value.
@@ -552,6 +557,7 @@
if (!B.hasAttributes())
return AttributeSet();
+ // Add target-independent attributes.
SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) {
Attribute::AttrKind Kind = *I;
@@ -565,6 +571,11 @@
Attrs.push_back(std::make_pair(Idx, Attribute::get(C, Kind)));
}
+ // Add target-dependent (string) attributes.
+ for (AttrBuilder::td_iterator I = B.td_begin(), E = B.td_end();
+ I != E; ++I)
+ Attrs.push_back(std::make_pair(Idx, Attribute::get(C, I->first,I->second)));
+
return get(C, Attrs);
}