Skip to content

Commit dc2049b

Browse files
authored
fixed #14459 - removed unused files.txt entry when defines are provided by the user (#8175)
the filename is never handed out and thus the file is never created
1 parent bbfd62c commit dc2049b

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
396396
std::list<std::string> fileNames;
397397
for (auto i = mFiles.cbegin(); i != mFiles.cend(); ++i)
398398
fileNames.emplace_back(i->path());
399-
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings);
399+
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, mFileSettings);
400400

401401
stdLogger.readActiveCheckers();
402402
}

gui/mainwindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
618618
if (!checkSettings.buildDir.empty()) {
619619
checkSettings.loadSummaries();
620620
std::list<std::string> sourcefiles;
621-
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, p.fileSettings);
621+
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, p.fileSettings);
622622
}
623623

624624
//mThread->SetanalyzeProject(true);
@@ -700,7 +700,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
700700
std::transform(fileNames.cbegin(), fileNames.cend(), std::back_inserter(sourcefiles), [](const QString& s) {
701701
return s.toStdString();
702702
});
703-
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, {});
703+
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, {});
704704
}
705705

706706
mThread->setCheckFiles(true);

lib/analyzerinfo.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,21 @@ static std::string getFilename(const std::string &fullpath)
4848
return fullpath.substr(pos1,pos2);
4949
}
5050

51-
void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<FileSettings> &fileSettings)
51+
void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::list<FileSettings> &fileSettings)
5252
{
5353
const std::string filesTxt(buildDir + "/files.txt");
5454
std::ofstream fout(filesTxt);
55-
fout << getFilesTxt(sourcefiles, userDefines, fileSettings);
55+
fout << getFilesTxt(sourcefiles, fileSettings);
5656
}
5757

58-
std::string AnalyzerInformation::getFilesTxt(const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<FileSettings> &fileSettings) {
58+
std::string AnalyzerInformation::getFilesTxt(const std::list<std::string> &sourcefiles, const std::list<FileSettings> &fileSettings) {
5959
std::ostringstream ret;
6060

6161
std::map<std::string, unsigned int> fileCount;
6262

6363
for (const std::string &f : sourcefiles) {
6464
const std::string afile = getFilename(f);
6565
ret << afile << ".a" << (++fileCount[afile]) << sep << sep << sep << Path::simplifyPath(f) << '\n';
66-
if (!userDefines.empty())
67-
ret << afile << ".a" << (++fileCount[afile]) << sep << userDefines << sep << sep << Path::simplifyPath(f) << '\n';
6866
}
6967

7068
for (const FileSettings &fs : fileSettings) {

lib/analyzerinfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CPPCHECKLIB AnalyzerInformation {
5757
public:
5858
~AnalyzerInformation();
5959

60-
static void writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<FileSettings> &fileSettings);
60+
static void writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::list<FileSettings> &fileSettings);
6161

6262
/** Close current TU.analyzerinfo file */
6363
void close();
@@ -80,7 +80,7 @@ class CPPCHECKLIB AnalyzerInformation {
8080
static void processFilesTxt(const std::string& buildDir, const std::function<void(const char* checkattr, const tinyxml2::XMLElement* e, const Info& filesTxtInfo)>& handler);
8181

8282
protected:
83-
static std::string getFilesTxt(const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<FileSettings> &fileSettings);
83+
static std::string getFilesTxt(const std::list<std::string> &sourcefiles, const std::list<FileSettings> &fileSettings);
8484

8585
static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fileIndex);
8686

test/testanalyzerinformation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class TestAnalyzerInformation : public TestFixture {
6666
const char expected[] = "a.a1:::a.c\n"
6767
"a.a2::1:a.c\n";
6868

69-
ASSERT_EQUALS(expected, AnalyzerInformationTest::getFilesTxt({}, "", fileSettings));
69+
ASSERT_EQUALS(expected, AnalyzerInformationTest::getFilesTxt({}, fileSettings));
7070
}
7171

7272
void duplicateFile() const {

0 commit comments

Comments
 (0)