From b4b64ca752f5c0e5b95ed64a94ddaeb72e0b8f5f Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 30 Jun 2009 02:34:44 +0000 Subject: 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. llvm-svn: 74501 --- clang/lib/CodeGen/CodeGenModule.cpp | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 7957a9fe88b..efa50ba3387 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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(getContext())) { + if (const VisibilityAttr *attr = D->getAttr()) { 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(getContext())) { + } else if (D->hasAttr()) { GV->setLinkage(llvm::Function::DLLExportLinkage); - } else if (D->hasAttr(getContext())) { + } else if (D->hasAttr()) { 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(getContext())) + if (D->hasAttr()) F->setCallingConv(llvm::CallingConv::X86_FastCall); - if (D->hasAttr(getContext())) + if (D->hasAttr()) 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(getContext())) + if (D->hasAttr()) F->addFnAttr(llvm::Attribute::AlwaysInline); - if (D->hasAttr(getContext())) + if (D->hasAttr()) F->addFnAttr(llvm::Attribute::NoInline); } @@ -364,10 +364,10 @@ void CodeGenModule::SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV) { setGlobalVisibility(GV, D); - if (D->hasAttr(getContext())) + if (D->hasAttr()) AddUsedGlobal(GV); - if (const SectionAttr *SA = D->getAttr(getContext())) + if (const SectionAttr *SA = D->getAttr()) 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(getContext())) { + if (FD->hasAttr()) { F->setLinkage(llvm::Function::DLLImportLinkage); - } else if (FD->hasAttr(getContext()) || - FD->hasAttr(getContext())) { + } else if (FD->hasAttr() || + FD->hasAttr()) { // "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(getContext())) + if (const SectionAttr *SA = FD->getAttr()) 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(getContext())) + if (Features.EmitAllDecls || Global->hasAttr()) return false; if (const FunctionDecl *FD = dyn_cast(Global)) { // Constructors and destructors should never be deferred. - if (FD->hasAttr(getContext()) || - FD->hasAttr(getContext())) + if (FD->hasAttr() || + FD->hasAttr()) 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(getContext())) + if (Global->hasAttr()) 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(getContext()) || - D->hasAttr(getContext())) + if (D->hasAttr() || + D->hasAttr()) GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); GV->setThreadLocal(D->isThreadSpecified()); @@ -856,7 +856,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { cast(Entry)->eraseFromParent(); } - if (const AnnotateAttr *AA = D->getAttr(getContext())) { + if (const AnnotateAttr *AA = D->getAttr()) { 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(getContext())) + else if (D->hasAttr()) GV->setLinkage(llvm::Function::DLLImportLinkage); - else if (D->hasAttr(getContext())) + else if (D->hasAttr()) GV->setLinkage(llvm::Function::DLLExportLinkage); - else if (D->hasAttr(getContext())) + else if (D->hasAttr()) 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(getContext())) + if (const ConstructorAttr *CA = D->getAttr()) AddGlobalCtor(Fn, CA->getPriority()); - if (const DestructorAttr *DA = D->getAttr(getContext())) + if (const DestructorAttr *DA = D->getAttr()) AddGlobalDtor(Fn, DA->getPriority()); } void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { - const AliasAttr *AA = D->getAttr(getContext()); + const AliasAttr *AA = D->getAttr(); 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(getContext())) { + if (D->hasAttr()) { if (const FunctionDecl *FD = dyn_cast(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(getContext()) || - D->hasAttr(getContext())) { + } else if (D->hasAttr() || + D->hasAttr()) { GA->setLinkage(llvm::Function::WeakAnyLinkage); } -- cgit v1.2.3