Generate Attr subclasses with TableGen.

Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.

Some other notes about newly-generated attribute classes:

 - The constructor arguments are a SourceLocation and a Context&,
   followed by the attributes arguments in the order that they were
   defined in Attr.td

 - Every argument in Attr.td has an appropriate accessor named getFoo,
   and there are sometimes a few extra ones (such as to get the length
   of a variadic argument).

Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111455 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp
index 96793d5..66d31dd 100644
--- a/lib/Sema/SemaAttr.cpp
+++ b/lib/Sema/SemaAttr.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -120,9 +121,11 @@
   // Otherwise, check to see if we need a max field alignment attribute.
   if (unsigned Alignment = Stack->getAlignment()) {
     if (Alignment == PackStackEntry::kMac68kAlignmentSentinel)
-      RD->addAttr(::new (Context) AlignMac68kAttr());
+      RD->addAttr(::new (Context) AlignMac68kAttr(SourceLocation(), Context));
     else
-      RD->addAttr(::new (Context) MaxFieldAlignmentAttr(Alignment * 8));
+      RD->addAttr(::new (Context) MaxFieldAlignmentAttr(SourceLocation(),
+                                                        Context,
+                                                        Alignment * 8));
   }
 }
 
@@ -285,11 +288,12 @@
       continue;
     }
 
-    VD->addAttr(::new (Context) UnusedAttr());
+    VD->addAttr(::new (Context) UnusedAttr(Tok.getLocation(), Context));
   }
 }
 
-typedef std::vector<VisibilityAttr::VisibilityTypes> VisStack;
+typedef std::vector<std::pair<VisibilityAttr::VisibilityType,
+                              SourceLocation> > VisStack;
 
 void Sema::AddPushedVisibilityAttribute(Decl *D) {
   if (!VisContext)
@@ -299,9 +303,10 @@
     return;
 
   VisStack *Stack = static_cast<VisStack*>(VisContext);
-  VisibilityAttr::VisibilityTypes type = Stack->back();
+  VisibilityAttr::VisibilityType type = Stack->back().first;
+  SourceLocation loc = Stack->back().second;
 
-  D->addAttr(::new (Context) VisibilityAttr(type, true));
+  D->addAttr(::new (Context) VisibilityAttr(loc, Context, type));
 }
 
 /// FreeVisContext - Deallocate and null out VisContext.
@@ -314,33 +319,34 @@
                                  SourceLocation PragmaLoc) {
   if (IsPush) {
     // Compute visibility to use.
-    VisibilityAttr::VisibilityTypes type;
+    VisibilityAttr::VisibilityType type;
     if (VisType->isStr("default"))
-      type = VisibilityAttr::DefaultVisibility;
+      type = VisibilityAttr::Default;
     else if (VisType->isStr("hidden"))
-      type = VisibilityAttr::HiddenVisibility;
+      type = VisibilityAttr::Hidden;
     else if (VisType->isStr("internal"))
-      type = VisibilityAttr::HiddenVisibility; // FIXME
+      type = VisibilityAttr::Hidden; // FIXME
     else if (VisType->isStr("protected"))
-      type = VisibilityAttr::ProtectedVisibility;
+      type = VisibilityAttr::Protected;
     else {
       Diag(PragmaLoc, diag::warn_attribute_unknown_visibility) <<
         VisType->getName();
       return;
     }
-    PushPragmaVisibility(type);
+    PushPragmaVisibility(type, PragmaLoc);
   } else {
     PopPragmaVisibility();
   }
 }
 
-void Sema::PushPragmaVisibility(VisibilityAttr::VisibilityTypes type) {
+void Sema::PushPragmaVisibility(VisibilityAttr::VisibilityType type,
+                                SourceLocation loc) {
   // Put visibility on stack.
   if (!VisContext)
     VisContext = new VisStack;
 
   VisStack *Stack = static_cast<VisStack*>(VisContext);
-  Stack->push_back(type);
+  Stack->push_back(std::make_pair(type, loc));
 }
 
 void Sema::PopPragmaVisibility() {