summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-10-12 15:52:35 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-10-12 16:56:53 +0200
commitcd8a49053664e5b4b17c9b121f55afec0aae3b7b (patch)
tree6c35e8303e79b7fab687e8581212ed45e762fc2b
parent2acc59ea28d7cabbef9b91d379f03ab6877596bf (diff)
compilers don't seem to warn about unused variables in the global scope
And this causes at least some problems with extern variables in headers, maybe that could be handled, but it probably wouldn't be trivial to get it exactly right about which location to warn and which ones not. Change-Id: I8974c9ba9493d09165b026ee7a451238f6d90a30
-rw-r--r--compilerplugins/clang/unusedvariablecheck.cxx2
1 files changed, 2 insertions, 0 deletions
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx
index b6b867dec89c..3d9ca3de0513 100644
--- a/compilerplugins/clang/unusedvariablecheck.cxx
+++ b/compilerplugins/clang/unusedvariablecheck.cxx
@@ -47,6 +47,8 @@ bool UnusedVariableCheck::VisitNamedDecl( NamedDecl* declaration )
const VarDecl* var = cast< VarDecl >( declaration );
if( var->isReferenced() || var->isUsed())
return true;
+ if( var->isDefinedOutsideFunctionOrMethod())
+ return true;
if( CXXRecordDecl* type = var->getType()->getAsCXXRecordDecl())
{
bool warn_unused = false;