Make AttributeSet::getFnAttributes() return an AttributeSet instead of an Attribute.
This is more code to isolate the use of the Attribute class to that of just
holding one attribute instead of a collection of attributes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173094 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h
index 10f30e7..b5d292e 100644
--- a/lib/IR/AttributeImpl.h
+++ b/lib/IR/AttributeImpl.h
@@ -39,6 +39,8 @@
ArrayRef<Constant*> values);
AttributeImpl(LLVMContext &C, StringRef data);
+ LLVMContext &getContext() { return Context; }
+
ArrayRef<Constant*> getValues() const { return Vals; }
bool hasAttribute(Attribute::AttrKind A) const;
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 5de1827..d3f284a 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -530,9 +530,29 @@
}
//===----------------------------------------------------------------------===//
+// AttributeWithIndex Definition
+//===----------------------------------------------------------------------===//
+
+AttributeWithIndex AttributeWithIndex::get(LLVMContext &C, unsigned Idx,
+ AttributeSet AS) {
+ // FIXME: This is temporary, but necessary for the conversion.
+ AttrBuilder B(AS, Idx);
+ return get(Idx, Attribute::get(C, B));
+}
+
+//===----------------------------------------------------------------------===//
// AttributeSetImpl Definition
//===----------------------------------------------------------------------===//
+AttributeSet AttributeSet::getFnAttributes() const {
+ // FIXME: Remove.
+ return AttrList ?
+ AttributeSet::get(AttrList->getContext(),
+ AttributeWithIndex::get(FunctionIndex,
+ getAttributes(FunctionIndex))) :
+ AttributeSet();
+}
+
AttributeSet AttributeSet::get(LLVMContext &C,
ArrayRef<AttributeWithIndex> Attrs) {
// If there are no attributes then return a null AttributesList pointer.