analyzing one vs config (first debug config that matches platform)

This commit is contained in:
Daniel Marjamäki 2019-04-13 20:01:40 +02:00
parent d3e7d09f5c
commit a0dd853642
5 changed files with 59 additions and 44 deletions

View File

@ -556,8 +556,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
mSettings->platform(Settings::Unix64); mSettings->platform(Settings::Unix64);
else if (platform == "native") else if (platform == "native")
mSettings->platform(Settings::Native); mSettings->platform(Settings::Native);
else if (platform == "unspecified") else if (platform == "unspecified" || platform == "Unspecified" || platform == "")
mSettings->platform(Settings::Unspecified); ;
else if (!mSettings->loadPlatformFile(argv[0], platform)) { else if (!mSettings->loadPlatformFile(argv[0], platform)) {
std::string message("cppcheck: error: unrecognized platform: \""); std::string message("cppcheck: error: unrecognized platform: \"");
message += platform; message += platform;
@ -570,6 +570,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
projType = mSettings->project.import(mSettings->project.guiProject.projectFile, mSettings); projType = mSettings->project.import(mSettings->project.guiProject.projectFile, mSettings);
} }
if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) { if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {
if (mSettings->project.guiProject.analyzeAllVsConfigs == "false")
mSettings->project.selectOneVsConfig(mSettings->platformType);
if (!CppCheckExecutor::tryLoadLibrary(mSettings->library, argv[0], "windows.cfg")) { if (!CppCheckExecutor::tryLoadLibrary(mSettings->library, argv[0], "windows.cfg")) {
// This shouldn't happen normally. // This shouldn't happen normally.
printMessage("cppcheck: Failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install."); printMessage("cppcheck: Failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install.");

View File

@ -877,6 +877,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
std::size_t processedsize = 0; std::size_t processedsize = 0;
unsigned int c = 0; unsigned int c = 0;
if (settings.project.fileSettings.empty()) {
for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
if (!_settings->library.markupFile(i->first) if (!_settings->library.markupFile(i->first)
|| !_settings->library.processMarkupAfterCode(i->first)) { || !_settings->library.processMarkupAfterCode(i->first)) {
@ -887,6 +888,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
c++; c++;
} }
} }
} else {
// filesettings // filesettings
c = 0; c = 0;
@ -896,6 +898,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
if (!settings.quiet) if (!settings.quiet)
reportStatus(c, settings.project.fileSettings.size(), c, settings.project.fileSettings.size()); reportStatus(c, settings.project.fileSettings.size(), c, settings.project.fileSettings.size());
} }
}
// second loop to parse all markup files which may not work until all // second loop to parse all markup files which may not work until all
// c/cpp files have been parsed and checked // c/cpp files have been parsed and checked

View File

@ -405,32 +405,8 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
p.ignorePaths(v); p.ignorePaths(v);
if (!mProjectFile->getAnalyzeAllVsConfigs()) { if (!mProjectFile->getAnalyzeAllVsConfigs()) {
std::set<std::string> filenames;
Settings::PlatformType platform = (Settings::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt(); Settings::PlatformType platform = (Settings::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
for (std::list<ImportProject::FileSettings>::iterator it = p.fileSettings.begin(); it != p.fileSettings.end();) { p.selectOneVsConfig(platform);
if (it->cfg.empty()) {
++it;
continue;
}
const ImportProject::FileSettings &fs = *it;
bool remove = false;
if (fs.cfg.compare(0,5,"Debug") != 0)
remove = true;
if (platform == Settings::Win64 && fs.platformType != platform)
remove = true;
else if ((platform == Settings::Win32A || platform == Settings::Win32W) && fs.platformType == Settings::Win64)
remove = true;
else if (fs.platformType != Settings::Win64 && platform == Settings::Win64)
remove = true;
else if (filenames.find(fs.filename) != filenames.end())
remove = true;
if (remove) {
it = p.fileSettings.erase(it);
} else {
filenames.insert(fs.filename);
++it;
}
}
} }
} else { } else {
enableProjectActions(false); enableProjectActions(false);

View File

@ -1003,6 +1003,8 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
std::list<std::string> suppressions; std::list<std::string> suppressions;
Settings temp; Settings temp;
guiProject.analyzeAllVsConfigs = false;
for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
if (strcmp(node->Name(), RootPathName) == 0 && node->Attribute(RootPathNameAttrib)) if (strcmp(node->Name(), RootPathName) == 0 && node->Attribute(RootPathNameAttrib))
temp.basePaths.push_back(joinRelativePath(path, node->Attribute(RootPathNameAttrib))); temp.basePaths.push_back(joinRelativePath(path, node->Attribute(RootPathNameAttrib)));
@ -1030,7 +1032,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
else if (strcmp(node->Name(), PlatformElementName) == 0) else if (strcmp(node->Name(), PlatformElementName) == 0)
guiProject.platform = node->GetText(); guiProject.platform = node->GetText();
else if (strcmp(node->Name(), AnalyzeAllVsConfigsElementName) == 0) else if (strcmp(node->Name(), AnalyzeAllVsConfigsElementName) == 0)
; // FIXME: Write some warning guiProject.analyzeAllVsConfigs = node->GetText();
else if (strcmp(node->Name(), AddonsElementName) == 0) else if (strcmp(node->Name(), AddonsElementName) == 0)
temp.addons = readXmlStringList(node, "", AddonElementName, nullptr); temp.addons = readXmlStringList(node, "", AddonElementName, nullptr);
else if (strcmp(node->Name(), TagsElementName) == 0) else if (strcmp(node->Name(), TagsElementName) == 0)
@ -1061,3 +1063,32 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
settings->maxCtuDepth = temp.maxCtuDepth; settings->maxCtuDepth = temp.maxCtuDepth;
return true; return true;
} }
void ImportProject::selectOneVsConfig(Settings::PlatformType platform)
{
std::set<std::string> filenames;
for (std::list<ImportProject::FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
if (it->cfg.empty()) {
++it;
continue;
}
const ImportProject::FileSettings &fs = *it;
bool remove = false;
if (fs.cfg.compare(0,5,"Debug") != 0)
remove = true;
if (platform == Settings::Win64 && fs.platformType != platform)
remove = true;
else if ((platform == Settings::Win32A || platform == Settings::Win32W) && fs.platformType == Settings::Win64)
remove = true;
else if (fs.platformType != Settings::Win64 && platform == Settings::Win64)
remove = true;
else if (filenames.find(fs.filename) != filenames.end())
remove = true;
if (remove) {
it = fileSettings.erase(it);
} else {
filenames.insert(fs.filename);
++it;
}
}
}

View File

@ -82,8 +82,11 @@ public:
}; };
std::list<FileSettings> fileSettings; std::list<FileSettings> fileSettings;
void selectOneVsConfig(cppcheck::Platform::PlatformType platform);
// Cppcheck GUI output // Cppcheck GUI output
struct { struct {
std::string analyzeAllVsConfigs;
std::vector<std::string> pathNames; std::vector<std::string> pathNames;
std::list<std::string> libraries; std::list<std::string> libraries;
std::list<std::string> excludedPaths; std::list<std::string> excludedPaths;