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

append [loplugin] automatically in report() rathen than manually everywhere

Change-Id: I2f98622f152ae0c7ac8d1113d6380f686ac7234c
üst b4392c57
...@@ -122,10 +122,10 @@ void BodyNotInBlock::checkBody( const Stmt* body, SourceLocation stmtLocation, c ...@@ -122,10 +122,10 @@ void BodyNotInBlock::checkBody( const Stmt* body, SourceLocation stmtLocation, c
if( bodyColumn == nextStatementColumn ) if( bodyColumn == nextStatementColumn )
{ {
report( DiagnosticsEngine::Warning, report( DiagnosticsEngine::Warning,
"statement aligned as second statement in %select{if|while|for}0 body but not in a statement block [loplugin]", "statement aligned as second statement in %select{if|while|for}0 body but not in a statement block",
(*it)->getLocStart()) << stmtType; (*it)->getLocStart()) << stmtType;
report( DiagnosticsEngine::Note, report( DiagnosticsEngine::Note,
"%select{if|while|for}0 body statement is here [loplugin]", "%select{if|while|for}0 body statement is here",
body->getLocStart()) << stmtType; body->getLocStart()) << stmtType;
} }
return; return;
......
...@@ -42,10 +42,11 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess ...@@ -42,10 +42,11 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess
if( level == DiagnosticsEngine::Error && diag.getErrorsAsFatal()) if( level == DiagnosticsEngine::Error && diag.getErrorsAsFatal())
level = DiagnosticsEngine::Fatal; level = DiagnosticsEngine::Fatal;
#endif #endif
string fullMessage = ( message + " [loplugin]" ).str();
if( loc.isValid()) if( loc.isValid())
return diag.Report( loc, diag.getCustomDiagID( level, message )); return diag.Report( loc, diag.getCustomDiagID( level, fullMessage ));
else else
return diag.Report( diag.getCustomDiagID( level, message )); return diag.Report( diag.getCustomDiagID( level, fullMessage ));
} }
bool Plugin::ignoreLocation( SourceLocation loc ) bool Plugin::ignoreLocation( SourceLocation loc )
...@@ -174,7 +175,7 @@ bool RewritePlugin::replaceText( SourceRange range, SourceRange replacementRange ...@@ -174,7 +175,7 @@ bool RewritePlugin::replaceText( SourceRange range, SourceRange replacementRange
bool RewritePlugin::reportEditFailure( SourceLocation loc ) bool RewritePlugin::reportEditFailure( SourceLocation loc )
{ {
report( DiagnosticsEngine::Warning, "cannot perform source modification (macro expansion involved?) [loplugin]", loc ); report( DiagnosticsEngine::Warning, "cannot perform source modification (macro expansion involved?)", loc );
return false; return false;
} }
......
...@@ -61,7 +61,7 @@ PluginHandler::PluginHandler( ASTContext& context, const vector< string >& args ...@@ -61,7 +61,7 @@ PluginHandler::PluginHandler( ASTContext& context, const vector< string >& args
} }
pluginObjectsCreated = true; pluginObjectsCreated = true;
if( !args.empty() && !wasCreated ) if( !args.empty() && !wasCreated )
report( DiagnosticsEngine::Fatal, "unknown plugin tool %0 [loplugin]" ) << args.front(); report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << args.front();
} }
PluginHandler::~PluginHandler() PluginHandler::~PluginHandler()
...@@ -126,17 +126,17 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) ...@@ -126,17 +126,17 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
} }
} }
if( modifyFile.empty()) if( modifyFile.empty())
report( DiagnosticsEngine::Warning, "modified source in solver/ : %0 [loplugin]" ) << e->getName(); report( DiagnosticsEngine::Warning, "modified source in solver/ : %0" ) << e->getName();
} }
else if( strncmp( e->getName(), WORKDIR, strlen( WORKDIR )) == 0 ) else if( strncmp( e->getName(), WORKDIR, strlen( WORKDIR )) == 0 )
report( DiagnosticsEngine::Warning, "modified source in workdir/ : %0 [loplugin]" ) << e->getName(); report( DiagnosticsEngine::Warning, "modified source in workdir/ : %0" ) << e->getName();
else if( strcmp( SRCDIR, BUILDDIR ) != 0 && strncmp( e->getName(), BUILDDIR, strlen( BUILDDIR )) == 0 ) else if( strcmp( SRCDIR, BUILDDIR ) != 0 && strncmp( e->getName(), BUILDDIR, strlen( BUILDDIR )) == 0 )
report( DiagnosticsEngine::Warning, "modified source in build dir : %0 [loplugin]" ) << e->getName(); report( DiagnosticsEngine::Warning, "modified source in build dir : %0" ) << e->getName();
else if( strncmp( e->getName(), SRCDIR, strlen( SRCDIR )) == 0 ) else if( strncmp( e->getName(), SRCDIR, strlen( SRCDIR )) == 0 )
; // ok ; // ok
else else
{ {
report( DiagnosticsEngine::Warning, "modified source in unknown location, not modifying : %0 [loplugin]" ) report( DiagnosticsEngine::Warning, "modified source in unknown location, not modifying : %0" )
<< e->getName(); << e->getName();
continue; // ---> continue; // --->
} }
...@@ -157,7 +157,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) ...@@ -157,7 +157,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
ostream.clear_error(); ostream.clear_error();
unlink( filename ); unlink( filename );
if( !ok ) if( !ok )
report( DiagnosticsEngine::Error, "cannot write modified source to %0 (%1) [loplugin]" ) << modifyFile << error; report( DiagnosticsEngine::Error, "cannot write modified source to %0 (%1)" ) << modifyFile << error;
delete[] filename; delete[] filename;
} }
} }
......
...@@ -119,7 +119,7 @@ bool PostfixIncrementFix::canChangePostfixToPrefix( const CXXOperatorCallExpr* o ...@@ -119,7 +119,7 @@ bool PostfixIncrementFix::canChangePostfixToPrefix( const CXXOperatorCallExpr* o
return canChangeInConditionStatement( op, dyn_cast< ForStmt >( parents[ parent_pos ] )->getCond(), return canChangeInConditionStatement( op, dyn_cast< ForStmt >( parents[ parent_pos ] )->getCond(),
parents, parent_pos ); parents, parent_pos );
default: default:
report( DiagnosticsEngine::Fatal, "cannot analyze operator++ (plugin needs fixing) [loplugin]", report( DiagnosticsEngine::Fatal, "cannot analyze operator++ (plugin needs fixing)",
op->getLocStart()) << parents[ parent_pos ]->getSourceRange(); op->getLocStart()) << parents[ parent_pos ]->getSourceRange();
// parents[ parent_pos ]->dump(); // parents[ parent_pos ]->dump();
// parents[ std::max( parent_pos - 3, 0 ) ]->dump(); // parents[ std::max( parent_pos - 3, 0 ) ]->dump();
...@@ -155,7 +155,7 @@ bool PostfixIncrementFix::shouldDoChange( const Expr* operand ) ...@@ -155,7 +155,7 @@ bool PostfixIncrementFix::shouldDoChange( const Expr* operand )
return true; return true;
default: default:
{ {
report( DiagnosticsEngine::Fatal, "cannot analyze operator++ (plugin needs fixing) [loplugin]", report( DiagnosticsEngine::Fatal, "cannot analyze operator++ (plugin needs fixing)",
expr->getLocStart()) << operand->getSourceRange(); expr->getLocStart()) << operand->getSourceRange();
expr->dump(); expr->dump();
operand->dump(); operand->dump();
......
...@@ -70,7 +70,7 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call ) ...@@ -70,7 +70,7 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
if( area->getKind() == StringLiteral::Ascii ) if( area->getKind() == StringLiteral::Ascii )
checkArea( area->getBytes(), area->getExprLoc()); checkArea( area->getBytes(), area->getExprLoc());
else else
report( DiagnosticsEngine::Warning, "unsupported string literal kind (plugin needs fixing?) [loplugin]", report( DiagnosticsEngine::Warning, "unsupported string literal kind (plugin needs fixing?)",
area->getLocStart()); area->getLocStart());
return true; return true;
} }
...@@ -87,11 +87,11 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call ) ...@@ -87,11 +87,11 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
if( inMacro == "SAL_DEBUG" ) if( inMacro == "SAL_DEBUG" )
return true; // ok return true; // ok
} }
report( DiagnosticsEngine::Warning, "missing log area [loplugin]", report( DiagnosticsEngine::Warning, "missing log area",
call->getArg( 1 )->IgnoreParenImpCasts()->getLocStart()); call->getArg( 1 )->IgnoreParenImpCasts()->getLocStart());
return true; return true;
} }
report( DiagnosticsEngine::Warning, "cannot analyse log area argument (plugin needs fixing?) [loplugin]", report( DiagnosticsEngine::Warning, "cannot analyse log area argument (plugin needs fixing?)",
call->getLocStart()); call->getLocStart());
} }
} }
...@@ -105,7 +105,7 @@ void SalLogAreas::checkArea( StringRef area, SourceLocation location ) ...@@ -105,7 +105,7 @@ void SalLogAreas::checkArea( StringRef area, SourceLocation location )
readLogAreas(); readLogAreas();
if( !logAreas.count( area )) if( !logAreas.count( area ))
{ {
report( DiagnosticsEngine::Warning, "unknown log area '%0' (check or extend sal/inc/sal/log-areas.dox) [loplugin]", report( DiagnosticsEngine::Warning, "unknown log area '%0' (check or extend sal/inc/sal/log-areas.dox)",
location ) << area; location ) << area;
} }
} }
...@@ -130,7 +130,7 @@ void SalLogAreas::readLogAreas() ...@@ -130,7 +130,7 @@ void SalLogAreas::readLogAreas()
} }
// If you get this error message, you possibly have too old icecream (ICECC_EXTRAFILES is needed). // If you get this error message, you possibly have too old icecream (ICECC_EXTRAFILES is needed).
if( logAreas.empty()) if( logAreas.empty())
report( DiagnosticsEngine::Warning, "error reading log areas [loplugin]" ); report( DiagnosticsEngine::Warning, "error reading log areas" );
} }
static Plugin::Registration< SalLogAreas > X( "sallogareas" ); static Plugin::Registration< SalLogAreas > X( "sallogareas" );
......
...@@ -89,11 +89,11 @@ bool UnusedVariableCheck::VisitVarDecl( VarDecl* var ) ...@@ -89,11 +89,11 @@ bool UnusedVariableCheck::VisitVarDecl( VarDecl* var )
if( const FunctionDecl* func = dyn_cast_or_null< FunctionDecl >( param->getParentFunctionOrMethod())) if( const FunctionDecl* func = dyn_cast_or_null< FunctionDecl >( param->getParentFunctionOrMethod()))
if( !func->doesThisDeclarationHaveABody()) if( !func->doesThisDeclarationHaveABody())
return true; return true;
report( DiagnosticsEngine::Warning, "unused parameter %0 [loplugin]", report( DiagnosticsEngine::Warning, "unused parameter %0",
var->getLocation()) << var->getDeclName(); var->getLocation()) << var->getDeclName();
} }
else else
report( DiagnosticsEngine::Warning, "unused variable %0 [loplugin]", report( DiagnosticsEngine::Warning, "unused variable %0",
var->getLocation()) << var->getDeclName(); var->getLocation()) << var->getDeclName();
} }
} }
......
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