diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-07 07:18:14 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-07 07:18:14 +0000 |
commit | 99a000e3ca7224cd70a2e87cc2751d78595c97f5 (patch) | |
tree | b02a93604119ef18c024650c08aa1232e1b88425 /lib/Sema/SemaDecl.cpp | |
parent | a1e1622d1549c470acc999c4399456863e58a011 (diff) |
Cleanup, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86351 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 0616fca6b8..df7be10223 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -384,6 +384,12 @@ bool Sema::isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S) { 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 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { 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); |