diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index d46a75f88..14fd14bf2 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -108,13 +108,10 @@ void CheckThread::run() if (!mFiles.isEmpty() || mAnalyseWholeProgram) { mAnalyseWholeProgram = false; qDebug() << "Whole program analysis"; - const std::string &buildDir = mCppcheck.settings().buildDir; - if (!buildDir.empty()) { - std::map files2; - for (const QString& file : mFiles) - files2[file.toStdString()] = 0; - mCppcheck.analyseWholeProgram(buildDir, files2); - } + std::map files2; + for (const QString& file : mFiles) + files2[file.toStdString()] = 0; + mCppcheck.analyseWholeProgram(mCppcheck.settings().buildDir, files2); mFiles.clear(); emit done(); return; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 58c4fa719..0cf3635d0 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1759,8 +1759,10 @@ bool CppCheck::analyseWholeProgram() void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map &files) { executeAddonsWholeProgram(files); - if (buildDir.empty()) + if (buildDir.empty()) { + removeCtuInfoFiles(files); return; + } if (mSettings.checks.isEnabled(Checks::unusedFunction)) CheckUnusedFunctions::analyseWholeProgram(this, buildDir); std::list fileInfoList; @@ -1821,3 +1823,14 @@ bool CppCheck::isUnusedFunctionCheckEnabled() const { return (mSettings.jobs == 1 && mSettings.checks.isEnabled(Checks::unusedFunction)); } + +void CppCheck::removeCtuInfoFiles(const std::map &files) +{ + if (mSettings.buildDir.empty()) { + for (const auto& f: files) { + const std::string &dumpFileName = getDumpFileName(mSettings, f.first); + const std::string &ctuInfoFileName = getCtuInfoFileName(dumpFileName); + std::remove(ctuInfoFileName.c_str()); + } + } +} diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 5889b63dd..fe9c8187c 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -145,6 +145,9 @@ public: * and if it's possible at all */ bool isUnusedFunctionCheckEnabled() const; + /** Remove *.ctu-info files */ + void removeCtuInfoFiles(const std::map& files); + private: /** Are there "simple" rules */ bool hasRule(const std::string &tokenlist) const;