Skip to content

Commit d1781a8

Browse files
authored
Fix #11727 Limit check to selected VS configurations does not work (#5072)
Fix #11727 Limit check to selected VS configurations does not work
1 parent 956bb3c commit d1781a8

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

gui/mainwindow.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,12 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
498498

499499
if (!mProjectFile->getAnalyzeAllVsConfigs()) {
500500
const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
501-
p.selectOneVsConfig(platform);
501+
std::vector<std::string> configurations;
502+
const QStringList configs = mProjectFile->getVsConfigurations();
503+
std::transform(configs.cbegin(), configs.cend(), std::back_inserter(configurations), [](const QString& e) {
504+
return e.toStdString();
505+
});
506+
p.selectVsConfigurations(platform, configurations);
502507
}
503508
} else {
504509
enableProjectActions(false);

lib/importproject.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,6 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
13001300
remove = true;
13011301
else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64)
13021302
remove = true;
1303-
else if (fs.platformType != cppcheck::Platform::Type::Win64 && platform == cppcheck::Platform::Type::Win64)
1304-
remove = true;
13051303
else if (filenames.find(fs.filename) != filenames.end())
13061304
remove = true;
13071305
if (remove) {
@@ -1313,6 +1311,30 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
13131311
}
13141312
}
13151313

1314+
void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector<std::string> &configurations)
1315+
{
1316+
for (std::list<ImportProject::FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
1317+
if (it->cfg.empty()) {
1318+
++it;
1319+
continue;
1320+
}
1321+
const ImportProject::FileSettings &fs = *it;
1322+
const auto config = fs.cfg.substr(0, fs.cfg.find('|'));
1323+
bool remove = false;
1324+
if (std::find(configurations.begin(), configurations.end(), config) == configurations.end())
1325+
remove = true;
1326+
if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform)
1327+
remove = true;
1328+
else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64)
1329+
remove = true;
1330+
if (remove) {
1331+
it = fileSettings.erase(it);
1332+
} else {
1333+
++it;
1334+
}
1335+
}
1336+
}
1337+
13161338
std::list<std::string> ImportProject::getVSConfigs()
13171339
{
13181340
return std::list<std::string>(mAllVSConfigs.cbegin(), mAllVSConfigs.cend());

lib/importproject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class CPPCHECKLIB ImportProject {
9191
ImportProject& operator=(const ImportProject&) = default;
9292

9393
void selectOneVsConfig(cppcheck::Platform::Type platform);
94+
void selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector<std::string> &configurations);
9495

9596
std::list<std::string> getVSConfigs();
9697

0 commit comments

Comments
 (0)