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
if( bodyColumn == nextStatementColumn )
{
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;
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;
}
return;
......
......@@ -42,10 +42,11 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess
if( level == DiagnosticsEngine::Error && diag.getErrorsAsFatal())
level = DiagnosticsEngine::Fatal;
#endif
string fullMessage = ( message + " [loplugin]" ).str();
if( loc.isValid())
return diag.Report( loc, diag.getCustomDiagID( level, message ));
return diag.Report( loc, diag.getCustomDiagID( level, fullMessage ));
else
return diag.Report( diag.getCustomDiagID( level, message ));
return diag.Report( diag.getCustomDiagID( level, fullMessage ));
}
bool Plugin::ignoreLocation( SourceLocation loc )
......@@ -174,7 +175,7 @@ bool RewritePlugin::replaceText( SourceRange range, SourceRange replacementRange
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;
}
......
......@@ -61,7 +61,7 @@ PluginHandler::PluginHandler( ASTContext& context, const vector< string >& args
}
pluginObjectsCreated = true;
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()
......@@ -126,17 +126,17 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
}
}
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 )
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 )
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 )
; // ok
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();
continue; // --->
}
......@@ -157,7 +157,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
ostream.clear_error();
unlink( filename );
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;
}
}
......
......@@ -119,7 +119,7 @@ bool PostfixIncrementFix::canChangePostfixToPrefix( const CXXOperatorCallExpr* o
return canChangeInConditionStatement( op, dyn_cast< ForStmt >( parents[ parent_pos ] )->getCond(),
parents, parent_pos );
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();
// parents[ parent_pos ]->dump();
// parents[ std::max( parent_pos - 3, 0 ) ]->dump();
......@@ -155,7 +155,7 @@ bool PostfixIncrementFix::shouldDoChange( const Expr* operand )
return true;
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->dump();
operand->dump();
......
......@@ -70,7 +70,7 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
if( area->getKind() == StringLiteral::Ascii )
checkArea( area->getBytes(), area->getExprLoc());
else
report( DiagnosticsEngine::Warning, "unsupported string literal kind (plugin needs fixing?) [loplugin]",
report( DiagnosticsEngine::Warning, "unsupported string literal kind (plugin needs fixing?)",
area->getLocStart());
return true;
}
......@@ -87,11 +87,11 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
if( inMacro == "SAL_DEBUG" )
return true; // ok
}
report( DiagnosticsEngine::Warning, "missing log area [loplugin]",
report( DiagnosticsEngine::Warning, "missing log area",
call->getArg( 1 )->IgnoreParenImpCasts()->getLocStart());
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());
}
}
......@@ -105,7 +105,7 @@ void SalLogAreas::checkArea( StringRef area, SourceLocation location )
readLogAreas();
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;
}
}
......@@ -130,7 +130,7 @@ void SalLogAreas::readLogAreas()
}
// If you get this error message, you possibly have too old icecream (ICECC_EXTRAFILES is needed).
if( logAreas.empty())
report( DiagnosticsEngine::Warning, "error reading log areas [loplugin]" );
report( DiagnosticsEngine::Warning, "error reading log areas" );
}
static Plugin::Registration< SalLogAreas > X( "sallogareas" );
......
......@@ -89,11 +89,11 @@ bool UnusedVariableCheck::VisitVarDecl( VarDecl* var )
if( const FunctionDecl* func = dyn_cast_or_null< FunctionDecl >( param->getParentFunctionOrMethod()))
if( !func->doesThisDeclarationHaveABody())
return true;
report( DiagnosticsEngine::Warning, "unused parameter %0 [loplugin]",
report( DiagnosticsEngine::Warning, "unused parameter %0",
var->getLocation()) << var->getDeclName();
}
else
report( DiagnosticsEngine::Warning, "unused variable %0 [loplugin]",
report( DiagnosticsEngine::Warning, "unused variable %0",
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