Command line: Added --template=clang formatting

This commit is contained in:
Daniel Marjamäki 2017-05-19 17:09:49 +02:00
parent f92b16706c
commit b53a2ff9eb
3 changed files with 27 additions and 3 deletions

View File

@ -992,7 +992,7 @@ void CmdLineParser::PrintHelp()
" '{file}:{line},{severity},{id},{message}' or\n"
" '{file}({line}):({severity}) {message}' or\n"
" '{callstack} {message}'\n"
" Pre-defined templates: gcc, vs, edit.\n"
" Pre-defined templates: clang, gcc, vs, edit.\n"
" -v, --verbose Output more detailed error information.\n"
" --version Print out version number.\n"
" --xml Write results in xml format to error stream (stderr).\n"

View File

@ -169,7 +169,7 @@ protected:
ErrorPath errorPath;
if (!value) {
errorPath.push_back(ErrorPathItem(errtok,""));
} else if (_settings->verbose) {
} else if (_settings->verbose || _settings->outputFormat == "clang") {
errorPath = value->errorPath;
errorPath.push_back(ErrorPathItem(errtok,""));
} else {

View File

@ -399,7 +399,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
// Save this ErrorMessage in plain text.
// No template is given
if (outputFormat.length() == 0) {
if (outputFormat.empty()) {
std::ostringstream text;
if (!_callStack.empty())
text << callStackToString(_callStack) << ": ";
@ -413,6 +413,30 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
return text.str();
}
else if (outputFormat == "clang") {
std::ostringstream text;
text << _callStack.back().getfile()
<< ':'
<< _callStack.back().line
<< ':'
<< _callStack.back().col
<< ": "
<< Severity::toString(_severity)
<< ": "
<< (verbose ? _verboseMessage : _shortMessage)
<< " [" << _id << ']';
for (std::list<FileLocation>::const_iterator loc = _callStack.begin(); loc != _callStack.end(); ++loc)
text << std::endl
<< loc->getfile()
<< ':'
<< loc->line
<< ':'
<< loc->col
<< ": note: "
<< (loc->getinfo().empty() ? _shortMessage : loc->getinfo());
return text.str();
}
// template is given. Reformat the output according to it
else {
std::string result = outputFormat;