From cddfc16068d3caca8eed26759e90b3f6a82bdf1d Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 19 Apr 2024 07:29:26 +0200 Subject: [PATCH 01/34] Rebasing --- lib/importproject.cpp | 149 ++++++++++++++++++++++++++++++++++++++++++ lib/importproject.h | 1 + 2 files changed, 150 insertions(+) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 336e25744c8..437678b4347 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -450,6 +450,29 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const while (std::getline(istr,line)) { if (!startsWith(line,"Project(")) continue; + + // NOTE(Felix): Custom code for vcxitems + { + const std::string::size_type pos = line.find(".vcxitems"); + if (pos != std::string::npos) + { + const std::string::size_type pos1 = line.rfind('\"', pos); + if (pos1 != std::string::npos) + { + std::string vcxitems(line.substr(pos1 + 1, pos - pos1 + 8)); + vcxitems = Path::toNativeSeparators(std::move(vcxitems)); + if (!Path::isAbsolute(vcxitems)) + vcxitems = path + vcxitems; + vcxitems = Path::fromNativeSeparators(std::move(vcxitems)); + if (!importVcxitems(vcxitems, variables, emptyString, fileFilters)) { + printError("failed to load '" + vcxitems + "' from Visual Studio solution"); + return false; + } + found = true; + } + } + } + const std::string::size_type pos = line.find(".vcxproj"); if (pos == std::string::npos) continue; @@ -816,6 +839,132 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& variables, const std::string& additionalIncludeDirectories, const std::vector& fileFilters) +{ + variables["ProjectDir"] = Path::simplifyPath(Path::getPathFromFilename(filename)); + + std::list projectConfigurationList; + std::list compileList; + std::list itemDefinitionGroupList; + std::string includePath; + + bool useOfMfc = false; + + tinyxml2::XMLDocument doc; + const tinyxml2::XMLError error = doc.LoadFile(filename.c_str()); + if (error != tinyxml2::XML_SUCCESS) { + printError(std::string("Visual Studio project file is not a valid XML - ") + tinyxml2::XMLDocument::ErrorIDToName(error)); + return false; + } + const tinyxml2::XMLElement* const rootnode = doc.FirstChildElement(); + if (rootnode == nullptr) { + printError("Visual Studio project file has no XML root node"); + return false; + } + for (const tinyxml2::XMLElement* node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { + if (std::strcmp(node->Name(), "ItemGroup") == 0) { + const char* labelAttribute = node->Attribute("Label"); + if (labelAttribute && std::strcmp(labelAttribute, "ProjectConfigurations") == 0) { + for (const tinyxml2::XMLElement* cfg = node->FirstChildElement(); cfg; cfg = cfg->NextSiblingElement()) { + if (std::strcmp(cfg->Name(), "ProjectConfiguration") == 0) { + const ProjectConfiguration p(cfg); + if (p.platform != ProjectConfiguration::Unknown) { + projectConfigurationList.emplace_back(cfg); + mAllVSConfigs.insert(p.configuration); + } + } + } + } + else { + for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { + if (std::strcmp(e->Name(), "ClCompile") == 0) { + const char* include = e->Attribute("Include"); + if (include && Path::acceptFile(include)) + compileList.emplace_back(include); + } + } + } + } + else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { + itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories); + } + else if (std::strcmp(node->Name(), "PropertyGroup") == 0) { + importPropertyGroup(node, variables, includePath, &useOfMfc); + } + else if (std::strcmp(node->Name(), "ImportGroup") == 0) { + const char* labelAttribute = node->Attribute("Label"); + if (labelAttribute && std::strcmp(labelAttribute, "PropertySheets") == 0) { + for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { + if (std::strcmp(e->Name(), "Import") == 0) { + const char* projectAttribute = e->Attribute("Project"); + if (projectAttribute) + loadVisualStudioProperties(projectAttribute, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList); + } + } + } + } + } + // # TODO: support signedness of char via /J (and potential XML option for it)? + // we can only set it globally but in this context it needs to be treated per file + for (const std::string& c : compileList) { + std::string cfilename = Path::simplifyPath(Path::isAbsolute(c) ? c : Path::getPathFromFilename(filename) + c); + + // Remove "msbuild this file directory" + { + std::string toRemove("$(MSBuildThisFileDirectory)"); + size_t pos = cfilename.find(toRemove); + while (pos != std::string::npos) + { + auto test = cfilename.erase(pos, toRemove.length()); + pos = cfilename.find(toRemove); + } + } + + if (!fileFilters.empty() && !matchglobs(fileFilters, cfilename)) + continue; + + // TODO(Felix): make this robust by iterating over the projects, + // checking retrieving their configurations and add them + // if this the shared item project is referenced + + // Assuming x64 configuration + std::string configs[] = { "Debug|x64", "Release|x64", }; + for (auto& c : configs) + { + FileSettings fs; + fs.filename = cfilename; + fs.cfg = c; + // TODO: detect actual MSC version + fs.msc = true; + fs.useMfc = useOfMfc; + fs.defines = "_WIN32=1;_WIN64=1"; + fs.platformType = cppcheck::Platform::Type::Win64; + std::string additionalIncludePaths; + for (const ItemDefinitionGroup& i : itemDefinitionGroupList) { + fs.standard = Standards::getCPP(i.cppstd); + fs.defines += ';' + i.preprocessorDefinitions; + if (i.enhancedInstructionSet == "StreamingSIMDExtensions") + fs.defines += ";__SSE__"; + else if (i.enhancedInstructionSet == "StreamingSIMDExtensions2") + fs.defines += ";__SSE2__"; + else if (i.enhancedInstructionSet == "AdvancedVectorExtensions") + fs.defines += ";__AVX__"; + else if (i.enhancedInstructionSet == "AdvancedVectorExtensions2") + fs.defines += ";__AVX2__"; + else if (i.enhancedInstructionSet == "AdvancedVectorExtensions512") + fs.defines += ";__AVX512__"; + additionalIncludePaths += ';' + i.additionalIncludePaths; + } + fs.setDefines(fs.defines); + fs.setIncludePaths(Path::getPathFromFilename(filename), toStringList(includePath + ';' + additionalIncludePaths), variables); + fileSettings.push_back(std::move(fs)); + } + } + + return true; +} + bool ImportProject::importBcb6Prj(const std::string &projectFilename) { tinyxml2::XMLDocument doc; diff --git a/lib/importproject.h b/lib/importproject.h index 7382b56eb8d..fe67034c19c 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -103,6 +103,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { private: bool importSln(std::istream &istr, const std::string &path, const std::vector &fileFilters); bool importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters); + bool importVcxitems(const std::string& filename, std::map& variables, const std::string& additionalIncludeDirectories, const std::vector& fileFilters); bool importBcb6Prj(const std::string &projectFilename); static void printError(const std::string &message); From 51d8713a671f3e3661eb1eb192201f72ca987b5f Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 27 Mar 2024 08:06:08 +0100 Subject: [PATCH 02/34] This change is crucial when $(SolutionDir) = "" and includePath is $(SolutionDir)/libs. Without this change, the include path will be "/libs", which is not the same as "./libs" or "libs". --- lib/importproject.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 437678b4347..06206211de7 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -187,6 +187,8 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings mPath = Path::getPathFromFilename(Path::fromNativeSeparators(filename)); if (!mPath.empty() && !endsWith(mPath,'/')) mPath += '/'; + if (mPath.empty()) + mPath = std::string("./"); const std::vector fileFilters = settings ? settings->fileFilters : std::vector(); From d4fb38a7b6c5222166e838fb43a692fc9cb4fafe Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 19 Apr 2024 07:36:01 +0200 Subject: [PATCH 03/34] Rebasing... --- lib/importproject.cpp | 208 +++++++++++++++++++++++++++++++++++------- lib/importproject.h | 11 ++- 2 files changed, 186 insertions(+), 33 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 06206211de7..2b9e9a241ae 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -192,6 +192,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings const std::vector fileFilters = settings ? settings->fileFilters : std::vector(); + std::vector sharedItemsProjects{}; if (endsWith(filename, ".json")) { if (importCompileCommands(fin)) { @@ -205,7 +206,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings } } else if (endsWith(filename, ".vcxproj")) { std::map variables; - if (importVcxproj(filename, variables, emptyString, fileFilters)) { + if (importVcxproj(filename, variables, emptyString, fileFilters, sharedItemsProjects)) { setRelativePaths(filename); return ImportProject::Type::VS_VCXPROJ; } @@ -448,7 +449,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const variables["SolutionDir"] = path; bool found = false; - + std::vector sharedItemsProjects{}; while (std::getline(istr,line)) { if (!startsWith(line,"Project(")) continue; @@ -841,8 +842,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& variables, const std::string& additionalIncludeDirectories, const std::vector& fileFilters) +bool ImportProject::importVcxproj(const std::string& filename, std::map& variables, const std::string& additionalIncludeDirectories, const std::vector& fileFilters, std::vector& cache) { variables["ProjectDir"] = Path::simplifyPath(Path::getPathFromFilename(filename)); @@ -850,6 +850,7 @@ bool ImportProject::importVcxitems(const std::string& filename, std::map compileList; std::list itemDefinitionGroupList; std::string includePath; + std::vector sharedItemsProjects; bool useOfMfc = false; @@ -905,45 +906,57 @@ bool ImportProject::importVcxitems(const std::string& filename, std::mapFirstChildElement(); e; e = e->NextSiblingElement()) { + if (std::strcmp(e->Name(), "Import") == 0) { + const char* projectAttribute = e->Attribute("Project"); + if (projectAttribute) + { + std::string pathToSharedItemsFile(projectAttribute); + if (!simplifyPathWithVariables(pathToSharedItemsFile, variables)) { + printError("Could not simplify path to referenced shared items project"); + exit(-1); + } + sharedItemsProjects.emplace_back(importVcxitems(pathToSharedItemsFile, fileFilters, cache)); + } + } + } } } + } + // Project files + for (const std::string& c : compileList) { + const std::string cfilename = Path::simplifyPath(Path::isAbsolute(c) ? c : Path::getPathFromFilename(filename) + c); if (!fileFilters.empty() && !matchglobs(fileFilters, cfilename)) continue; - // TODO(Felix): make this robust by iterating over the projects, - // checking retrieving their configurations and add them - // if this the shared item project is referenced - - // Assuming x64 configuration - std::string configs[] = { "Debug|x64", "Release|x64", }; - for (auto& c : configs) - { + for (const ProjectConfiguration& p : projectConfigurationList) { + + if (!guiProject.checkVsConfigs.empty()) { + const bool doChecking = std::any_of(guiProject.checkVsConfigs.cbegin(), guiProject.checkVsConfigs.cend(), [&](const std::string& c) { + return c == p.configuration; + }); + if (!doChecking) + continue; + } + FileSettings fs; fs.filename = cfilename; - fs.cfg = c; - // TODO: detect actual MSC version + fs.cfg = p.name; fs.msc = true; fs.useMfc = useOfMfc; - fs.defines = "_WIN32=1;_WIN64=1"; - fs.platformType = cppcheck::Platform::Type::Win64; + fs.defines = "_WIN32=1"; + if (p.platform == ProjectConfiguration::Win32) + fs.platformType = cppcheck::Platform::Type::Win32W; + else if (p.platform == ProjectConfiguration::x64) { + fs.platformType = cppcheck::Platform::Type::Win64; + fs.defines += ";_WIN64=1"; + } std::string additionalIncludePaths; for (const ItemDefinitionGroup& i : itemDefinitionGroupList) { + if (!i.conditionIsTrue(p)) + continue; fs.standard = Standards::getCPP(i.cppstd); fs.defines += ';' + i.preprocessorDefinitions; if (i.enhancedInstructionSet == "StreamingSIMDExtensions") @@ -964,9 +977,142 @@ bool ImportProject::importVcxitems(const std::string& filename, std::map& fileFilters, std::vector &cache) +{ + for (const auto& entry : cache) + { + if (filename == entry.pathToProjectFile) + { + return entry; + } + } + + std::string projectDir = Path::simplifyPath(Path::getPathFromFilename(filename)); + if (projectDir.empty()) + { + projectDir = std::string("./"); + } + + SharedItemsProject result{}; + result.pathToProjectFile = filename; + + tinyxml2::XMLDocument doc; + const tinyxml2::XMLError error = doc.LoadFile(filename.c_str()); + if (error != tinyxml2::XML_SUCCESS) { + printError(std::string("Visual Studio project file is not a valid XML - ") + tinyxml2::XMLDocument::ErrorIDToName(error)); + exit(-1); + } + const tinyxml2::XMLElement* const rootnode = doc.FirstChildElement(); + if (rootnode == nullptr) { + printError("Visual Studio project file has no XML root node"); + exit(-1); + } + for (const tinyxml2::XMLElement* node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { + if (std::strcmp(node->Name(), "ItemGroup") == 0) { + const char* labelAttribute = node->Attribute("Label"); + for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { + if (std::strcmp(e->Name(), "ClCompile") == 0) { + const char* include = e->Attribute("Include"); + if (include && Path::acceptFile(include)) { + std::string filename = stringReplace(include, "$(MSBuildThisFileDirectory)", projectDir); + + // Don't include file if it matches the filter + if (!fileFilters.empty() && !matchglobs(fileFilters, filename)) + continue; + + result.sourceFiles.emplace_back(filename); + } else { + printError("Could not find shared items source file"); + exit(-1); + } + } + } + } + else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { + ItemDefinitionGroup temp(node, ""); + for (const auto& includePath : toStringList(temp.additionalIncludePaths)) { + if (includePath == std::string("%(AdditionalIncludeDirectories)")) + continue; + + result.includePaths.emplace_back(stringReplace(includePath, "$(MSBuildThisFileDirectory)", projectDir)); + } + } + } + + cache.emplace_back(result); + return result; +} + bool ImportProject::importBcb6Prj(const std::string &projectFilename) { tinyxml2::XMLDocument doc; diff --git a/lib/importproject.h b/lib/importproject.h index fe67034c19c..7c6efba9a79 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -100,10 +100,17 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { bool importCompileCommands(std::istream &istr); bool importCppcheckGuiProject(std::istream &istr, Settings *settings); virtual bool sourceFileExists(const std::string &file); + private: + struct SharedItemsProject { + std::string pathToProjectFile; + std::vector includePaths; + std::vector sourceFiles; + }; + bool importSln(std::istream &istr, const std::string &path, const std::vector &fileFilters); - bool importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters); - bool importVcxitems(const std::string& filename, std::map& variables, const std::string& additionalIncludeDirectories, const std::vector& fileFilters); + static SharedItemsProject importVcxitems(const std::string& filename, const std::vector& fileFilters, std::vector &cache); + bool importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters, std::vector &cache); bool importBcb6Prj(const std::string &projectFilename); static void printError(const std::string &message); From 32cfcd17fd49e19fb75d8bff86016c1a3b669120 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 2 Apr 2024 08:34:53 +0200 Subject: [PATCH 04/34] Removing duplicate code, storing source files relative to the shared items project file and making the project redirect paths accordingly --- lib/importproject.cpp | 105 +++++++++++++----------------------------- 1 file changed, 33 insertions(+), 72 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 2b9e9a241ae..3e61b553d23 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -883,8 +883,10 @@ bool ImportProject::importVcxproj(const std::string& filename, std::mapFirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "ClCompile") == 0) { const char* include = e->Attribute("Include"); - if (include && Path::acceptFile(include)) - compileList.emplace_back(include); + if (include && Path::acceptFile(include)) { + std::string toInclude = Path::simplifyPath(Path::isAbsolute(include) ? include : Path::getPathFromFilename(filename) + include); + compileList.emplace_back(toInclude); + } } } } @@ -912,7 +914,14 @@ bool ImportProject::importVcxproj(const std::string& filename, std::mapAttribute("Project"); if (projectAttribute) { - std::string pathToSharedItemsFile(projectAttribute); + // Path to shared items project is relative to current project directory, + // unless the string starts with $(SolutionDir) + std::string pathToSharedItemsFile; + if (std::string(projectAttribute).rfind("$(SolutionDir)", 0) == 0) { + pathToSharedItemsFile = std::string(projectAttribute); + } else { + pathToSharedItemsFile = variables["ProjectDir"] + std::string(projectAttribute); + } if (!simplifyPathWithVariables(pathToSharedItemsFile, variables)) { printError("Could not simplify path to referenced shared items project"); exit(-1); @@ -925,9 +934,21 @@ bool ImportProject::importVcxproj(const std::string& filename, std::map sharedItemsIncludePaths{}; + for (const auto& sharedProject : sharedItemsProjects) { + for (const auto& file : sharedProject.sourceFiles) { + std::string pathToFile = Path::simplifyPath(Path::getPathFromFilename(sharedProject.pathToProjectFile) + file); + compileList.emplace_back(std::move(pathToFile)); + } + for (const auto& p : sharedProject.includePaths) { + std::string path = Path::simplifyPath(Path::getPathFromFilename(sharedProject.pathToProjectFile) + p); + sharedItemsIncludePaths.emplace_back(std::move(path)); + } + } + // Project files - for (const std::string& c : compileList) { - const std::string cfilename = Path::simplifyPath(Path::isAbsolute(c) ? c : Path::getPathFromFilename(filename) + c); + for (const std::string& cfilename : compileList) { if (!fileFilters.empty() && !matchglobs(fileFilters, cfilename)) continue; @@ -973,63 +994,10 @@ bool ImportProject::importVcxproj(const std::string& filename, std::mapFirstChildElement(); node; node = node->NextSiblingElement()) { if (std::strcmp(node->Name(), "ItemGroup") == 0) { - const char* labelAttribute = node->Attribute("Label"); for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "ClCompile") == 0) { const char* include = e->Attribute("Include"); if (include && Path::acceptFile(include)) { - std::string filename = stringReplace(include, "$(MSBuildThisFileDirectory)", projectDir); + std::string file = stringReplace(include, "$(MSBuildThisFileDirectory)", "./"); // Don't include file if it matches the filter - if (!fileFilters.empty() && !matchglobs(fileFilters, filename)) + if (!fileFilters.empty() && !matchglobs(fileFilters, file)) continue; - result.sourceFiles.emplace_back(filename); + result.sourceFiles.emplace_back(file); } else { printError("Could not find shared items source file"); exit(-1); @@ -1104,7 +1065,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin if (includePath == std::string("%(AdditionalIncludeDirectories)")) continue; - result.includePaths.emplace_back(stringReplace(includePath, "$(MSBuildThisFileDirectory)", projectDir)); + result.includePaths.emplace_back(stringReplace(includePath, "$(MSBuildThisFileDirectory)", "./")); } } } From e7d69db26b872090e111a2b3711c032681491e54 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 12 Apr 2024 08:01:43 +0200 Subject: [PATCH 05/34] Proper error reporting instead of "exit(-1)" call --- lib/importproject.cpp | 15 +++++++++++---- lib/importproject.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 3e61b553d23..ea0d4f19c64 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -926,7 +926,13 @@ bool ImportProject::importVcxproj(const std::string& filename, std::mapFirstChildElement(); node; node = node->NextSiblingElement()) { if (std::strcmp(node->Name(), "ItemGroup") == 0) { @@ -1054,7 +1060,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin result.sourceFiles.emplace_back(file); } else { printError("Could not find shared items source file"); - exit(-1); + return result; } } } @@ -1070,6 +1076,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin } } + result.successFull = true; cache.emplace_back(result); return result; } diff --git a/lib/importproject.h b/lib/importproject.h index 7c6efba9a79..7db2dcf05a0 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -103,6 +103,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { private: struct SharedItemsProject { + bool successFull; std::string pathToProjectFile; std::vector includePaths; std::vector sourceFiles; From 36a0f3eefb19b963d2f89be564c58db3112be845 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 30 Apr 2024 13:14:17 +0200 Subject: [PATCH 06/34] Rebasing... --- lib/importproject.cpp | 135 +++--------------------------------------- lib/importproject.h | 2 +- 2 files changed, 8 insertions(+), 129 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index ea0d4f19c64..e3365766e5d 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -724,125 +724,7 @@ static void loadVisualStudioProperties(const std::string &props, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters) -{ - variables["ProjectDir"] = Path::simplifyPath(Path::getPathFromFilename(filename)); - - std::list projectConfigurationList; - std::list compileList; - std::list itemDefinitionGroupList; - std::string includePath; - - bool useOfMfc = false; - - tinyxml2::XMLDocument doc; - const tinyxml2::XMLError error = doc.LoadFile(filename.c_str()); - if (error != tinyxml2::XML_SUCCESS) { - printError(std::string("Visual Studio project file is not a valid XML - ") + tinyxml2::XMLDocument::ErrorIDToName(error)); - return false; - } - const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement(); - if (rootnode == nullptr) { - printError("Visual Studio project file has no XML root node"); - return false; - } - for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { - if (std::strcmp(node->Name(), "ItemGroup") == 0) { - const char *labelAttribute = node->Attribute("Label"); - if (labelAttribute && std::strcmp(labelAttribute, "ProjectConfigurations") == 0) { - for (const tinyxml2::XMLElement *cfg = node->FirstChildElement(); cfg; cfg = cfg->NextSiblingElement()) { - if (std::strcmp(cfg->Name(), "ProjectConfiguration") == 0) { - const ProjectConfiguration p(cfg); - if (p.platform != ProjectConfiguration::Unknown) { - projectConfigurationList.emplace_back(cfg); - mAllVSConfigs.insert(p.configuration); - } - } - } - } else { - for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { - if (std::strcmp(e->Name(), "ClCompile") == 0) { - const char *include = e->Attribute("Include"); - if (include && Path::acceptFile(include)) - compileList.emplace_back(include); - } - } - } - } else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { - itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories); - } else if (std::strcmp(node->Name(), "PropertyGroup") == 0) { - importPropertyGroup(node, variables, includePath, &useOfMfc); - } else if (std::strcmp(node->Name(), "ImportGroup") == 0) { - const char *labelAttribute = node->Attribute("Label"); - if (labelAttribute && std::strcmp(labelAttribute, "PropertySheets") == 0) { - for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { - if (std::strcmp(e->Name(), "Import") == 0) { - const char *projectAttribute = e->Attribute("Project"); - if (projectAttribute) - loadVisualStudioProperties(projectAttribute, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList); - } - } - } - } - } - // # TODO: support signedness of char via /J (and potential XML option for it)? - // we can only set it globally but in this context it needs to be treated per file - - for (const std::string &c : compileList) { - const std::string cfilename = Path::simplifyPath(Path::isAbsolute(c) ? c : Path::getPathFromFilename(filename) + c); - if (!fileFilters.empty() && !matchglobs(fileFilters, cfilename)) - continue; - - for (const ProjectConfiguration &p : projectConfigurationList) { - - if (!guiProject.checkVsConfigs.empty()) { - const bool doChecking = std::any_of(guiProject.checkVsConfigs.cbegin(), guiProject.checkVsConfigs.cend(), [&](const std::string& c) { - return c == p.configuration; - }); - if (!doChecking) - continue; - } - - FileSettings fs{cfilename}; - fs.cfg = p.name; - // TODO: detect actual MSC version - fs.msc = true; - fs.useMfc = useOfMfc; - fs.defines = "_WIN32=1"; - if (p.platform == ProjectConfiguration::Win32) - fs.platformType = Platform::Type::Win32W; - else if (p.platform == ProjectConfiguration::x64) { - fs.platformType = Platform::Type::Win64; - fs.defines += ";_WIN64=1"; - } - std::string additionalIncludePaths; - for (const ItemDefinitionGroup &i : itemDefinitionGroupList) { - if (!i.conditionIsTrue(p)) - continue; - fs.standard = Standards::getCPP(i.cppstd); - fs.defines += ';' + i.preprocessorDefinitions; - if (i.enhancedInstructionSet == "StreamingSIMDExtensions") - fs.defines += ";__SSE__"; - else if (i.enhancedInstructionSet == "StreamingSIMDExtensions2") - fs.defines += ";__SSE2__"; - else if (i.enhancedInstructionSet == "AdvancedVectorExtensions") - fs.defines += ";__AVX__"; - else if (i.enhancedInstructionSet == "AdvancedVectorExtensions2") - fs.defines += ";__AVX2__"; - else if (i.enhancedInstructionSet == "AdvancedVectorExtensions512") - fs.defines += ";__AVX512__"; - additionalIncludePaths += ';' + i.additionalIncludePaths; - } - fsSetDefines(fs, fs.defines); - fsSetIncludePaths(fs, Path::getPathFromFilename(filename), toStringList(includePath + ';' + additionalIncludePaths), variables); - fileSettings.push_back(std::move(fs)); - } - } - - return true; -} - -bool ImportProject::importVcxproj(const std::string& filename, std::map& variables, const std::string& additionalIncludeDirectories, const std::vector& fileFilters, std::vector& cache) +bool ImportProject::importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters, std::vector &cache) { variables["ProjectDir"] = Path::simplifyPath(Path::getPathFromFilename(filename)); @@ -890,19 +772,16 @@ bool ImportProject::importVcxproj(const std::string& filename, std::mapName(), "ItemDefinitionGroup") == 0) { + } else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories); - } - else if (std::strcmp(node->Name(), "PropertyGroup") == 0) { + } else if (std::strcmp(node->Name(), "PropertyGroup") == 0) { importPropertyGroup(node, variables, includePath, &useOfMfc); - } - else if (std::strcmp(node->Name(), "ImportGroup") == 0) { - const char* labelAttribute = node->Attribute("Label"); + } else if (std::strcmp(node->Name(), "ImportGroup") == 0) { + const char *labelAttribute = node->Attribute("Label"); if (labelAttribute && std::strcmp(labelAttribute, "PropertySheets") == 0) { - for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { + for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "Import") == 0) { - const char* projectAttribute = e->Attribute("Project"); + const char *projectAttribute = e->Attribute("Project"); if (projectAttribute) loadVisualStudioProperties(projectAttribute, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList); } diff --git a/lib/importproject.h b/lib/importproject.h index 7db2dcf05a0..e0b3f482d97 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -110,7 +110,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { }; bool importSln(std::istream &istr, const std::string &path, const std::vector &fileFilters); - static SharedItemsProject importVcxitems(const std::string& filename, const std::vector& fileFilters, std::vector &cache); + static SharedItemsProject importVcxitems(const std::string &filename, const std::vector &fileFilters, std::vector &cache); bool importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters, std::vector &cache); bool importBcb6Prj(const std::string &projectFilename); From 77a7dcea7884b057c30e8ef78bc127ba9039f706 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 19 Apr 2024 07:18:57 +0200 Subject: [PATCH 07/34] skipping string constructor --- lib/importproject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index e3365766e5d..dccfb813481 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -188,7 +188,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings if (!mPath.empty() && !endsWith(mPath,'/')) mPath += '/'; if (mPath.empty()) - mPath = std::string("./"); + mPath = "./"; const std::vector fileFilters = settings ? settings->fileFilters : std::vector(); From cdcd98f3ba29dcc0eb3b5671cea0aaa1f3190862 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 19 Apr 2024 07:45:48 +0200 Subject: [PATCH 08/34] Trying to fix up whitespace and formatting --- lib/importproject.cpp | 54 +++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index dccfb813481..d2b94ab4ddf 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -742,16 +742,16 @@ bool ImportProject::importVcxproj(const std::string &filename, std::mapFirstChildElement(); node; node = node->NextSiblingElement()) { + for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { if (std::strcmp(node->Name(), "ItemGroup") == 0) { - const char* labelAttribute = node->Attribute("Label"); + const char *labelAttribute = node->Attribute("Label"); if (labelAttribute && std::strcmp(labelAttribute, "ProjectConfigurations") == 0) { - for (const tinyxml2::XMLElement* cfg = node->FirstChildElement(); cfg; cfg = cfg->NextSiblingElement()) { + for (const tinyxml2::XMLElement *cfg = node->FirstChildElement(); cfg; cfg = cfg->NextSiblingElement()) { if (std::strcmp(cfg->Name(), "ProjectConfiguration") == 0) { const ProjectConfiguration p(cfg); if (p.platform != ProjectConfiguration::Unknown) { @@ -760,11 +760,10 @@ bool ImportProject::importVcxproj(const std::string &filename, std::mapFirstChildElement(); e; e = e->NextSiblingElement()) { + } else { + for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "ClCompile") == 0) { - const char* include = e->Attribute("Include"); + const char *include = e->Attribute("Include"); if (include && Path::acceptFile(include)) { std::string toInclude = Path::simplifyPath(Path::isAbsolute(include) ? include : Path::getPathFromFilename(filename) + include); compileList.emplace_back(toInclude); @@ -786,13 +785,11 @@ bool ImportProject::importVcxproj(const std::string &filename, std::mapFirstChildElement(); e; e = e->NextSiblingElement()) { + } else if (labelAttribute && std::strcmp(labelAttribute, "Shared") == 0) { + for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "Import") == 0) { - const char* projectAttribute = e->Attribute("Project"); - if (projectAttribute) - { + const char *projectAttribute = e->Attribute("Project"); + if (projectAttribute) { // Path to shared items project is relative to current project directory, // unless the string starts with $(SolutionDir) std::string pathToSharedItemsFile; @@ -805,9 +802,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map sharedItemsIncludePaths{}; for (const auto& sharedProject : sharedItemsProjects) { - for (const auto& file : sharedProject.sourceFiles) { + for (const auto &file : sharedProject.sourceFiles) { std::string pathToFile = Path::simplifyPath(Path::getPathFromFilename(sharedProject.pathToProjectFile) + file); compileList.emplace_back(std::move(pathToFile)); } - for (const auto& p : sharedProject.includePaths) { + for (const auto &p : sharedProject.includePaths) { std::string path = Path::simplifyPath(Path::getPathFromFilename(sharedProject.pathToProjectFile) + p); sharedItemsIncludePaths.emplace_back(std::move(path)); } } // Project files - for (const std::string& cfilename : compileList) { + for (const std::string &cfilename : compileList) { if (!fileFilters.empty() && !matchglobs(fileFilters, cfilename)) continue; - for (const ProjectConfiguration& p : projectConfigurationList) { + for (const ProjectConfiguration &p : projectConfigurationList) { if (!guiProject.checkVsConfigs.empty()) { const bool doChecking = std::any_of(guiProject.checkVsConfigs.cbegin(), guiProject.checkVsConfigs.cend(), [&](const std::string& c) { return c == p.configuration; - }); + }); if (!doChecking) continue; } @@ -902,10 +899,8 @@ static std::string stringReplace(const std::string& original, const std::string& ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::string& filename, const std::vector& fileFilters, std::vector &cache) { - for (const auto& entry : cache) - { - if (filename == entry.pathToProjectFile) - { + for (const auto &entry : cache) { + if (filename == entry.pathToProjectFile) { return entry; } } @@ -919,14 +914,14 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin printError(std::string("Visual Studio project file is not a valid XML - ") + tinyxml2::XMLDocument::ErrorIDToName(error)); return result; } - const tinyxml2::XMLElement* const rootnode = doc.FirstChildElement(); + const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement(); if (rootnode == nullptr) { printError("Visual Studio project file has no XML root node"); return result; } - for (const tinyxml2::XMLElement* node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { + for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { if (std::strcmp(node->Name(), "ItemGroup") == 0) { - for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { + for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "ClCompile") == 0) { const char* include = e->Attribute("Include"); if (include && Path::acceptFile(include)) { @@ -943,8 +938,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin } } } - } - else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { + } else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { ItemDefinitionGroup temp(node, ""); for (const auto& includePath : toStringList(temp.additionalIncludePaths)) { if (includePath == std::string("%(AdditionalIncludeDirectories)")) From a5cef0be6f325641e1fe83057299143bbfd9e9f7 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 19 Apr 2024 07:47:30 +0200 Subject: [PATCH 09/34] Even more formatting fixes --- lib/importproject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index d2b94ab4ddf..85b566d4eaa 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -857,7 +857,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Fri, 19 Apr 2024 07:48:24 +0200 Subject: [PATCH 10/34] Restoring TODO --- lib/importproject.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 85b566d4eaa..60add1cf466 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -847,6 +847,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Fri, 19 Apr 2024 07:55:29 +0200 Subject: [PATCH 11/34] Fixing up errors I introduced during rebasing, sorry! --- lib/importproject.cpp | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 60add1cf466..1f59596bde7 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -452,30 +452,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const std::vector sharedItemsProjects{}; while (std::getline(istr,line)) { if (!startsWith(line,"Project(")) - continue; - - // NOTE(Felix): Custom code for vcxitems - { - const std::string::size_type pos = line.find(".vcxitems"); - if (pos != std::string::npos) - { - const std::string::size_type pos1 = line.rfind('\"', pos); - if (pos1 != std::string::npos) - { - std::string vcxitems(line.substr(pos1 + 1, pos - pos1 + 8)); - vcxitems = Path::toNativeSeparators(std::move(vcxitems)); - if (!Path::isAbsolute(vcxitems)) - vcxitems = path + vcxitems; - vcxitems = Path::fromNativeSeparators(std::move(vcxitems)); - if (!importVcxitems(vcxitems, variables, emptyString, fileFilters)) { - printError("failed to load '" + vcxitems + "' from Visual Studio solution"); - return false; - } - found = true; - } - } - } - + continue; const std::string::size_type pos = line.find(".vcxproj"); if (pos == std::string::npos) continue; @@ -487,7 +464,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const if (!Path::isAbsolute(vcxproj)) vcxproj = path + vcxproj; vcxproj = Path::fromNativeSeparators(std::move(vcxproj)); - if (!importVcxproj(vcxproj, variables, emptyString, fileFilters)) { + if (!importVcxproj(vcxproj, variables, emptyString, fileFilters, sharedItemsProjects)) { printError("failed to load '" + vcxproj + "' from Visual Studio solution"); return false; } @@ -852,9 +829,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Fri, 19 Apr 2024 07:58:06 +0200 Subject: [PATCH 12/34] Restoring TODO and fixing whitespace --- lib/importproject.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 1f59596bde7..e15608f9a14 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -452,7 +452,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const std::vector sharedItemsProjects{}; while (std::getline(istr,line)) { if (!startsWith(line,"Project(")) - continue; + continue; const std::string::size_type pos = line.find(".vcxproj"); if (pos == std::string::npos) continue; @@ -791,7 +791,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map sharedItemsIncludePaths{}; @@ -824,7 +826,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Fri, 19 Apr 2024 07:59:16 +0200 Subject: [PATCH 13/34] More whitespace fixes... --- lib/importproject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index e15608f9a14..08aef9a45bb 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -791,8 +791,8 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Tue, 30 Apr 2024 13:27:46 +0200 Subject: [PATCH 14/34] Remove local stringReplace, adjust FileSettings usage --- lib/importproject.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 08aef9a45bb..29433d13bac 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -823,8 +823,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& fileFilters, std::vector &cache) { for (const auto &entry : cache) { @@ -905,7 +893,8 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin if (std::strcmp(e->Name(), "ClCompile") == 0) { const char* include = e->Attribute("Include"); if (include && Path::acceptFile(include)) { - std::string file = stringReplace(include, "$(MSBuildThisFileDirectory)", "./"); + std::string file(include); + findAndReplace(file, "$(MSBuildThisFileDirectory)", "./"); // Don't include file if it matches the filter if (!fileFilters.empty() && !matchglobs(fileFilters, file)) @@ -924,7 +913,9 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin if (includePath == std::string("%(AdditionalIncludeDirectories)")) continue; - result.includePaths.emplace_back(stringReplace(includePath, "$(MSBuildThisFileDirectory)", "./")); + std::string toAdd(includePath); + findAndReplace(toAdd, "$(MSBuildThisFileDirectory)", "./"); + result.includePaths.emplace_back(toAdd); } } } From ed2a67ac2e342ca2e9b5b02fe9b0cdba9afd41df Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 30 Apr 2024 14:34:28 +0200 Subject: [PATCH 15/34] Adding Solution containing Shared items project for test --- .../shared-items-project/Main/Main.vcxproj | 136 ++++++++++++++++++ .../shared-items-project/Main/MainFile.cpp | 7 + .../Shared/Shared.vcxitems | 22 +++ .../shared-items-project/Shared/TestClass.cpp | 11 ++ .../shared-items-project/Shared/TestClass.h | 11 ++ test/cli/shared-items-project/Solution.sln | 37 +++++ 6 files changed, 224 insertions(+) create mode 100644 test/cli/shared-items-project/Main/Main.vcxproj create mode 100644 test/cli/shared-items-project/Main/MainFile.cpp create mode 100644 test/cli/shared-items-project/Shared/Shared.vcxitems create mode 100644 test/cli/shared-items-project/Shared/TestClass.cpp create mode 100644 test/cli/shared-items-project/Shared/TestClass.h create mode 100644 test/cli/shared-items-project/Solution.sln diff --git a/test/cli/shared-items-project/Main/Main.vcxproj b/test/cli/shared-items-project/Main/Main.vcxproj new file mode 100644 index 00000000000..7a781adb5cf --- /dev/null +++ b/test/cli/shared-items-project/Main/Main.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {074143a3-6080-409a-a181-24e4e468bfd8} + Blub + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/test/cli/shared-items-project/Main/MainFile.cpp b/test/cli/shared-items-project/Main/MainFile.cpp new file mode 100644 index 00000000000..545a063c426 --- /dev/null +++ b/test/cli/shared-items-project/Main/MainFile.cpp @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + Shared::TestClass test{}; + return 0; +} \ No newline at end of file diff --git a/test/cli/shared-items-project/Shared/Shared.vcxitems b/test/cli/shared-items-project/Shared/Shared.vcxitems new file mode 100644 index 00000000000..6f904c81453 --- /dev/null +++ b/test/cli/shared-items-project/Shared/Shared.vcxitems @@ -0,0 +1,22 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {3633ee6f-e5e8-46fc-87c9-f13a18db966a} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + \ No newline at end of file diff --git a/test/cli/shared-items-project/Shared/TestClass.cpp b/test/cli/shared-items-project/Shared/TestClass.cpp new file mode 100644 index 00000000000..89683fe6689 --- /dev/null +++ b/test/cli/shared-items-project/Shared/TestClass.cpp @@ -0,0 +1,11 @@ +#include "TestClass.h" + +using namespace Shared; + +TestClass::TestClass() +{ +} + +TestClass::~TestClass() +{ +} diff --git a/test/cli/shared-items-project/Shared/TestClass.h b/test/cli/shared-items-project/Shared/TestClass.h new file mode 100644 index 00000000000..da8799606a0 --- /dev/null +++ b/test/cli/shared-items-project/Shared/TestClass.h @@ -0,0 +1,11 @@ +#pragma once + +namespace Shared +{ + class TestClass + { + public: + explicit TestClass(); + virtual ~TestClass(); + }; +} // namespace Shared diff --git a/test/cli/shared-items-project/Solution.sln b/test/cli/shared-items-project/Solution.sln new file mode 100644 index 00000000000..5daeb4dbcda --- /dev/null +++ b/test/cli/shared-items-project/Solution.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34607.119 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shared", "Shared\Shared.vcxitems", "{3633EE6F-E5E8-46FC-87C9-F13A18DB966A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "Main\Main.vcxproj", "{074143A3-6080-409A-A181-24E4E468BFD8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x64.ActiveCfg = Debug|x64 + {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x64.Build.0 = Debug|x64 + {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x86.ActiveCfg = Debug|Win32 + {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x86.Build.0 = Debug|Win32 + {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x64.ActiveCfg = Release|x64 + {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x64.Build.0 = Release|x64 + {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x86.ActiveCfg = Release|Win32 + {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {510D1526-E6EE-452F-A697-173A3D4C4E93} + EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + Shared\Shared.vcxitems*{074143a3-6080-409a-a181-24e4e468bfd8}*SharedItemsImports = 4 + Shared\Shared.vcxitems*{3633ee6f-e5e8-46fc-87c9-f13a18db966a}*SharedItemsImports = 9 + EndGlobalSection +EndGlobal From a2cd83a49cef172c7ac7fb33bf7242a0ede8434f Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 9 Aug 2024 06:58:50 +0200 Subject: [PATCH 16/34] Rebasing... --- test/cli/more-projects_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 2830d577abb..9970cbe19e2 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -843,3 +843,15 @@ def test_compdb_D(tmpdir): assert stdout.splitlines() == out_expected assert stderr.splitlines() == [] assert ret == 0, stdout + + +def test_shared_items_project(tmpdir): + solutionDir = os.path.join(os.getcwd(), 'shared-items-project') + solutionFile = f"{solutionDir}/Solution.sln" + + args = ['--project={}'.format(solutionFile), "-j1"] + + # TODO: + # - Assert "shared-items-project\Main\MainFile.Cpp" + # - Assert "shared-items-project\Shared\TestClass.Cpp" + From 433e0411f86401484583e771228bdf45e1c17fad Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 9 Aug 2024 06:59:42 +0200 Subject: [PATCH 17/34] Rebasing... --- test/cli/more-projects_test.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 9970cbe19e2..6c1723949bb 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -755,6 +755,7 @@ def test_json_file_ignore_2(tmpdir): assert_cppcheck(args, ec_exp=1, err_exp=[], out_exp=out_lines) +<<<<<<< HEAD @pytest.mark.xfail(strict=True) def test_project_D(tmpdir): test_file = os.path.join(tmpdir, 'test.cpp') @@ -845,13 +846,29 @@ def test_compdb_D(tmpdir): assert ret == 0, stdout -def test_shared_items_project(tmpdir): +def test_shared_items_project(tmpdir = ""): + # tmpdir is unused solutionDir = os.path.join(os.getcwd(), 'shared-items-project') - solutionFile = f"{solutionDir}/Solution.sln" - - args = ['--project={}'.format(solutionFile), "-j1"] - - # TODO: - # - Assert "shared-items-project\Main\MainFile.Cpp" - # - Assert "shared-items-project\Shared\TestClass.Cpp" + solutionFile = os.path.join(solutionDir, 'Solution.sln') + codeMainFile = os.path.join(solutionDir, 'Main', 'MainFile.cpp') + codeSharedFile = os.path.join(solutionDir, 'Shared', 'TestClass.cpp') + args = [ + '--platform=win64', + '--project={}'.format(solutionFile), + '--project-configuration=Release|x64', + '-j1' + ] + + exitcode, stdout, stderr = cppcheck(args) + assert exitcode == 0 + lines = stdout.splitlines() + assert lines == [ + 'Checking {} Release|x64...'.format(codeMainFile), + 'Checking {}: _WIN32=1;_WIN64=1;_MSC_VER=1900...'.format(codeMainFile), + '1/2 files checked 50% done', + 'Checking {} Release|x64...'.format(codeSharedFile), + 'Checking {}: _WIN32=1;_WIN64=1;_MSC_VER=1900...'.format(codeSharedFile), + '2/2 files checked 100% done', + ] + assert stderr == '' From 3164e05f6e8346ca22347ac98eecdde1575eee00 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 30 Apr 2024 15:18:28 +0200 Subject: [PATCH 18/34] Removing all but one configuration --- .../shared-items-project/Main/Main.vcxproj | 80 ------------------- test/cli/shared-items-project/Solution.sln | 9 --- 2 files changed, 89 deletions(-) diff --git a/test/cli/shared-items-project/Main/Main.vcxproj b/test/cli/shared-items-project/Main/Main.vcxproj index 7a781adb5cf..17c6fc98aa3 100644 --- a/test/cli/shared-items-project/Main/Main.vcxproj +++ b/test/cli/shared-items-project/Main/Main.vcxproj @@ -1,18 +1,6 @@ - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - Release x64 @@ -26,25 +14,6 @@ 10.0 - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - Application false @@ -58,59 +27,10 @@ - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - Level3 diff --git a/test/cli/shared-items-project/Solution.sln b/test/cli/shared-items-project/Solution.sln index 5daeb4dbcda..6a4aac0fd2f 100644 --- a/test/cli/shared-items-project/Solution.sln +++ b/test/cli/shared-items-project/Solution.sln @@ -9,20 +9,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "Main\Main.vcxproj", EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x64.ActiveCfg = Debug|x64 - {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x64.Build.0 = Debug|x64 - {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x86.ActiveCfg = Debug|Win32 - {074143A3-6080-409A-A181-24E4E468BFD8}.Debug|x86.Build.0 = Debug|Win32 {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x64.ActiveCfg = Release|x64 {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x64.Build.0 = Release|x64 - {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x86.ActiveCfg = Release|Win32 - {074143A3-6080-409A-A181-24E4E468BFD8}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From a3c91fe5882ee387380ec0ec5754c3eb8fda8517 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 5 Jun 2024 12:54:44 +0200 Subject: [PATCH 19/34] Undoing change (which fixed an issue locally, but is not related to shared items project implementation) --- lib/importproject.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 29433d13bac..6396063411b 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -187,8 +187,6 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings mPath = Path::getPathFromFilename(Path::fromNativeSeparators(filename)); if (!mPath.empty() && !endsWith(mPath,'/')) mPath += '/'; - if (mPath.empty()) - mPath = "./"; const std::vector fileFilters = settings ? settings->fileFilters : std::vector(); From d648807b3e68112adc05eb8302656e1f031bfe4e Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 5 Jun 2024 13:05:07 +0200 Subject: [PATCH 20/34] Fix whitespace formatting for formatter pipeline --- lib/importproject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 6396063411b..4c9b760f004 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -777,7 +777,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Fri, 9 Aug 2024 07:00:17 +0200 Subject: [PATCH 21/34] Rebasing... --- test/cli/more-projects_test.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 6c1723949bb..b0d0ff9f6f7 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -863,12 +863,7 @@ def test_shared_items_project(tmpdir = ""): exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 lines = stdout.splitlines() - assert lines == [ - 'Checking {} Release|x64...'.format(codeMainFile), - 'Checking {}: _WIN32=1;_WIN64=1;_MSC_VER=1900...'.format(codeMainFile), - '1/2 files checked 50% done', - 'Checking {} Release|x64...'.format(codeSharedFile), - 'Checking {}: _WIN32=1;_WIN64=1;_MSC_VER=1900...'.format(codeSharedFile), - '2/2 files checked 100% done', - ] + + # Assume no errors, and that shared items code files have been checked as well + assert any('2/2 files checked 100% done' in x for x in lines) assert stderr == '' From c87a240cfb8186112753b2f01fb754fb2fd7e85c Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 11 Jun 2024 11:08:04 +0200 Subject: [PATCH 22/34] Fix issue: Reducing scope of variable --- lib/importproject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 4c9b760f004..29dbde8dbe6 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -190,7 +190,6 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings const std::vector fileFilters = settings ? settings->fileFilters : std::vector(); - std::vector sharedItemsProjects{}; if (endsWith(filename, ".json")) { if (importCompileCommands(fin)) { @@ -204,6 +203,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings } } else if (endsWith(filename, ".vcxproj")) { std::map variables; + std::vector sharedItemsProjects{}; if (importVcxproj(filename, variables, emptyString, fileFilters, sharedItemsProjects)) { setRelativePaths(filename); return ImportProject::Type::VS_VCXPROJ; From 041a65b4cdeba92322cdd293d1042b5be36654ef Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 11 Jun 2024 11:22:02 +0200 Subject: [PATCH 23/34] Trying to appease the Pipeline --- lib/importproject.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 29dbde8dbe6..80fd2e64897 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -865,11 +865,11 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& fileFilters, std::vector &cache) { - for (const auto &entry : cache) { - if (filename == entry.pathToProjectFile) { - return entry; - } - } + auto isInCacheCheck = [filename](const auto& e) -> bool { return filename == e.pathToProjectFile; }; + auto iterator = std::find_if(cache.begin(), cache.end(), isInCacheCheck); + if (iterator != std::end(cache)) { + return *iterator; + } SharedItemsProject result{}; result.pathToProjectFile = filename; From da70af9aec66b74978ad20e3d2d9b0da998d79f9 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Tue, 11 Jun 2024 11:29:03 +0200 Subject: [PATCH 24/34] Fix whitespace, hopefull fixing CI compilation error which works fine locally??? --- lib/importproject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 80fd2e64897..62a6782eb7f 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -865,11 +865,11 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& fileFilters, std::vector &cache) { - auto isInCacheCheck = [filename](const auto& e) -> bool { return filename == e.pathToProjectFile; }; + auto isInCacheCheck = [filename](const ImportProject::SharedItemsProject& e) -> bool { return filename == e.pathToProjectFile; }; auto iterator = std::find_if(cache.begin(), cache.end(), isInCacheCheck); - if (iterator != std::end(cache)) { + if (iterator != std::end(cache)) { return *iterator; - } + } SharedItemsProject result{}; result.pathToProjectFile = filename; From 94ef315eafa9cd1f195cd019370aedb2364d1200 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 12 Jun 2024 07:02:04 +0200 Subject: [PATCH 25/34] Fixed formatting --- lib/importproject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 62a6782eb7f..a09af14e67d 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -865,7 +865,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& fileFilters, std::vector &cache) { - auto isInCacheCheck = [filename](const ImportProject::SharedItemsProject& e) -> bool { return filename == e.pathToProjectFile; }; + auto isInCacheCheck = [filename](const ImportProject::SharedItemsProject& e) -> bool { + return filename == e.pathToProjectFile; + }; auto iterator = std::find_if(cache.begin(), cache.end(), isInCacheCheck); if (iterator != std::end(cache)) { return *iterator; From 87373623c8585e0e6a1ea4521b2dc6c7fd18819f Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 12 Jun 2024 07:03:37 +0200 Subject: [PATCH 26/34] Remove redundant {} initializer --- lib/importproject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index a09af14e67d..0f859aa8968 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -203,7 +203,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings } } else if (endsWith(filename, ".vcxproj")) { std::map variables; - std::vector sharedItemsProjects{}; + std::vector sharedItemsProjects; if (importVcxproj(filename, variables, emptyString, fileFilters, sharedItemsProjects)) { setRelativePaths(filename); return ImportProject::Type::VS_VCXPROJ; @@ -447,7 +447,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const variables["SolutionDir"] = path; bool found = false; - std::vector sharedItemsProjects{}; + std::vector sharedItemsProjects; while (std::getline(istr,line)) { if (!startsWith(line,"Project(")) continue; @@ -794,7 +794,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map sharedItemsIncludePaths{}; + std::vector sharedItemsIncludePaths; for (const auto& sharedProject : sharedItemsProjects) { for (const auto &file : sharedProject.sourceFiles) { std::string pathToFile = Path::simplifyPath(Path::getPathFromFilename(sharedProject.pathToProjectFile) + file); @@ -873,7 +873,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin return *iterator; } - SharedItemsProject result{}; + SharedItemsProject result; result.pathToProjectFile = filename; tinyxml2::XMLDocument doc; From 341274d3094bb11c7514fdb159aba5696e165759 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 12 Jun 2024 07:04:51 +0200 Subject: [PATCH 27/34] Replacing exit with cleaner return --- lib/importproject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 0f859aa8968..782aa9db064 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -775,7 +775,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map Date: Wed, 12 Jun 2024 11:48:01 +0200 Subject: [PATCH 28/34] Fixed missing "return", fixed trailing whitespace --- lib/importproject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 782aa9db064..db46ac98d8e 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -775,7 +775,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map& fileFilters, std::vector &cache) { - auto isInCacheCheck = [filename](const ImportProject::SharedItemsProject& e) -> bool { - return filename == e.pathToProjectFile; + auto isInCacheCheck = [filename](const ImportProject::SharedItemsProject& e) -> bool { + return filename == e.pathToProjectFile; }; auto iterator = std::find_if(cache.begin(), cache.end(), isInCacheCheck); if (iterator != std::end(cache)) { From 7a248690dbb28ce797481888240bd469f682cf51 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 12 Jun 2024 13:21:23 +0200 Subject: [PATCH 29/34] Fixed whitespace in test --- test/cli/more-projects_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index b0d0ff9f6f7..d8ba5c316b2 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -859,7 +859,7 @@ def test_shared_items_project(tmpdir = ""): '--project-configuration=Release|x64', '-j1' ] - + exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 lines = stdout.splitlines() From 7f8440223b121ebf6eb0feefc72552f49f8fc34b Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 12 Jun 2024 13:21:51 +0200 Subject: [PATCH 30/34] Reverting removal of init braces. --- lib/importproject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index db46ac98d8e..b4489afd262 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -873,7 +873,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin return *iterator; } - SharedItemsProject result; + SharedItemsProject result{}; result.pathToProjectFile = filename; tinyxml2::XMLDocument doc; From 6374db14dbc729f9146b1de3213d036a1210f45c Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 9 Aug 2024 07:09:20 +0200 Subject: [PATCH 31/34] Removing leftovers from rebasing --- test/cli/more-projects_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index d8ba5c316b2..19006da6501 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -755,7 +755,6 @@ def test_json_file_ignore_2(tmpdir): assert_cppcheck(args, ec_exp=1, err_exp=[], out_exp=out_lines) -<<<<<<< HEAD @pytest.mark.xfail(strict=True) def test_project_D(tmpdir): test_file = os.path.join(tmpdir, 'test.cpp') From 304519eed4c529835c4c4e681fa4a1186cfcd297 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Fri, 9 Aug 2024 07:10:13 +0200 Subject: [PATCH 32/34] removal of unused test variables --- test/cli/more-projects_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 19006da6501..7824bb88f5c 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -849,8 +849,6 @@ def test_shared_items_project(tmpdir = ""): # tmpdir is unused solutionDir = os.path.join(os.getcwd(), 'shared-items-project') solutionFile = os.path.join(solutionDir, 'Solution.sln') - codeMainFile = os.path.join(solutionDir, 'Main', 'MainFile.cpp') - codeSharedFile = os.path.join(solutionDir, 'Shared', 'TestClass.cpp') args = [ '--platform=win64', From e1c228099768f13d82872b96d82a5050c7bec475 Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Mon, 19 Aug 2024 09:02:33 +0200 Subject: [PATCH 33/34] fixed nits and blatant typo --- lib/importproject.cpp | 10 +++++----- lib/importproject.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index b4489afd262..e3b7c2e66d1 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -769,9 +769,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map bool { return filename == e.pathToProjectFile; }; - auto iterator = std::find_if(cache.begin(), cache.end(), isInCacheCheck); + const auto iterator = std::find_if(cache.begin(), cache.end(), isInCacheCheck); if (iterator != std::end(cache)) { return *iterator; } @@ -920,7 +920,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin } } - result.successFull = true; + result.successful = true; cache.emplace_back(result); return result; } diff --git a/lib/importproject.h b/lib/importproject.h index e0b3f482d97..c1635471371 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -103,7 +103,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { private: struct SharedItemsProject { - bool successFull; + bool successful; std::string pathToProjectFile; std::vector includePaths; std::vector sourceFiles; From 1ebbf981a92cfde695c97aa4a795025aa22f1f3e Mon Sep 17 00:00:00 2001 From: Felix Faber Date: Wed, 21 Aug 2024 08:56:35 +0200 Subject: [PATCH 34/34] Fixed nits --- lib/importproject.cpp | 4 ++-- lib/importproject.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index e3b7c2e66d1..fec2deb734d 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -873,7 +873,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin return *iterator; } - SharedItemsProject result{}; + SharedItemsProject result; result.pathToProjectFile = filename; tinyxml2::XMLDocument doc; @@ -910,7 +910,7 @@ ImportProject::SharedItemsProject ImportProject::importVcxitems(const std::strin } else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) { ItemDefinitionGroup temp(node, ""); for (const auto& includePath : toStringList(temp.additionalIncludePaths)) { - if (includePath == std::string("%(AdditionalIncludeDirectories)")) + if (includePath == "%(AdditionalIncludeDirectories)") continue; std::string toAdd(includePath); diff --git a/lib/importproject.h b/lib/importproject.h index c1635471371..bf5d3dcf57c 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -103,7 +103,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { private: struct SharedItemsProject { - bool successful; + bool successful = false; std::string pathToProjectFile; std::vector includePaths; std::vector sourceFiles;