From ccc81cc760929af726cd8db14ae0fd51bad52984 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Tue, 5 Nov 2019 11:57:07 +0100 Subject: [PATCH] ClangTools: Clean up handling of output files Do not remove the output files after the runner invocation since they will be removed later anyway due to the use of a temporary dir. For debugging, allow to prevent deleting the temporary dir. This allows easier inspection of the actually generated output files and also enables us to import the diagnostics again without actually running the tools. Change-Id: I39e04d6debc2ffa5c15e836729a4b7c7d8a3798c Reviewed-by: Cristian Adam --- src/plugins/clangtools/clangtoolruncontrol.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/clangtools/clangtoolruncontrol.cpp b/src/plugins/clangtools/clangtoolruncontrol.cpp index 1503961aab8..4d6dc1502b5 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.cpp +++ b/src/plugins/clangtools/clangtoolruncontrol.cpp @@ -207,6 +207,7 @@ ClangToolRunWorker::ClangToolRunWorker(RunControl *runControl, , m_fileInfos(fileInfos) , m_temporaryDir("clangtools-XXXXXX") { + m_temporaryDir.setAutoRemove(qEnvironmentVariable("QTC_CLANG_DONT_DELETE_OUTPUT_FILES") != "1"); setId("ClangTidyClazyRunner"); setSupportsReRunning(false); @@ -387,7 +388,6 @@ void ClangToolRunWorker::onRunnerFinishedWithSuccess(const QString &filePath) filePath, m_projectFiles, &errorMessage); - QFile::remove(outputFilePath); // Clean-up. if (!errorMessage.isEmpty()) { m_filesAnalyzed.remove(filePath); @@ -418,9 +418,6 @@ void ClangToolRunWorker::onRunnerFinishedWithFailure(const QString &errorMessage const QString fileToAnalyze = toolRunner->fileToAnalyze(); const QString outputFilePath = toolRunner->outputFilePath(); - // Even in the error case the log file was created, so clean it up here, too. - QFile::remove(outputFilePath); - m_filesAnalyzed.remove(fileToAnalyze); m_filesNotAnalyzed.insert(fileToAnalyze); m_success = false;