only one warning per one SAL_INFO/SAL_WARN
Change-Id: I5aafe9ed51c86dc31492d205f44fba6b1db137d2
This commit is contained in:
@@ -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
|
||||
|
@@ -31,6 +31,7 @@ class SalLogAreas
|
||||
void checkArea( StringRef area, SourceLocation location );
|
||||
void readLogAreas();
|
||||
const FunctionDecl* inFunction;
|
||||
SourceLocation lastSalDetailLogStreamMacro;
|
||||
set< string > logAreas;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user