From 9526dd8425644ab89eb448ce3364928acaec8048 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 13 Aug 2026 09:03:12 -0400 Subject: [PATCH 1/3] refactor ExcludedFromBuild to use Conditional --- lib/importproject.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 5c9bcaadd3f..0acfcd9ce3e 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -818,10 +818,14 @@ namespace { bool useUnicode = false; }; + struct ExcludedFromBuild : Conditional { + explicit ExcludedFromBuild(const tinyxml2::XMLElement *efb) : Conditional(efb) {} + }; + struct ItemGroupClCompile { explicit ItemGroupClCompile(std::string filename) : mFilename(std::move(filename)) {} ItemGroupClCompile(const tinyxml2::XMLElement *element, std::string file) : mFilename(std::move(file)) { - for (const tinyxml2::XMLElement* childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) { + for (const tinyxml2::XMLElement *childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) { const char *name = childElement->Name(); if (!name) continue; @@ -830,23 +834,22 @@ namespace { const char *text = childElement->GetText(); if (!condition || !text || std::strcmp(text, "true") != 0) continue; - mConditions.emplace_back(condition); + mExcludedFromBuild.emplace_back(childElement); } - // TODO: ForcedIncludeFiles and PrecompiledHeaderFile + // TODO: ForcedIncludeFiles and AdditionalIncludeDirectories } } - bool exclude(const ProjectConfiguration& p, std::vector& errors) const { - if (mConditions.empty()) + bool excludedfromBuild(const ProjectConfiguration &pc, std::vector &errors) const { + if (mExcludedFromBuild.empty()) return false; - for (const std::string& condition : mConditions) { - Conditional conditional(condition); - if (conditional.conditionIsTrue(p, mFilename, errors)) + for (const ExcludedFromBuild &excluded : mExcludedFromBuild) { + if (excluded.conditionIsTrue(pc, mFilename, errors)) return true; } return false; } std::string mFilename; - std::list mConditions; + std::list mExcludedFromBuild; }; } @@ -1074,7 +1077,7 @@ bool ImportProject::importVcxproj(const std::string &filename, const tinyxml2::X } // check if the file should be excluded for this configuration - if (compile.exclude(p, errors)) + if (compile.excludedfromBuild(p, errors)) continue; FileSettings fs{ compile.mFilename, Standards::Language::None, 0}; // file will be identified later on From 9e031970116d6baba3d56b7557eb816cfea86fa7 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 13 Aug 2026 09:14:51 -0400 Subject: [PATCH 2/3] remove unused constructor --- lib/importproject.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 0acfcd9ce3e..5eebd8bb710 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -623,7 +623,6 @@ namespace { if (condAttr) mCondition = condAttr; } - explicit Conditional(std::string condition) : mCondition(std::move(condition)) {} static void replaceAll(std::string &c, const std::string &from, const std::string &to) { std::string::size_type pos; From db1b6ff1ca75b35c75e3ea9c16b18d4e31e16168 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 13 Aug 2026 10:41:33 -0400 Subject: [PATCH 3/3] fix cppcheck warning --- lib/importproject.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 5eebd8bb710..0d2c6d9046d 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -839,13 +839,9 @@ namespace { } } bool excludedfromBuild(const ProjectConfiguration &pc, std::vector &errors) const { - if (mExcludedFromBuild.empty()) - return false; - for (const ExcludedFromBuild &excluded : mExcludedFromBuild) { - if (excluded.conditionIsTrue(pc, mFilename, errors)) - return true; - } - return false; + return std::any_of(mExcludedFromBuild.cbegin(), mExcludedFromBuild.cend(), [&](const ExcludedFromBuild &excluded) { + return excluded.conditionIsTrue(pc, mFilename, errors); + }); } std::string mFilename; std::list mExcludedFromBuild;