diff options
author | Lubos Lunak <l.lunak@suse.cz> | 2012-10-17 19:53:32 +0200 |
---|---|---|
committer | Lubos Lunak <l.lunak@suse.cz> | 2012-10-19 10:15:42 +0200 |
commit | 1a77b93aec7070327a91f21c801d2e951b5a068d (patch) | |
tree | dc11fb9168393b13d4587b3e16384eea94f6fa14 /compilerplugins/clang | |
parent | 06b8cdc503e021a644219a064503433482d98d48 (diff) |
only one warning per one SAL_INFO/SAL_WARN
Change-Id: I5aafe9ed51c86dc31492d205f44fba6b1db137d2
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/sallogareas.cxx | 8 | ||||
-rw-r--r-- | compilerplugins/clang/sallogareas.hxx | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx index 1dd99b9b727a..1a4a8b25c3c2 100644 --- a/compilerplugins/clang/sallogareas.cxx +++ b/compilerplugins/clang/sallogareas.cxx @@ -31,6 +31,7 @@ SalLogAreas::SalLogAreas( ASTContext& context ) void SalLogAreas::run() { inFunction = NULL; + lastSalDetailLogStreamMacro = SourceLocation(); TraverseDecl( context.getTranslationUnitDecl()); } @@ -55,6 +56,13 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call ) { if( const StringLiteral* area = dyn_cast< StringLiteral >( call->getArg( 1 )->IgnoreParenImpCasts())) { + // The SAL_DETAIL_LOG_STREAM macro expands to two calls to sal::detail::log(), + // so do not warn repeatedly about the same macro (the area->getLocStart() of all the calls + // from the same macro should be the same). + SourceLocation expansionLocation = context.getSourceManager().getExpansionLoc(area->getLocStart()); + if( expansionLocation == lastSalDetailLogStreamMacro ) + return true; + lastSalDetailLogStreamMacro = expansionLocation; if( area->getKind() == StringLiteral::Ascii ) checkArea( area->getBytes(), area->getExprLoc()); else diff --git a/compilerplugins/clang/sallogareas.hxx b/compilerplugins/clang/sallogareas.hxx index 72f0e756d633..e83e890697e4 100644 --- a/compilerplugins/clang/sallogareas.hxx +++ b/compilerplugins/clang/sallogareas.hxx @@ -31,6 +31,7 @@ class SalLogAreas void checkArea( StringRef area, SourceLocation location ); void readLogAreas(); const FunctionDecl* inFunction; + SourceLocation lastSalDetailLogStreamMacro; set< string > logAreas; }; |