From 6858cdedd8a13339fc4875b8de8038d53c670b0d Mon Sep 17 00:00:00 2001 From: firewave Date: Sat, 31 Jan 2026 11:35:32 +0100 Subject: [PATCH] AnalyzerInformation: removed unused files.txt entry when defines are provided by the user the filename is never handed out and thus the file is never created --- cli/cppcheckexecutor.cpp | 2 +- gui/mainwindow.cpp | 4 ++-- lib/analyzerinfo.cpp | 8 +++----- lib/analyzerinfo.h | 4 ++-- test/testanalyzerinformation.cpp | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index a16f76183c0..0d3ee5c1c0d 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -395,7 +395,7 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup std::list fileNames; for (auto i = mFiles.cbegin(); i != mFiles.cend(); ++i) fileNames.emplace_back(i->path()); - AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings); + AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, mFileSettings); stdLogger.readActiveCheckers(); } diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 19270f1605b..6d0a1a8d5ce 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -618,7 +618,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons if (!checkSettings.buildDir.empty()) { checkSettings.loadSummaries(); std::list sourcefiles; - AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, p.fileSettings); + AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, p.fileSettings); } //mThread->SetanalyzeProject(true); @@ -700,7 +700,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar std::transform(fileNames.cbegin(), fileNames.cend(), std::back_inserter(sourcefiles), [](const QString& s) { return s.toStdString(); }); - AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, {}); + AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, {}); } mThread->setCheckFiles(true); diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index c7045252f3d..c90baf57de1 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -48,14 +48,14 @@ static std::string getFilename(const std::string &fullpath) return fullpath.substr(pos1,pos2); } -void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings) +void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::list &fileSettings) { const std::string filesTxt(buildDir + "/files.txt"); std::ofstream fout(filesTxt); - fout << getFilesTxt(sourcefiles, userDefines, fileSettings); + fout << getFilesTxt(sourcefiles, fileSettings); } -std::string AnalyzerInformation::getFilesTxt(const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings) { +std::string AnalyzerInformation::getFilesTxt(const std::list &sourcefiles, const std::list &fileSettings) { std::ostringstream ret; std::map fileCount; @@ -63,8 +63,6 @@ std::string AnalyzerInformation::getFilesTxt(const std::list &sourc for (const std::string &f : sourcefiles) { const std::string afile = getFilename(f); ret << afile << ".a" << (++fileCount[afile]) << sep << sep << sep << Path::simplifyPath(f) << '\n'; - if (!userDefines.empty()) - ret << afile << ".a" << (++fileCount[afile]) << sep << userDefines << sep << sep << Path::simplifyPath(f) << '\n'; } for (const FileSettings &fs : fileSettings) { diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 881076c09f4..89c3a52523a 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -57,7 +57,7 @@ class CPPCHECKLIB AnalyzerInformation { public: ~AnalyzerInformation(); - static void writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings); + static void writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::list &fileSettings); /** Close current TU.analyzerinfo file */ void close(); @@ -80,7 +80,7 @@ class CPPCHECKLIB AnalyzerInformation { static void processFilesTxt(const std::string& buildDir, const std::function& handler); protected: - static std::string getFilesTxt(const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings); + static std::string getFilesTxt(const std::list &sourcefiles, const std::list &fileSettings); static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fileIndex); diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index 13dd721f0a4..01a8dcdeccd 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -66,7 +66,7 @@ class TestAnalyzerInformation : public TestFixture { const char expected[] = "a.a1:::a.c\n" "a.a2::1:a.c\n"; - ASSERT_EQUALS(expected, AnalyzerInformationTest::getFilesTxt({}, "", fileSettings)); + ASSERT_EQUALS(expected, AnalyzerInformationTest::getFilesTxt({}, fileSettings)); } void duplicateFile() const {