diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-12 00:17:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-12 00:17:51 +0000 |
commit | 48a83b5e7ae4051c7c11680ac00c1fa02d610a62 (patch) | |
tree | 67768c87edafe6ba7eb591e81184571540fd57de /lib | |
parent | af3280fadbdab6305581955c973e1229970958eb (diff) |
Remove unnecessary ASTContext parameters from isMain and isExternC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Decl.cpp | 9 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 17 |
4 files changed, 17 insertions, 13 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 66f20364a6..ab8de1d5fe 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -117,7 +117,8 @@ void VarDecl::setInit(ASTContext &C, Expr *I) { Init = I; } -bool VarDecl::isExternC(ASTContext &Context) const { +bool VarDecl::isExternC() const { + ASTContext &Context = getASTContext(); if (!Context.getLangOptions().CPlusPlus) return (getDeclContext()->isTranslationUnit() && getStorageClass() != Static) || @@ -444,13 +445,15 @@ void FunctionDecl::setBody(Stmt *B) { EndRangeLoc = B->getLocEnd(); } -bool FunctionDecl::isMain(ASTContext &Context) const { +bool FunctionDecl::isMain() const { + ASTContext &Context = getASTContext(); return !Context.getLangOptions().Freestanding && getDeclContext()->getLookupContext()->isTranslationUnit() && getIdentifier() && getIdentifier()->isStr("main"); } -bool FunctionDecl::isExternC(ASTContext &Context) const { +bool FunctionDecl::isExternC() const { + ASTContext &Context = getASTContext(); // In C, any non-static, non-overloadable function has external // linkage. if (!Context.getLangOptions().CPlusPlus) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 00182113f8..ae7a8b1dcb 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -561,7 +561,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { // In C++, if this is marked "extern", defer code generation. if (getLangOptions().CPlusPlus && !VD->getInit() && (VD->getStorageClass() == VarDecl::Extern || - VD->isExternC(getContext()))) + VD->isExternC())) return; // In C, if this isn't a definition, defer code generation. diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index f9495b81b3..434d3c48fe 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -99,7 +99,7 @@ bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) { // (always). if (!FD->hasAttr<OverloadableAttr>()) { // C functions are not mangled, and "main" is never mangled. - if (!Context.getLangOptions().CPlusPlus || FD->isMain(Context)) + if (!Context.getLangOptions().CPlusPlus || FD->isMain()) return false; // No mangling in an "implicit extern C" header. diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 53fab18017..a1bcb63892 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2239,7 +2239,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, // If this is a locally-scoped extern C variable, update the map of // such variables. - if (CurContext->isFunctionOrMethod() && NewVD->isExternC(Context) && + if (CurContext->isFunctionOrMethod() && NewVD->isExternC() && !NewVD->isInvalidDecl()) RegisterLocallyScopedExternCDecl(NewVD, PrevDecl, S); @@ -2329,7 +2329,7 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl, NewVD->setType(FixedTy); } - if (!PrevDecl && NewVD->isExternC(Context)) { + if (!PrevDecl && NewVD->isExternC()) { // Since we did not find anything by this name and we're declaring // an extern "C" variable, look for a non-visible extern "C" // declaration with the same name. @@ -2779,7 +2779,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // If this is a locally-scoped extern C function, update the // map of such names. - if (CurContext->isFunctionOrMethod() && NewFD->isExternC(Context) + if (CurContext->isFunctionOrMethod() && NewFD->isExternC() && !NewFD->isInvalidDecl()) RegisterLocallyScopedExternCDecl(NewFD, PrevDecl, S); @@ -2820,7 +2820,8 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl, return NewFD->setInvalidDecl(); } - if (NewFD->isMain(Context)) CheckMain(NewFD); + if (NewFD->isMain()) + CheckMain(NewFD); // Semantic checking for this function declaration (in isolation). if (getLangOptions().CPlusPlus) { @@ -2877,7 +2878,7 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl, NewFD->setC99InlineDefinition(true); // Check for a previous declaration of this name. - if (!PrevDecl && NewFD->isExternC(Context)) { + if (!PrevDecl && NewFD->isExternC()) { // Since we did not find anything by this name and we're declaring // an extern "C" function, look for a non-visible extern "C" // declaration with the same name. @@ -3289,7 +3290,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, QualType InitType = Type; if (const ArrayType *Array = Context.getAsArrayType(Type)) InitType = Array->getElementType(); - if ((!Var->hasExternalStorage() && !Var->isExternC(Context)) && + if ((!Var->hasExternalStorage() && !Var->isExternC()) && InitType->isRecordType() && !InitType->isDependentType()) { if (!RequireCompleteType(Var->getLocation(), InitType, diag::err_invalid_incomplete_type_use)) { @@ -3623,7 +3624,7 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { // definition itself provides a prototype. The aim is to detect // global functions that fail to be declared in header files. if (!FD->isInvalidDecl() && FD->isGlobal() && !isa<CXXMethodDecl>(FD) && - !FD->isMain(Context)) { + !FD->isMain()) { bool MissingPrototype = true; for (const FunctionDecl *Prev = FD->getPreviousDeclaration(); Prev; Prev = Prev->getPreviousDeclaration()) { @@ -3697,7 +3698,7 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, if (FD) { FD->setBody(Body); - if (FD->isMain(Context)) + if (FD->isMain()) // C and C++ allow for main to automagically return 0. // Implements C++ [basic.start.main]p5 and C99 5.1.2.2.3. FD->setHasImplicitReturnZero(true); |