Fix #11727 Limit check to selected VS configurations does not work (#5072)

Fix #11727 Limit check to selected VS configurations does not work
This commit is contained in:
Rainer Wiesenfarth 2023-05-23 12:44:03 +02:00 committed by GitHub
parent 956bb3ce8c
commit d1781a8cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 3 deletions

View File

@ -498,7 +498,12 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
if (!mProjectFile->getAnalyzeAllVsConfigs()) {
const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
p.selectOneVsConfig(platform);
std::vector<std::string> configurations;
const QStringList configs = mProjectFile->getVsConfigurations();
std::transform(configs.cbegin(), configs.cend(), std::back_inserter(configurations), [](const QString& e) {
return e.toStdString();
});
p.selectVsConfigurations(platform, configurations);
}
} else {
enableProjectActions(false);

View File

@ -1300,8 +1300,6 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
remove = true;
else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64)
remove = true;
else if (fs.platformType != cppcheck::Platform::Type::Win64 && platform == cppcheck::Platform::Type::Win64)
remove = true;
else if (filenames.find(fs.filename) != filenames.end())
remove = true;
if (remove) {
@ -1313,6 +1311,30 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
}
}
void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector<std::string> &configurations)
{
for (std::list<ImportProject::FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
if (it->cfg.empty()) {
++it;
continue;
}
const ImportProject::FileSettings &fs = *it;
const auto config = fs.cfg.substr(0, fs.cfg.find('|'));
bool remove = false;
if (std::find(configurations.begin(), configurations.end(), config) == configurations.end())
remove = true;
if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform)
remove = true;
else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64)
remove = true;
if (remove) {
it = fileSettings.erase(it);
} else {
++it;
}
}
}
std::list<std::string> ImportProject::getVSConfigs()
{
return std::list<std::string>(mAllVSConfigs.cbegin(), mAllVSConfigs.cend());

View File

@ -91,6 +91,7 @@ public:
ImportProject& operator=(const ImportProject&) = default;
void selectOneVsConfig(cppcheck::Platform::Type platform);
void selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector<std::string> &configurations);
std::list<std::string> getVSConfigs();