[cfe-commits] r117431 - /cfe/trunk/lib/Sema/SemaDecl.cpp
John McCall
rjmccall at apple.com
Tue Oct 26 18:41:35 PDT 2010
Author: rjmccall
Date: Tue Oct 26 20:41:35 2010
New Revision: 117431
URL: http://llvm.org/viewvc/llvm-project?rev=117431&view=rev
Log:
Avoid calculating linkage until the more obvious checks have run when
deciding whether to queue a decl for unused-declaration warnings.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=117431&r1=117430&r2=117431&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 26 20:41:35 2010
@@ -559,10 +559,6 @@
if (D->getDeclContext()->isDependentContext())
return false;
- // We warn for unused decls internal to the translation unit.
- if (D->getLinkage() == ExternalLinkage)
- return false;
-
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return false;
@@ -577,25 +573,32 @@
return false;
}
- if (FD->isThisDeclarationADefinition())
- return !Context.DeclMustBeEmitted(FD);
- return true;
- }
+ if (FD->isThisDeclarationADefinition() &&
+ Context.DeclMustBeEmitted(FD))
+ return false;
+
+ } else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ if (!VD->isFileVarDecl() ||
+ VD->getType().isConstant(Context) ||
+ Context.DeclMustBeEmitted(VD))
+ return false;
- if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (VD->isStaticDataMember() &&
VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return false;
- if ( VD->isFileVarDecl() &&
- !VD->getType().isConstant(Context))
- return !Context.DeclMustBeEmitted(VD);
+ } else {
+ return false;
}
- return false;
- }
+ // Only warn for unused decls internal to the translation unit.
+ if (D->getLinkage() == ExternalLinkage)
+ return false;
+
+ return true;
+}
- void Sema::MarkUnusedFileScopedDecl(const DeclaratorDecl *D) {
+void Sema::MarkUnusedFileScopedDecl(const DeclaratorDecl *D) {
if (!D)
return;
More information about the cfe-commits
mailing list