Remove the last of uses that use the Attribute object as a collection of attributes.

Collections of attributes are handled via the AttributeSet class now. This
finally frees us up to make significant changes to how attributes are structured.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173228 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index a3abd36..4bd2391 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -541,6 +541,14 @@
 // AttributeSetImpl Definition
 //===----------------------------------------------------------------------===//
 
+AttributeSet AttributeSet::getParamAttributes(unsigned Idx) const {
+  // FIXME: Remove.
+  return AttrList && hasAttributes(Idx) ?
+    AttributeSet::get(AttrList->getContext(),
+                      AttributeWithIndex::get(Idx, getAttributes(Idx))) :
+    AttributeSet();
+}
+
 AttributeSet AttributeSet::getRetAttributes() const {
   // FIXME: Remove.
   return AttrList && hasAttributes(ReturnIndex) ?
@@ -601,6 +609,11 @@
   return get(C, AttributeWithIndex::get(Idx, Attribute::get(C, B)));
 }
 
+AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx,
+                               Attribute::AttrKind Kind) {
+  return get(C, AttributeWithIndex::get(Idx, Attribute::get(C, Kind)));
+}
+
 //===----------------------------------------------------------------------===//
 // AttributeSet Method Implementations
 //===----------------------------------------------------------------------===//
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index 0e42536..1e3258f 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -1467,13 +1467,13 @@
 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
   Argument *A = unwrap<Argument>(Arg);
   AttrBuilder B(PA);
-  A->addAttr(Attribute::get(A->getContext(), B));
+  A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1,  B));
 }
 
 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
   Argument *A = unwrap<Argument>(Arg);
   AttrBuilder B(PA);
-  A->removeAttr(Attribute::get(A->getContext(), B));
+  A->removeAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1,  B));
 }
 
 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
@@ -1484,10 +1484,10 @@
   
 
 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
+  Argument *A = unwrap<Argument>(Arg);
   AttrBuilder B;
   B.addAlignmentAttr(align);
-  unwrap<Argument>(Arg)->addAttr(Attribute::
-                                 get(unwrap<Argument>(Arg)->getContext(), B));
+  A->addAttr(AttributeSet::get(A->getContext(),A->getArgNo() + 1, B));
 }
 
 /*--.. Operations on basic blocks ..........................................--*/
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp
index f2f3ec9..839e496 100644
--- a/lib/IR/Function.cpp
+++ b/lib/IR/Function.cpp
@@ -123,23 +123,16 @@
     hasAttribute(1, Attribute::StructRet);
 }
 
-/// addAttr - Add a Attribute to an argument
-void Argument::addAttr(Attribute attr) {
-  AttrBuilder B(attr);
-  getParent()->addAttributes(getArgNo() + 1,
-                             AttributeSet::get(getParent()->getContext(),
-                                               getArgNo() + 1, B));
+/// addAttr - Add attributes to an argument.
+void Argument::addAttr(AttributeSet AS) {
+  getParent()->addAttributes(getArgNo() + 1, AS);
 }
 
-/// removeAttr - Remove a Attribute from an argument
-void Argument::removeAttr(Attribute attr) {
-  AttrBuilder B(attr);
-  getParent()->removeAttributes(getArgNo() + 1,
-                                AttributeSet::get(getParent()->getContext(),
-                                                  getArgNo() + 1, B));
+/// removeAttr - Remove attributes from an argument.
+void Argument::removeAttr(AttributeSet AS) {
+  getParent()->removeAttributes(getArgNo() + 1, AS);
 }
 
-
 //===----------------------------------------------------------------------===//
 // Helper Methods in Function
 //===----------------------------------------------------------------------===//