From 5efb2e3be0e8455e2896f0c01b8436af7bc28800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 1 Jun 2017 13:13:23 +0200 Subject: [PATCH] Visual Studio: Skip unknown platforms (ARM, ARM64) --- lib/importproject.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 9753f5684..03c61f3ec 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -255,14 +255,22 @@ namespace { if (e->GetText()) { if (std::strcmp(e->Name(),"Configuration")==0) configuration = e->GetText(); - else if (std::strcmp(e->Name(),"Platform")==0) - platform = e->GetText(); + else if (std::strcmp(e->Name(),"Platform")==0) { + platformStr = e->GetText(); + if (platformStr == "Win32") + platform = Win32; + else if (platformStr == "x64") + platform = x64; + else + platform = Unknown; + } } } } std::string name; std::string configuration; - std::string platform; + enum { Win32, x64, Unknown } platform; + std::string platformStr; }; struct ItemDefinitionGroup { @@ -300,7 +308,7 @@ namespace { return true; std::string c = '(' + condition + ");"; replaceAll(c, "$(Configuration)", p.configuration); - replaceAll(c, "$(Platform)", p.platform); + replaceAll(c, "$(Platform)", p.platformStr); // TODO : Better evaluation Settings s; @@ -423,8 +431,11 @@ void ImportProject::importVcxproj(const std::string &filename, std::mapName(), "ItemGroup") == 0) { if (node->Attribute("Label") && std::strcmp(node->Attribute("Label"), "ProjectConfigurations") == 0) { for (const tinyxml2::XMLElement *cfg = node->FirstChildElement(); cfg; cfg = cfg->NextSiblingElement()) { - if (std::strcmp(cfg->Name(), "ProjectConfiguration") == 0) - projectConfigurationList.push_back(ProjectConfiguration(cfg)); + if (std::strcmp(cfg->Name(), "ProjectConfiguration") == 0) { + ProjectConfiguration p(cfg); + if (p.platform != ProjectConfiguration::Unknown) + projectConfigurationList.push_back(ProjectConfiguration(cfg)); + } } } else { for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { @@ -455,9 +466,9 @@ void ImportProject::importVcxproj(const std::string &filename, std::mapname; fs.defines = "_MSC_VER=1900;_WIN32=1"; - if (p->platform == "Win32") + if (p->platform == ProjectConfiguration::Win32) fs.platformType = cppcheck::Platform::Win32W; - else if (p->platform == "x64") { + else if (p->platform == ProjectConfiguration::x64) { fs.platformType = cppcheck::Platform::Win64; fs.defines += ";_WIN64=1"; }