Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74501 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 66b1f17..a919dfa 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -522,7 +522,7 @@
   case Builtin::BIsqrtf:
   case Builtin::BIsqrtl: {
     // Rewrite sqrt to intrinsic if allowed.
-    if (!FD->hasAttr<ConstAttr>(getContext()))
+    if (!FD->hasAttr<ConstAttr>())
       break;
     Value *Arg0 = EmitScalarExpr(E->getArg(0));
     const llvm::Type *ArgType = Arg0->getType();
@@ -534,7 +534,7 @@
   case Builtin::BIpowf:
   case Builtin::BIpowl: {
     // Rewrite sqrt to intrinsic if allowed.
-    if (!FD->hasAttr<ConstAttr>(getContext()))
+    if (!FD->hasAttr<ConstAttr>())
       break;
     Value *Base = EmitScalarExpr(E->getArg(0));
     Value *Exponent = EmitScalarExpr(E->getArg(1));
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 8ff5891..b5195c4 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -377,13 +377,13 @@
 
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
-    if (TargetDecl->hasAttr<NoThrowAttr>(getContext()))
+    if (TargetDecl->hasAttr<NoThrowAttr>())
       FuncAttrs |= llvm::Attribute::NoUnwind;
-    if (TargetDecl->hasAttr<NoReturnAttr>(getContext()))
+    if (TargetDecl->hasAttr<NoReturnAttr>())
       FuncAttrs |= llvm::Attribute::NoReturn;
-    if (TargetDecl->hasAttr<ConstAttr>(getContext()))
+    if (TargetDecl->hasAttr<ConstAttr>())
       FuncAttrs |= llvm::Attribute::ReadNone;
-    else if (TargetDecl->hasAttr<PureAttr>(getContext()))
+    else if (TargetDecl->hasAttr<PureAttr>())
       FuncAttrs |= llvm::Attribute::ReadOnly;
   }
 
@@ -438,7 +438,7 @@
   signed RegParm = 0;
   if (TargetDecl)
     if (const RegparmAttr *RegParmAttr 
-          = TargetDecl->getAttr<RegparmAttr>(getContext()))
+          = TargetDecl->getAttr<RegparmAttr>())
       RegParm = RegParmAttr->getNumParams();
 
   unsigned PointerWidth = getContext().Target.getPointerWidth(0);
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index f97c62f..2ae7e22 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -60,7 +60,7 @@
 /// EmitBlockVarDecl - This method handles emission of any variable declaration
 /// inside a function, including static vars etc.
 void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) {
-  if (D.hasAttr<AsmLabelAttr>(getContext()))
+  if (D.hasAttr<AsmLabelAttr>())
     CGM.ErrorUnsupported(&D, "__asm__");
   
   switch (D.getStorageClass()) {
@@ -171,7 +171,7 @@
   }
 
   // FIXME: Merge attribute handling.
-  if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>(getContext())) {
+  if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) {
     SourceManager &SM = CGM.getContext().getSourceManager();
     llvm::Constant *Ann =
       CGM.EmitAnnotateAttr(GV, AA, 
@@ -179,10 +179,10 @@
     CGM.AddAnnotation(Ann);
   }
 
-  if (const SectionAttr *SA = D.getAttr<SectionAttr>(getContext()))
+  if (const SectionAttr *SA = D.getAttr<SectionAttr>())
     GV->setSection(SA->getName());
   
-  if (D.hasAttr<UsedAttr>(getContext()))
+  if (D.hasAttr<UsedAttr>())
     CGM.AddUsedGlobal(GV);
 
   // We may have to cast the constant because of the initializer
@@ -244,7 +244,7 @@
 /// These turn into simple stack objects, or GlobalValues depending on target.
 void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
   QualType Ty = D.getType();
-  bool isByRef = D.hasAttr<BlocksAttr>(getContext());
+  bool isByRef = D.hasAttr<BlocksAttr>();
   bool needsDispose = false;
   unsigned Align = 0;
 
@@ -414,7 +414,7 @@
   }
 
   // Handle the cleanup attribute
-  if (const CleanupAttr *CA = D.getAttr<CleanupAttr>(getContext())) {
+  if (const CleanupAttr *CA = D.getAttr<CleanupAttr>()) {
     const FunctionDecl *FD = CA->getFunctionDecl();
     
     llvm::Constant* F = CGM.GetAddrOfFunction(GlobalDecl(FD));
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index a211407..0951019 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -670,7 +670,7 @@
         isa<ImplicitParamDecl>(VD))) {
     LValue LV;
     bool NonGCable = VD->hasLocalStorage() && 
-      !VD->hasAttr<BlocksAttr>(getContext());
+      !VD->hasAttr<BlocksAttr>();
     if (VD->hasExternalStorage()) {
       llvm::Value *V = CGM.GetAddrOfGlobalVar(VD);
       if (VD->getType()->isReferenceType())
@@ -686,7 +686,7 @@
       // local static?
       if (!NonGCable)
         attr = getContext().getObjCGCAttrKind(E->getType());
-      if (VD->hasAttr<BlocksAttr>(getContext())) {
+      if (VD->hasAttr<BlocksAttr>()) {
         bool needsCopyDispose = BlockRequiresCopying(VD->getType());
         const llvm::Type *PtrStructTy = V->getType();
         const llvm::Type *Ty = PtrStructTy;
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index e7cf8e6..51f9a76 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -126,7 +126,7 @@
 /// its pointer, name, and types registered in the class struture.  
 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
   // Check if we should generate debug info for this method.
-  if (CGM.getDebugInfo() && !OMD->hasAttr<NodebugAttr>(getContext()))
+  if (CGM.getDebugInfo() && !OMD->hasAttr<NodebugAttr>())
     DebugInfo = CGM.getDebugInfo();
   StartObjCMethod(OMD, OMD->getClassInterface());
   EmitStmt(OMD->getBody(getContext()));
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 865e8c2..b9e8495 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1360,7 +1360,7 @@
 /// class has the __objc_exception__ attribute.
 static bool hasObjCExceptionAttribute(ASTContext &Context, 
                                       const ObjCInterfaceDecl *OID) {
-  if (OID->hasAttr<ObjCExceptionAttr>(Context))
+  if (OID->hasAttr<ObjCExceptionAttr>())
     return true;
   if (const ObjCInterfaceDecl *Super = OID->getSuperClass())
     return hasObjCExceptionAttribute(Context, Super);
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index f10a08f..672f6da 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -199,7 +199,7 @@
 void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
                                    llvm::Function *Fn) {
   // Check if we should generate debug info for this function.
-  if (CGM.getDebugInfo() && !FD->hasAttr<NodebugAttr>(getContext()))
+  if (CGM.getDebugInfo() && !FD->hasAttr<NodebugAttr>())
     DebugInfo = CGM.getDebugInfo();
   
   FunctionArgList Args;
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 7957a9f..efa50ba 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -102,7 +102,7 @@
     if (VD->getStorageClass() == VarDecl::PrivateExtern)
       return LangOptions::Hidden;
 
-  if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>(getContext())) {
+  if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) {
     switch (attr->getVisibility()) {
     default: assert(0 && "Unknown visibility!");
     case VisibilityAttr::DefaultVisibility: 
@@ -306,9 +306,9 @@
 
   if (Linkage == GVA_Internal) {
     GV->setLinkage(llvm::Function::InternalLinkage);
-  } else if (D->hasAttr<DLLExportAttr>(getContext())) {
+  } else if (D->hasAttr<DLLExportAttr>()) {
     GV->setLinkage(llvm::Function::DLLExportLinkage);
-  } else if (D->hasAttr<WeakAttr>(getContext())) {
+  } else if (D->hasAttr<WeakAttr>()) {
     GV->setLinkage(llvm::Function::WeakAnyLinkage);
   } else if (Linkage == GVA_C99Inline) {
     // In C99 mode, 'inline' functions are guaranteed to have a strong
@@ -341,10 +341,10 @@
                                         AttributeList.size()));
 
   // Set the appropriate calling convention for the Function.
-  if (D->hasAttr<FastCallAttr>(getContext()))
+  if (D->hasAttr<FastCallAttr>())
     F->setCallingConv(llvm::CallingConv::X86_FastCall);
 
-  if (D->hasAttr<StdCallAttr>(getContext()))
+  if (D->hasAttr<StdCallAttr>())
     F->setCallingConv(llvm::CallingConv::X86_StdCall);
 }
 
@@ -353,10 +353,10 @@
   if (!Features.Exceptions && !Features.ObjCNonFragileABI)
     F->addFnAttr(llvm::Attribute::NoUnwind);  
 
-  if (D->hasAttr<AlwaysInlineAttr>(getContext()))
+  if (D->hasAttr<AlwaysInlineAttr>())
     F->addFnAttr(llvm::Attribute::AlwaysInline);
   
-  if (D->hasAttr<NoinlineAttr>(getContext()))
+  if (D->hasAttr<NoinlineAttr>())
     F->addFnAttr(llvm::Attribute::NoInline);
 }
 
@@ -364,10 +364,10 @@
                                         llvm::GlobalValue *GV) {
   setGlobalVisibility(GV, D);
 
-  if (D->hasAttr<UsedAttr>(getContext()))
+  if (D->hasAttr<UsedAttr>())
     AddUsedGlobal(GV);
 
-  if (const SectionAttr *SA = D->getAttr<SectionAttr>(getContext()))
+  if (const SectionAttr *SA = D->getAttr<SectionAttr>())
     GV->setSection(SA->getName());
 }
 
@@ -391,10 +391,10 @@
   // Only a few attributes are set on declarations; these may later be
   // overridden by a definition.
   
-  if (FD->hasAttr<DLLImportAttr>(getContext())) {
+  if (FD->hasAttr<DLLImportAttr>()) {
     F->setLinkage(llvm::Function::DLLImportLinkage);
-  } else if (FD->hasAttr<WeakAttr>(getContext()) || 
-             FD->hasAttr<WeakImportAttr>(getContext())) {
+  } else if (FD->hasAttr<WeakAttr>() || 
+             FD->hasAttr<WeakImportAttr>()) {
     // "extern_weak" is overloaded in LLVM; we probably should have
     // separate linkage types for this. 
     F->setLinkage(llvm::Function::ExternalWeakLinkage);
@@ -402,7 +402,7 @@
     F->setLinkage(llvm::Function::ExternalLinkage); 
   }
 
-  if (const SectionAttr *SA = FD->getAttr<SectionAttr>(getContext()))
+  if (const SectionAttr *SA = FD->getAttr<SectionAttr>())
     F->setSection(SA->getName());
 }
 
@@ -516,13 +516,13 @@
 bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {
   // Never defer when EmitAllDecls is specified or the decl has
   // attribute used.
-  if (Features.EmitAllDecls || Global->hasAttr<UsedAttr>(getContext()))
+  if (Features.EmitAllDecls || Global->hasAttr<UsedAttr>())
     return false;
 
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Global)) {
     // Constructors and destructors should never be deferred.
-    if (FD->hasAttr<ConstructorAttr>(getContext()) || 
-        FD->hasAttr<DestructorAttr>(getContext()))
+    if (FD->hasAttr<ConstructorAttr>() || 
+        FD->hasAttr<DestructorAttr>())
       return false;
 
     GVALinkage Linkage = GetLinkageForFunction(getContext(), FD, Features);
@@ -546,7 +546,7 @@
   
   // If this is an alias definition (which otherwise looks like a declaration)
   // emit it now.
-  if (Global->hasAttr<AliasAttr>(getContext()))
+  if (Global->hasAttr<AliasAttr>())
     return EmitAliasDefinition(Global);
 
   // Ignore declarations, they will be emitted on their first use.
@@ -735,8 +735,8 @@
     if (D->getStorageClass() == VarDecl::PrivateExtern)
       GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
-    if (D->hasAttr<WeakAttr>(getContext()) || 
-        D->hasAttr<WeakImportAttr>(getContext()))
+    if (D->hasAttr<WeakAttr>() || 
+        D->hasAttr<WeakImportAttr>())
       GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 
     GV->setThreadLocal(D->isThreadSpecified());
@@ -856,7 +856,7 @@
     cast<llvm::GlobalValue>(Entry)->eraseFromParent();
   }
 
-  if (const AnnotateAttr *AA = D->getAttr<AnnotateAttr>(getContext())) {
+  if (const AnnotateAttr *AA = D->getAttr<AnnotateAttr>()) {
     SourceManager &SM = Context.getSourceManager();
     AddAnnotation(EmitAnnotateAttr(GV, AA,
                               SM.getInstantiationLineNumber(D->getLocation())));
@@ -869,11 +869,11 @@
   // Set the llvm linkage type as appropriate.
   if (D->getStorageClass() == VarDecl::Static)
     GV->setLinkage(llvm::Function::InternalLinkage);
-  else if (D->hasAttr<DLLImportAttr>(getContext()))
+  else if (D->hasAttr<DLLImportAttr>())
     GV->setLinkage(llvm::Function::DLLImportLinkage);
-  else if (D->hasAttr<DLLExportAttr>(getContext()))
+  else if (D->hasAttr<DLLExportAttr>())
     GV->setLinkage(llvm::Function::DLLExportLinkage);
-  else if (D->hasAttr<WeakAttr>(getContext()))
+  else if (D->hasAttr<WeakAttr>())
     GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage);
   else if (!CompileOpts.NoCommon &&
            (!D->hasExternalStorage() && !D->getInit()))
@@ -1036,14 +1036,14 @@
   SetFunctionDefinitionAttributes(D, Fn);
   SetLLVMFunctionAttributesForDefinition(D, Fn);
   
-  if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>(getContext()))
+  if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>())
     AddGlobalCtor(Fn, CA->getPriority());
-  if (const DestructorAttr *DA = D->getAttr<DestructorAttr>(getContext()))
+  if (const DestructorAttr *DA = D->getAttr<DestructorAttr>())
     AddGlobalDtor(Fn, DA->getPriority());
 }
 
 void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
-  const AliasAttr *AA = D->getAttr<AliasAttr>(getContext());
+  const AliasAttr *AA = D->getAttr<AliasAttr>();
   assert(AA && "Not an alias?");
 
   const llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
@@ -1099,7 +1099,7 @@
   // Set attributes which are particular to an alias; this is a
   // specialization of the attributes which may be set on a global
   // variable/function.
-  if (D->hasAttr<DLLExportAttr>(getContext())) {
+  if (D->hasAttr<DLLExportAttr>()) {
     if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
       // The dllexport attribute is ignored for undefined symbols.
       if (FD->getBody(getContext()))
@@ -1107,8 +1107,8 @@
     } else {
       GA->setLinkage(llvm::Function::DLLExportLinkage);
     }
-  } else if (D->hasAttr<WeakAttr>(getContext()) || 
-             D->hasAttr<WeakImportAttr>(getContext())) {
+  } else if (D->hasAttr<WeakAttr>() || 
+             D->hasAttr<WeakImportAttr>()) {
     GA->setLinkage(llvm::Function::WeakAnyLinkage);
   }
 
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 8501835..8018b4f 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -87,7 +87,7 @@
 bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) {
   // Clang's "overloadable" attribute extension to C/C++ implies
   // name mangling (always).
-  if (!FD->hasAttr<OverloadableAttr>(Context)) {
+  if (!FD->hasAttr<OverloadableAttr>()) {
     // C functions are not mangled, and "main" is never mangled.
     if (!Context.getLangOptions().CPlusPlus || FD->isMain())
       return false;
@@ -111,7 +111,7 @@
 bool CXXNameMangler::mangle(const NamedDecl *D) {
   // Any decl can be declared with __asm("foo") on it, and this takes
   // precedence over all other naming in the .o file.
-  if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>(Context)) {
+  if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
     // If we have an asm name, then we use it as the mangling.
     Out << '\01';  // LLVM IR Marker for __asm("foo")
     Out << ALA->getLabel();