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()
|
void SalLogAreas::run()
|
||||||
{
|
{
|
||||||
inFunction = NULL;
|
inFunction = NULL;
|
||||||
|
lastSalDetailLogStreamMacro = SourceLocation();
|
||||||
TraverseDecl( context.getTranslationUnitDecl());
|
TraverseDecl( context.getTranslationUnitDecl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +56,13 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
|
|||||||
{
|
{
|
||||||
if( const StringLiteral* area = dyn_cast< StringLiteral >( call->getArg( 1 )->IgnoreParenImpCasts()))
|
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 )
|
if( area->getKind() == StringLiteral::Ascii )
|
||||||
checkArea( area->getBytes(), area->getExprLoc());
|
checkArea( area->getBytes(), area->getExprLoc());
|
||||||
else
|
else
|
||||||
|
@@ -31,6 +31,7 @@ class SalLogAreas
|
|||||||
void checkArea( StringRef area, SourceLocation location );
|
void checkArea( StringRef area, SourceLocation location );
|
||||||
void readLogAreas();
|
void readLogAreas();
|
||||||
const FunctionDecl* inFunction;
|
const FunctionDecl* inFunction;
|
||||||
|
SourceLocation lastSalDetailLogStreamMacro;
|
||||||
set< string > logAreas;
|
set< string > logAreas;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user