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 | 2889e0e72c73edc07f7992ea95667fb6d56a5a0f (patch) | |
tree | 744d6621c7980251e37284b7e63202797ca55a68 /clang/lib | |
parent | c0a3561f0f6e1a4fa1d0c71687455a2da3484414 (diff) | |
download | bcm5719-llvm-2889e0e72c73edc07f7992ea95667fb6d56a5a0f.tar.gz bcm5719-llvm-2889e0e72c73edc07f7992ea95667fb6d56a5a0f.zip |
Cleanup, no functionality change.
llvm-svn: 86351
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 0616fca6b8c..df7be102235 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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); |