ClangTools: Always print stderr output

E.g. clang-tidy prints error messages for invalid config files, but then
continues to run and finishes with exit code zero.

Fixes: QTCREATORBUG-29298
Change-Id: Idbfb7998994ac8197cd863f4bbb2c64ac1bd5525
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2023-09-04 13:14:34 +02:00
parent 705232c737
commit 817d72df7f
2 changed files with 15 additions and 0 deletions

View File

@@ -774,6 +774,9 @@ Group ClangTool::runRecipe(const RunSettings &runSettings,
// TODO: postMessage() instead // TODO: postMessage() instead
m_runControl->postMessage(message, StdErrFormat); m_runControl->postMessage(message, StdErrFormat);
m_runControl->postMessage(output.errorDetails, StdErrFormat); m_runControl->postMessage(output.errorDetails, StdErrFormat);
} else if (!output.errorMessage.isEmpty()) {
m_runControl->postMessage(output.errorMessage, ErrorMessageFormat);
m_runControl->postMessage(output.errorDetails, StdErrFormat);
} else { } else {
qCDebug(LOG) << "Clang tool task finished with success:" qCDebug(LOG) << "Clang tool task finished with success:"
<< output.outputFilePath; << output.outputFilePath;

View File

@@ -165,6 +165,18 @@ GroupItem clangToolTask(const AnalyzeInputData &input,
}; };
const auto onProcessDone = [=](const Process &process) { const auto onProcessDone = [=](const Process &process) {
qCDebug(LOG).noquote() << "Output:\n" << process.cleanedStdOut(); qCDebug(LOG).noquote() << "Output:\n" << process.cleanedStdOut();
// Here we handle only the case of process success with stderr output.
if (!outputHandler)
return;
if (process.result() != ProcessResult::FinishedWithSuccess)
return;
const QString stdErr = process.cleanedStdErr();
if (stdErr.isEmpty())
return;
outputHandler(
{true, input.unit.file, {}, {}, input.tool, Tr::tr("%1 produced stderr output:")
.arg(storage->name), stdErr});
}; };
const auto onProcessError = [=](const Process &process) { const auto onProcessError = [=](const Process &process) {
if (!outputHandler) if (!outputHandler)