summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/sallogareas.cxx8
-rw-r--r--compilerplugins/clang/sallogareas.hxx1
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;
};