diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-02-02 00:42:06 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-02-02 00:42:06 +0000 |
commit | bdcbccc710a0528b4abce947782fd502bafb848d (patch) | |
tree | d5b4afd39f42249dc0f4bc05a66c52b8501441f2 /lib/IR/Attributes.cpp | |
parent | fb10b256aa018a1ef59a18f7c9634bd72a95e6e3 (diff) |
Use the AttributeSet's iterators.
Use the AttributeSet's iterators in AttrBuilder::hasAttributes() when
determining of the intersection of the AttrBuilder and AttributeSet is non-null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Attributes.cpp')
-rw-r--r-- | lib/IR/Attributes.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index f8ca9f1f04..d585843e90 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -42,9 +42,7 @@ Attribute Attribute::get(LLVMContext &Context, Constant *Kind, Constant *Val) { if (!PA) { // If we didn't find any existing attributes of the same shape then create a // new one and insert it. - PA = (!Val) ? - new AttributeImpl(Context, Kind) : - new AttributeImpl(Context, Kind, Val); + PA = new AttributeImpl(Context, Kind, Val); pImpl->AttrsSet.InsertNode(PA, InsertPoint); } @@ -884,7 +882,27 @@ bool AttrBuilder::hasAttributes() const { } bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const { - return Raw() & A.Raw(Index); + unsigned Idx = ~0U; + for (unsigned I = 0, E = A.getNumSlots(); I != E; ++I) + if (A.getSlotIndex(I) == Index) { + Idx = I; + break; + } + + assert(Idx != ~0U && "Couldn't find the index!"); + + for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx); + I != E; ++I) { + Attribute Attr = *I; + // FIXME: Support StringRefs. + Attribute::AttrKind Kind = Attribute::AttrKind( + cast<ConstantInt>(Attr.getAttributeKind())->getZExtValue()); + + if (Attrs.count(Kind)) + return true; + } + + return false; } bool AttrBuilder::hasAlignmentAttr() const { |