]> granicus.if.org Git - clang/commitdiff
Cleanup, no functionality change.
authorAnders Carlsson <andersca@mac.com>
Sat, 7 Nov 2009 07:18:14 +0000 (07:18 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 7 Nov 2009 07:18:14 +0000 (07:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86351 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index 0616fca6b8cb7eab61c567cc0f5ce7a946ba2571..df7be1022353f5c0df9f7acfbb889777764d0cb6 100644 (file)
@@ -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);