diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-02-06 01:33:42 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-02-06 01:33:42 +0000 |
commit | 4b00144e1b85e12af789ebfa57669c7cfaa89a0d (patch) | |
tree | b77d37f3ae955348443d06e461fab4ec94d2acc3 /llvm/lib/IR | |
parent | e261492fd485b51c581673530668b0da4c3f93c1 (diff) | |
download | bcm5719-llvm-4b00144e1b85e12af789ebfa57669c7cfaa89a0d.tar.gz bcm5719-llvm-4b00144e1b85e12af789ebfa57669c7cfaa89a0d.zip |
Add a 'StringRef' version of hasAttribute.
Fix the 'operator==' and 'hasAttributes' queries to take into account
target-dependent attributes.
llvm-svn: 174481
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 67ab4eaa699..99fafae88e8 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -977,8 +977,12 @@ bool AttrBuilder::contains(Attribute::AttrKind A) const { return Attrs.count(A); } +bool AttrBuilder::contains(StringRef A) const { + return TargetDepAttrs.find(A) != TargetDepAttrs.end(); +} + bool AttrBuilder::hasAttributes() const { - return !Attrs.empty(); + return !Attrs.empty() || !TargetDepAttrs.empty(); } bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const { @@ -1005,9 +1009,17 @@ bool AttrBuilder::hasAlignmentAttr() const { } bool AttrBuilder::operator==(const AttrBuilder &B) { - SmallVector<Attribute::AttrKind, 8> This(Attrs.begin(), Attrs.end()); - SmallVector<Attribute::AttrKind, 8> That(B.Attrs.begin(), B.Attrs.end()); - return This == That; + for (DenseSet<Attribute::AttrKind>::iterator I = Attrs.begin(), + E = Attrs.end(); I != E; ++I) + if (!B.Attrs.count(*I)) + return false; + + for (td_const_iterator I = TargetDepAttrs.begin(), + E = TargetDepAttrs.end(); I != E; ++I) + if (B.TargetDepAttrs.find(I->first) == B.TargetDepAttrs.end()) + return false; + + return Alignment == B.Alignment && StackAlignment == B.StackAlignment; } AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) { |