[cfe-commits] r81589 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/Mangle.cpp lib/Sema/SemaDecl.cpp
Douglas Gregor
dgregor at apple.com
Fri Sep 11 17:17:51 PDT 2009
Author: dgregor
Date: Fri Sep 11 19:17:51 2009
New Revision: 81589
URL: http://llvm.org/viewvc/llvm-project?rev=81589&view=rev
Log:
Remove unnecessary ASTContext parameters from isMain and isExternC
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=81589&r1=81588&r2=81589&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Sep 11 19:17:51 2009
@@ -573,7 +573,7 @@
/// \brief Determines whether this variable is a variable with
/// external, C linkage.
- bool isExternC(ASTContext &Context) const;
+ bool isExternC() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
@@ -961,11 +961,11 @@
/// \brief Determines whether this is a function "main", which is
/// the entry point into an executable program.
- bool isMain(ASTContext &Context) const;
+ bool isMain() const;
/// \brief Determines whether this function is a function with
/// external, C linkage.
- bool isExternC(ASTContext &Context) const;
+ bool isExternC() const;
/// \brief Determines whether this is a global function.
bool isGlobal() const;
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=81589&r1=81588&r2=81589&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Sep 11 19:17:51 2009
@@ -117,7 +117,8 @@
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 @@
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)
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=81589&r1=81588&r2=81589&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Sep 11 19:17:51 2009
@@ -561,7 +561,7 @@
// 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.
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=81589&r1=81588&r2=81589&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Fri Sep 11 19:17:51 2009
@@ -99,7 +99,7 @@
// (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.
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=81589&r1=81588&r2=81589&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 11 19:17:51 2009
@@ -2239,7 +2239,7 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
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);
More information about the cfe-commits
mailing list