diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 963a9463a..48a5663ad 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -901,7 +901,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha std::list fileNames; for (std::map::const_iterator i = mFiles.begin(); i != mFiles.end(); ++i) fileNames.emplace_back(i->first); - AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.project.fileSettings); + AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, settings.project.fileSettings); } unsigned int returnValue = 0; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 19b544361..88caa4731 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -444,8 +444,9 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons qDebug() << "Checking project file" << mProjectFile->getFilename(); if (!checkSettings.buildDir.empty()) { + checkSettings.loadSummaries(); std::list sourcefiles; - AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, p.fileSettings); + AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, p.fileSettings); } //mThread->SetanalyzeProject(true); @@ -510,10 +511,11 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar qDebug() << "Checking project file" << mProjectFile->getFilename(); if (!checkSettings.buildDir.empty()) { + checkSettings.loadSummaries(); std::list sourcefiles; foreach (QString s, fileNames) sourcefiles.push_back(s.toStdString()); - AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.project.fileSettings); + AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, checkSettings.project.fileSettings); } mThread->setCheckFiles(true); @@ -1175,7 +1177,8 @@ void MainWindow::clearResults() if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) { QDir dir(QFileInfo(mProjectFile->getFilename()).absolutePath() + '/' + mProjectFile->getBuildDir()); for (const QString& f: dir.entryList(QDir::Files)) { - dir.remove(f); + if (!f.endsWith("files.txt") && !QRegExp(".*.s[0-9]+$").exactMatch(f)) + dir.remove(f); } } mUI.mResults->clear(true); diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 1d6af8537..fe5d8a148 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -44,7 +44,7 @@ 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::list &fileSettings) +void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings) { std::map fileCount; @@ -53,6 +53,8 @@ void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std:: for (const std::string &f : sourcefiles) { const std::string afile = getFilename(f); fout << afile << ".a" << (++fileCount[afile]) << "::" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n'; + if (!userDefines.empty()) + fout << afile << ".a" << (++fileCount[afile]) << ":" << userDefines << ":" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n'; } for (const ImportProject::FileSettings &fs : fileSettings) { diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 10d919ae7..cf37d0715 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -50,7 +50,7 @@ class CPPCHECKLIB AnalyzerInformation { public: ~AnalyzerInformation(); - static void writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::list &fileSettings); + static void writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings); /** Close current TU.analyzerinfo file */ void close();