aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-12 07:56:49 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-12 07:56:49 +0000
commit74fe825ca597f56985ab4387baca35948647ec4b (patch)
treec1e9d0b6c9a741dfa08d14d4db60f6b13d1186ed
parent4930e7266b7643410cfbbed5ef6e4d3b19178918 (diff)
downloadexternal_llvm-74fe825ca597f56985ab4387baca35948647ec4b.zip
external_llvm-74fe825ca597f56985ab4387baca35948647ec4b.tar.gz
external_llvm-74fe825ca597f56985ab4387baca35948647ec4b.tar.bz2
Support string attributes in the AttrBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174948 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/IR/Attributes.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index d338d65..8249be4 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -938,14 +938,22 @@ AttrBuilder &AttrBuilder::removeAttributes(AttributeSet A, uint64_t Index) {
assert(Idx != ~0U && "Couldn't find index in AttributeSet!");
for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx); I != E; ++I) {
- // FIXME: Support string attributes.
- Attribute::AttrKind Kind = I->getKindAsEnum();
- Attrs.erase(Kind);
+ Attribute Attr = *I;
+ if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
+ Attribute::AttrKind Kind = I->getKindAsEnum();
+ Attrs.erase(Kind);
- if (Kind == Attribute::Alignment)
- Alignment = 0;
- else if (Kind == Attribute::StackAlignment)
- StackAlignment = 0;
+ if (Kind == Attribute::Alignment)
+ Alignment = 0;
+ else if (Kind == Attribute::StackAlignment)
+ StackAlignment = 0;
+ } else {
+ assert(Attr.isStringAttribute() && "Invalid attribute type!");
+ std::map<std::string, std::string>::iterator
+ Iter = TargetDepAttrs.find(Attr.getKindAsString());
+ if (Iter != TargetDepAttrs.end())
+ TargetDepAttrs.erase(Iter);
+ }
}
return *this;
@@ -1021,10 +1029,16 @@ bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const {
assert(Idx != ~0U && "Couldn't find the index!");
for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx);
- I != E; ++I)
- // FIXME: Support string attributes.
- if (Attrs.count(I->getKindAsEnum()))
- return true;
+ I != E; ++I) {
+ Attribute Attr = *I;
+ if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
+ if (Attrs.count(I->getKindAsEnum()))
+ return true;
+ } else {
+ assert(Attr.isStringAttribute() && "Invalid attribute kind!");
+ return TargetDepAttrs.find(Attr.getKindAsString())!=TargetDepAttrs.end();
+ }
+ }
return false;
}