[cfe-commits] r86351 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Anders Carlsson
andersca at mac.com
Fri Nov 6 23:18:15 PST 2009
Author: andersca
Date: Sat Nov 7 01:18:14 2009
New Revision: 86351
URL: http://llvm.org/viewvc/llvm-project?rev=86351&view=rev
Log:
Cleanup, no functionality change.
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=86351&r1=86350&r2=86351&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Nov 7 01:18:14 2009
@@ -384,6 +384,12 @@
return IdResolver.isDeclInScope(D, Ctx, Context, S);
}
+static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
+ return (!D->isUsed() && !D->hasAttr<UnusedAttr>() && isa<VarDecl>(D) &&
+ !isa<ParmVarDecl>(D) && !isa<ImplicitParamDecl>(D) &&
+ D->getDeclContext()->isFunctionOrMethod());
+}
+
void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
if (S->decl_empty()) return;
assert((S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope)) &&
@@ -400,10 +406,8 @@
if (!D->getDeclName()) continue;
// Diagnose unused variables in this scope.
- if (!D->isUsed() && !D->hasAttr<UnusedAttr>() && isa<VarDecl>(D) &&
- !isa<ParmVarDecl>(D) && !isa<ImplicitParamDecl>(D) &&
- D->getDeclContext()->isFunctionOrMethod())
- Diag(D->getLocation(), diag::warn_unused_variable) << D->getDeclName();
+ if (ShouldDiagnoseUnusedDecl(D))
+ Diag(D->getLocation(), diag::warn_unused_variable) << D->getDeclName();
// Remove this name from our lexical scope.
IdResolver.RemoveDecl(D);
More information about the cfe-commits
mailing list