From 3fc4b96b503fa202411317684a2ba02e41e43072 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 21 Jan 2013 22:44:49 +0000 Subject: 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 --- lib/IR/Attributes.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'lib/IR/Attributes.cpp') 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 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)); } //===----------------------------------------------------------------------===// -- cgit v1.1