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 | c342d9d345acdbd95577c7c6e9ce7d3a1bdb57bf (patch) | |
tree | 97747a4aa454a6b592ccdfc643cacbd648ae2757 /lib/IR | |
parent | 85df6b43403d3ebf5d80023a85699c6fb254941a (diff) | |
download | external_llvm-c342d9d345acdbd95577c7c6e9ce7d3a1bdb57bf.zip external_llvm-c342d9d345acdbd95577c7c6e9ce7d3a1bdb57bf.tar.gz external_llvm-c342d9d345acdbd95577c7c6e9ce7d3a1bdb57bf.tar.bz2 |
Add a 'StringRef' version of hasAttribute.
Fix the 'operator==' and 'hasAttributes' queries to take into account
target-dependent attributes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174481 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/Attributes.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 67ab4ea..99fafae 100644 --- a/lib/IR/Attributes.cpp +++ b/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) { |