1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Add a 'StringRef' version of hasAttribute.

Fix the 'operator==' and 'hasAttributes' queries to take into account
target-dependent attributes.

llvm-svn: 174481
This commit is contained in:
Bill Wendling 2013-02-06 01:33:42 +00:00
parent 555fe288d9
commit f45bd45085
2 changed files with 20 additions and 4 deletions

View File

@ -404,6 +404,10 @@ public:
/// \brief Return true if the builder has the specified attribute. /// \brief Return true if the builder has the specified attribute.
bool contains(Attribute::AttrKind A) const; bool contains(Attribute::AttrKind A) const;
/// \brief Return true if the builder has the specified target-dependent
/// attribute.
bool contains(StringRef A) const;
/// \brief Return true if the builder has IR-level attributes. /// \brief Return true if the builder has IR-level attributes.
bool hasAttributes() const; bool hasAttributes() const;

View File

@ -977,8 +977,12 @@ bool AttrBuilder::contains(Attribute::AttrKind A) const {
return Attrs.count(A); return Attrs.count(A);
} }
bool AttrBuilder::contains(StringRef A) const {
return TargetDepAttrs.find(A) != TargetDepAttrs.end();
}
bool AttrBuilder::hasAttributes() const { bool AttrBuilder::hasAttributes() const {
return !Attrs.empty(); return !Attrs.empty() || !TargetDepAttrs.empty();
} }
bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const { bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const {
@ -1005,9 +1009,17 @@ bool AttrBuilder::hasAlignmentAttr() const {
} }
bool AttrBuilder::operator==(const AttrBuilder &B) { bool AttrBuilder::operator==(const AttrBuilder &B) {
SmallVector<Attribute::AttrKind, 8> This(Attrs.begin(), Attrs.end()); for (DenseSet<Attribute::AttrKind>::iterator I = Attrs.begin(),
SmallVector<Attribute::AttrKind, 8> That(B.Attrs.begin(), B.Attrs.end()); E = Attrs.end(); I != E; ++I)
return This == That; 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) { AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {