diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-30 02:34:44 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-30 02:34:44 +0000 |
commit | 40b598eea1310ec9ed554d56ce3e25b34c585458 (patch) | |
tree | 8e2c3592f8ed4ac239504747ebffb388d5b170d6 /lib/CodeGen | |
parent | e4f2142d00fa5fdb580c4e2413da91882d955381 (diff) |
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 12 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 58 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 4 |
9 files changed, 49 insertions, 49 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 66b1f17368..a919dfa2e3 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -522,7 +522,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, 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 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, 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 8ff58914cb..b5195c4a54 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -377,13 +377,13 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, // 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 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, 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 f97c62f9d1..2ae7e225eb 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -60,7 +60,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) { /// 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 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { } // 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 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { 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 @@ const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty, /// 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 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { } // 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 a21140765c..0951019f01 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -670,7 +670,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { 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 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { // 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 e7cf8e6e65..51f9a76579 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -126,7 +126,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD, /// 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 865e8c240b..b9e8495596 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1360,7 +1360,7 @@ static llvm::Constant *getConstantGEP(llvm::Constant *C, /// 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 f10a08f9db..672f6da502 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -199,7 +199,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, 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 7957a9fe88..efa50ba338 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -102,7 +102,7 @@ CodeGenModule::getDeclVisibilityMode(const Decl *D) const { 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 @@ void CodeGenModule::SetFunctionDefinitionAttributes(const FunctionDecl *D, 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 @@ void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D, 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 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, 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 @@ void CodeGenModule::SetCommonAttributes(const Decl *D, 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 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD, // 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 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD, 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 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV, 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 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { // 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 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName, 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 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { 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 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { // 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 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { 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 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { // 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 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { } 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 850183568a..8018b4f45a 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -87,7 +87,7 @@ static bool isInCLinkageSpecification(const Decl *D) { 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::mangleFunctionDecl(const FunctionDecl *FD) { 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(); |