summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-10-09 16:39:49 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-10-09 17:25:28 +0200
commit7cd19a8f10881028bfaf4217e586955f1d435c31 (patch)
tree676f9a1592d2702465140b9eddaa1096cdefd31a /compilerplugins
parent4d05099806fc6116fbd7abe992d7f2f31210dd4c (diff)
do not analyse system headers in the compiler plugin
Change-Id: Ica1e233b45cc778bfdc86cfd608ada7fc261c6c2
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/bodynotinblock.cxx3
-rw-r--r--compilerplugins/clang/compileplugin.cxx5
-rw-r--r--compilerplugins/clang/compileplugin.hxx15
-rw-r--r--compilerplugins/clang/unusedvariablecheck.cxx3
4 files changed, 22 insertions, 4 deletions
diff --git a/compilerplugins/clang/bodynotinblock.cxx b/compilerplugins/clang/bodynotinblock.cxx
index ce19a5f6477a..9e59896f892f 100644
--- a/compilerplugins/clang/bodynotinblock.cxx
+++ b/compilerplugins/clang/bodynotinblock.cxx
@@ -32,8 +32,7 @@ void BodyNotInBlock::run()
bool BodyNotInBlock::VisitFunctionDecl( FunctionDecl* declaration )
{
- // TODO also LO header files? or a subdir?
- if( !context.getSourceManager().isFromMainFile( declaration->getLocStart()))
+ if( ignoreLocation( declaration ))
return true;
if( !declaration->doesThisDeclarationHaveABody())
return true;
diff --git a/compilerplugins/clang/compileplugin.cxx b/compilerplugins/clang/compileplugin.cxx
index e5d34a32ccd5..a61a3bab66a4 100644
--- a/compilerplugins/clang/compileplugin.cxx
+++ b/compilerplugins/clang/compileplugin.cxx
@@ -43,6 +43,11 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess
return diag.Report( loc, diag.getCustomDiagID( level, message ));
}
+bool Plugin::ignoreLocation( SourceLocation loc )
+ {
+ return context.getSourceManager().isInSystemHeader( context.getSourceManager().getExpansionLoc( loc ));
+ }
+
/**
Class that manages all LO modules.
*/
diff --git a/compilerplugins/clang/compileplugin.hxx b/compilerplugins/clang/compileplugin.hxx
index edf3a5ea11a8..a02b36005e4b 100644
--- a/compilerplugins/clang/compileplugin.hxx
+++ b/compilerplugins/clang/compileplugin.hxx
@@ -24,9 +24,24 @@ class Plugin
explicit Plugin( ASTContext& context );
protected:
DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc );
+ bool ignoreLocation( SourceLocation loc );
+ bool ignoreLocation( const Decl* decl );
+ bool ignoreLocation( const Stmt* stmt );
ASTContext& context;
};
+inline
+bool Plugin::ignoreLocation( const Decl* decl )
+ {
+ return ignoreLocation( decl->getLocStart());
+ }
+
+inline
+bool Plugin::ignoreLocation( const Stmt* stmt )
+ {
+ return ignoreLocation( stmt->getLocStart());
+ }
+
} // namespace
#endif // COMPILEPLUGIN_H
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx
index a9e47b2eb316..f2916320718d 100644
--- a/compilerplugins/clang/unusedvariablecheck.cxx
+++ b/compilerplugins/clang/unusedvariablecheck.cxx
@@ -40,8 +40,7 @@ void UnusedVariableCheck::run()
bool UnusedVariableCheck::VisitNamedDecl( NamedDecl* declaration )
{
- // TODO also LO header files? or a subdir?
- if( !context.getSourceManager().isFromMainFile( declaration->getLocStart()))
+ if( ignoreLocation( declaration ))
return true;
if( !isa< VarDecl >( declaration ))
return true;