Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate ctu-info from FileSettings for whole project analysis #6499

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
if (!mSettings.quiet && (!mCurrentConfig.empty() || checkCount > 1)) {
std::string fixedpath = Path::simplifyPath(filename);
fixedpath = Path::toNativeSeparators(std::move(fixedpath));
mErrorLogger.reportOut("Checking " + fixedpath + ": " + mCurrentConfig + "...", Color::FgGreen);
mErrorLogger.reportOut("Checking... " + fixedpath + ": " + mCurrentConfig, Color::FgGreen);
}

if (!tokenizer.tokens())
Expand Down Expand Up @@ -1461,7 +1461,7 @@ void CppCheck::executeAddons(const std::vector<std::string>& files, const std::s
}
}

void CppCheck::executeAddonsWholeProgram(const std::list<std::pair<std::string, std::size_t>> &files)
void CppCheck::executeAddonsWholeProgram(const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings)
{
if (mSettings.addons.empty())
return;
Expand All @@ -1472,6 +1472,15 @@ void CppCheck::executeAddonsWholeProgram(const std::list<std::pair<std::string,
ctuInfoFiles.push_back(getCtuInfoFileName(dumpFileName));
}

for (const auto &f: fileSettings) { // --project
const std::string &dumpFileName = getDumpFileName(mSettings, f.filename);

// ignore duplciates
auto it = std::find(ctuInfoFiles.begin(), ctuInfoFiles.end(), getCtuInfoFileName(dumpFileName));
if (it == ctuInfoFiles.end())
ctuInfoFiles.push_back(getCtuInfoFileName(dumpFileName));
}
mErrorLogger.reportOut("Checking... whole program", Color::FgGreen);
try {
executeAddons(ctuInfoFiles, "");
} catch (const InternalError& e) {
Expand Down Expand Up @@ -1758,7 +1767,7 @@ bool CppCheck::analyseWholeProgram()

unsigned int CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings)
{
executeAddonsWholeProgram(files); // TODO: pass FileSettings
executeAddonsWholeProgram(files, fileSettings);
if (buildDir.empty()) {
removeCtuInfoFiles(files, fileSettings);
return mExitCode;
Expand Down
2 changes: 1 addition & 1 deletion lib/cppcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger {
/**
* Execute addons
*/
void executeAddonsWholeProgram(const std::list<std::pair<std::string, std::size_t>> &files);
void executeAddonsWholeProgram(const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings);

#ifdef HAVE_RULES
/**
Expand Down
Loading