Kaydet (Commit) 7cd19a8f authored tarafından Luboš Luňák's avatar Luboš Luňák

do not analyse system headers in the compiler plugin

Change-Id: Ica1e233b45cc778bfdc86cfd608ada7fc261c6c2
üst 4d050998
......@@ -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;
......
......@@ -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.
*/
......
......@@ -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
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment