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 | 9ca01da53d72c453754a587539024687f86afdd5 (patch) | |
| tree | f4c9dbe740725c4a6423ea8acda47e407b49041a /llvm | |
| parent | b7d1e1ff57bfebe306bd54368a2b62a9a0e168b3 (diff) | |
| download | bcm5719-llvm-9ca01da53d72c453754a587539024687f86afdd5.tar.gz bcm5719-llvm-9ca01da53d72c453754a587539024687f86afdd5.zip | |
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.
llvm-svn: 174250
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/IR/AttributeImpl.h | 1 | ||||
| -rw-r--r-- | llvm/lib/IR/Attributes.cpp | 26 |
2 files changed, 22 insertions, 5 deletions
diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h index 66001f73a00..bf87562dd64 100644 --- a/llvm/lib/IR/AttributeImpl.h +++ b/llvm/lib/IR/AttributeImpl.h @@ -153,7 +153,6 @@ public: /// \p Slot is an index into the AttrNodes list, not the index of the return / /// parameter/ function which the attributes apply to. AttributeSet getSlotAttributes(unsigned Slot) const { - // FIXME: This needs to use AttrNodes instead. return AttributeSet::get(Context, AttrNodes[Slot]); } diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index f8ca9f1f042..d585843e905 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/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 { |

