aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-01-21 22:44:49 +0000
committerBill Wendling <isanbard@gmail.com>2013-01-21 22:44:49 +0000
commit3fc4b96b503fa202411317684a2ba02e41e43072 (patch)
tree232625bd4381c5b6dd7c7bbec178598e7fd131ac /lib/IR
parentc5f1bc88a2eb7ad9ff924ca90cf88494e5f947b9 (diff)
downloadexternal_llvm-3fc4b96b503fa202411317684a2ba02e41e43072.zip
external_llvm-3fc4b96b503fa202411317684a2ba02e41e43072.tar.gz
external_llvm-3fc4b96b503fa202411317684a2ba02e41e43072.tar.bz2
Have AttributeSet::getRetAttributes() return an AttributeSet instead of Attribute.
This further restricts the use of the Attribute class to the Attribute family of classes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/Attributes.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index d3f284a..5c95d4a 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -544,9 +544,18 @@ AttributeWithIndex AttributeWithIndex::get(LLVMContext &C, unsigned Idx,
// AttributeSetImpl Definition
//===----------------------------------------------------------------------===//
+AttributeSet AttributeSet::getRetAttributes() const {
+ // FIXME: Remove.
+ return AttrList && hasAttributes(ReturnIndex) ?
+ AttributeSet::get(AttrList->getContext(),
+ AttributeWithIndex::get(ReturnIndex,
+ getAttributes(ReturnIndex))) :
+ AttributeSet();
+}
+
AttributeSet AttributeSet::getFnAttributes() const {
// FIXME: Remove.
- return AttrList ?
+ return AttrList && hasAttributes(FunctionIndex) ?
AttributeSet::get(AttrList->getContext(),
AttributeWithIndex::get(FunctionIndex,
getAttributes(FunctionIndex))) :
@@ -588,20 +597,22 @@ AttributeSet AttributeSet::get(LLVMContext &C,
}
AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) {
- SmallVector<AttributeWithIndex, 8> Attrs;
- for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) {
- Attribute::AttrKind Kind = *I;
- Attribute A = Attribute::get(C, Kind);
+ // FIXME: This should be implemented as a loop that creates the
+ // AttributeWithIndexes that then are used to create the AttributeSet.
+ if (!B.hasAttributes())
+ return AttributeSet();
- if (Kind == Attribute::Alignment)
- A.setAlignment(B.getAlignment());
- else if (Kind == Attribute::StackAlignment)
- A.setStackAlignment(B.getStackAlignment());
+ uint64_t Mask = 0;
- Attrs.push_back(AttributeWithIndex::get(Idx, A));
- }
+ for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I)
+ Mask |= AttributeImpl::getAttrMask(*I);
- return get(C, Attrs);
+ Attribute A = Attribute::decodeLLVMAttributesForBitcode(C, Mask);
+ if (B.getAlignment())
+ A.setAlignment(B.getAlignment());
+ if (B.getStackAlignment())
+ A.setStackAlignment(B.getStackAlignment());
+ return get(C, AttributeWithIndex::get(Idx, A));
}
//===----------------------------------------------------------------------===//