From 2ccbad90e6d1aa2cda7a690dbcc4a7a3f59adad3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 22 Feb 2025 07:22:58 -0500 Subject: [PATCH] cmGeneratorExpressionDAGChecker: Construct with initializer list syntax --- Source/cmCommonTargetGenerator.cxx | 7 ++-- Source/cmComputeLinkDepends.cxx | 26 ++++++------ Source/cmExportTryCompileFileGenerator.cxx | 11 +++-- Source/cmGeneratorExpression.cxx | 10 +++-- Source/cmGeneratorExpressionNode.cxx | 20 ++++++---- Source/cmGeneratorTarget.cxx | 17 ++++---- .../cmGeneratorTarget_IncludeDirectories.cxx | 27 +++++++------ Source/cmGeneratorTarget_Link.cxx | 10 +++-- Source/cmGeneratorTarget_LinkDirectories.cxx | 5 ++- Source/cmGeneratorTarget_Options.cxx | 40 +++++++++++-------- Source/cmGeneratorTarget_Sources.cxx | 5 ++- .../cmGeneratorTarget_TransitiveProperty.cxx | 12 ++++-- Source/cmQtAutoGenInitializer.cxx | 14 ++++--- 13 files changed, 122 insertions(+), 82 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 9f25904e0f..d183dc2ef9 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -500,9 +500,10 @@ std::string cmCommonTargetGenerator::GetLinkerLauncher( std::string propName = lang + "_LINKER_LAUNCHER"; cmValue launcherProp = this->GeneratorTarget->GetProperty(propName); if (cmNonempty(launcherProp)) { - cmGeneratorExpressionDAGChecker dagChecker( - this->GeneratorTarget, propName, nullptr, nullptr, - this->LocalCommonGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this->GeneratorTarget, propName, nullptr, nullptr, + this->LocalCommonGenerator, config, + }; std::string evaluatedLinklauncher = cmGeneratorExpression::Evaluate( *launcherProp, this->LocalCommonGenerator, config, this->GeneratorTarget, &dagChecker, this->GeneratorTarget, lang); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index d445128b69..dffe5e099b 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -646,18 +646,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, if (cmValue feature = this->Target->GetProperty(key)) { if (!feature->empty() && key.length() > lloPrefix.length()) { auto item = key.substr(lloPrefix.length()); - cmGeneratorExpressionDAGChecker dag{ + cmGeneratorExpressionDAGChecker dagChecker{ this->Target->GetBacktrace(), this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, this->Target->GetLocalGenerator(), - config + config, }; auto overrideFeature = cmGeneratorExpression::Evaluate( *feature, this->Target->GetLocalGenerator(), config, - this->Target, &dag, this->Target, linkLanguage); + this->Target, &dagChecker, this->Target, linkLanguage); this->LinkLibraryOverride.emplace(item, overrideFeature); } } @@ -666,16 +666,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, // global override property if (cmValue linkLibraryOverride = this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) { - cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(), - target, - "LINK_LIBRARY_OVERRIDE", - nullptr, - nullptr, - target->GetLocalGenerator(), - config }; + cmGeneratorExpressionDAGChecker dagChecker{ + target->GetBacktrace(), + target, + "LINK_LIBRARY_OVERRIDE", + nullptr, + nullptr, + target->GetLocalGenerator(), + config, + }; auto overrideValue = cmGeneratorExpression::Evaluate( - *linkLibraryOverride, target->GetLocalGenerator(), config, target, &dag, - target, linkLanguage); + *linkLibraryOverride, target->GetLocalGenerator(), config, target, + &dagChecker, target, linkLanguage); auto overrideList = cmTokenize(overrideValue, ","_s); if (overrideList.size() >= 2) { diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 021e071153..ea55f47346 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -86,9 +86,14 @@ std::string cmExportTryCompileFileGenerator::FindTargets( tgt, "LINK_OPTIONS", nullptr, nullptr, tgt->GetLocalGenerator(), this->Config); } - cmGeneratorExpressionDAGChecker dagChecker( - tgt, propName, nullptr, parentDagChecker.get(), tgt->GetLocalGenerator(), - this->Config); + cmGeneratorExpressionDAGChecker dagChecker{ + tgt, + propName, + nullptr, + parentDagChecker.get(), + tgt->GetLocalGenerator(), + this->Config, + }; std::unique_ptr cge = ge.Parse(*prop); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 553ea1fb9c..580d65dc6f 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -425,10 +425,14 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate( this->GeneratorExpression.Parse(std::move(expression)); // Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS - cmGeneratorExpressionDAGChecker dagChecker( + cmGeneratorExpressionDAGChecker dagChecker{ this->HeadTarget, - property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr, - nullptr, this->LocalGenerator, this->Config); + property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, + nullptr, + nullptr, + this->LocalGenerator, + this->Config, + }; return this->CompiledGeneratorExpression->Evaluate( this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr, diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index e42622158b..e355cf676c 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -485,10 +485,15 @@ protected: cmGeneratorExpressionDAGChecker* dagCheckerParent) const { if (context->HeadTarget) { - cmGeneratorExpressionDAGChecker dagChecker( - context->Backtrace, context->HeadTarget, - genexOperator + ":" + expression, content, dagCheckerParent, - context->LG, context->Config); + cmGeneratorExpressionDAGChecker dagChecker{ + context->Backtrace, + context->HeadTarget, + genexOperator + ":" + expression, + content, + dagCheckerParent, + context->LG, + context->Config, + }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: { @@ -2987,9 +2992,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode dagCheckerParent, usage)); } - cmGeneratorExpressionDAGChecker dagChecker( - context->Backtrace, target, propertyName, content, dagCheckerParent, - context->LG, context->Config); + cmGeneratorExpressionDAGChecker dagChecker{ + context->Backtrace, target, propertyName, content, + dagCheckerParent, context->LG, context->Config, + }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fb92771b03..39f0b46d60 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -744,8 +744,9 @@ std::string cmGeneratorTarget::GetLinkerTypeProperty( std::string propName{ "LINKER_TYPE" }; auto linkerType = this->GetProperty(propName); if (!linkerType.IsEmpty()) { - cmGeneratorExpressionDAGChecker dagChecker( - this, propName, nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, propName, nullptr, nullptr, this->LocalGenerator, config, + }; auto ltype = cmGeneratorExpression::Evaluate(*linkerType, this->GetLocalGenerator(), config, this, &dagChecker, this, lang); @@ -1200,9 +1201,10 @@ void cmGeneratorTarget::AddSystemIncludeCacheKey( const std::string& key, const std::string& config, const std::string& language) const { - cmGeneratorExpressionDAGChecker dagChecker( - this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, - config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, + nullptr, this->LocalGenerator, config, + }; bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); @@ -1978,8 +1980,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector& result, return; } - cmGeneratorExpressionDAGChecker dagChecker( - this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config, + }; cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator, config, this, &dagChecker), result); diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index a05b1a2986..da97a68ff3 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -47,13 +47,13 @@ std::string AddLangSpecificInterfaceIncludeDirectories( const std::string& propertyName, IncludeDirectoryFallBack mode, cmGeneratorExpressionDAGChecker* context) { - cmGeneratorExpressionDAGChecker dag{ + cmGeneratorExpressionDAGChecker dagChecker{ target->GetBacktrace(), target, propertyName, nullptr, context, - target->GetLocalGenerator(), config + target->GetLocalGenerator(), config, }; - switch (dag.Check()) { + switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: - dag.ReportError( + dagChecker.ReportError( nullptr, "$GetName() + ",propertyName"); CM_FALLTHROUGH; case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: @@ -100,9 +100,9 @@ void AddLangSpecificImplicitIncludeDirectories( { if (const auto* libraries = target->GetLinkImplementationLibraries(config, UseTo::Compile)) { - cmGeneratorExpressionDAGChecker dag{ + cmGeneratorExpressionDAGChecker dagChecker{ target->GetBacktrace(), target, propertyName, nullptr, nullptr, - target->GetLocalGenerator(), config + target->GetLocalGenerator(), config, }; for (const cmLinkImplItem& library : libraries->Libraries) { @@ -128,10 +128,10 @@ void AddLangSpecificImplicitIncludeDirectories( } } - cmExpandList( - AddLangSpecificInterfaceIncludeDirectories( - target, dependency, lang, config, propertyName, mode, &dag), - entry.Values); + cmExpandList(AddLangSpecificInterfaceIncludeDirectories( + target, dependency, lang, config, propertyName, mode, + &dagChecker), + entry.Values); entries.Entries.emplace_back(std::move(entry)); } } @@ -257,9 +257,10 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( std::vector> includes; std::unordered_set uniqueIncludes; - cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES", - nullptr, nullptr, - this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "INCLUDE_DIRECTORIES", nullptr, + nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index 50bcefaf26..e1db657ed2 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -564,8 +564,9 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, return; } // Keep this logic in sync with ComputeLinkImplementationLibraries. - cmGeneratorExpressionDAGChecker dagChecker(this, prop, nullptr, nullptr, - this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, prop, nullptr, nullptr, this->LocalGenerator, config, + }; // The $ expression may be in a link interface to specify // private link dependencies that are otherwise excluded from usage // requirements. @@ -1320,8 +1321,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( // Collect libraries directly linked in this configuration. for (auto const& entry : entryRange) { // Keep this logic in sync with ExpandLinkItems. - cmGeneratorExpressionDAGChecker dagChecker( - this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config, + }; // The $ expression may be used to specify link dependencies // that are otherwise excluded from usage requirements. if (usage == UseTo::Compile) { diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index bd894978d8..3acb2cb96a 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -125,8 +125,9 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( std::vector> result; std::unordered_set uniqueDirectories; - cmGeneratorExpressionDAGChecker dagChecker( - this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index 5ac42bf893..5eb3760745 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -233,8 +233,9 @@ std::vector> cmGeneratorTarget::GetCompileOptions( std::vector> result; std::unordered_set uniqueOptions; - cmGeneratorExpressionDAGChecker dagChecker( - this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; @@ -274,8 +275,9 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( std::vector> result; std::unordered_set uniqueFeatures; - cmGeneratorExpressionDAGChecker dagChecker( - this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; @@ -324,9 +326,10 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( std::vector> list; std::unordered_set uniqueOptions; - cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS", - nullptr, nullptr, - this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "COMPILE_DEFINITIONS", nullptr, + nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; @@ -389,9 +392,9 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( } std::unordered_set uniqueOptions; - cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS", - nullptr, nullptr, - this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "PRECOMPILE_HEADERS", nullptr, nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; @@ -448,8 +451,9 @@ std::vector> cmGeneratorTarget::GetLinkOptions( std::vector> result; std::unordered_set uniqueOptions; - cmGeneratorExpressionDAGChecker dagChecker( - this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config, + }; cmList debugProperties{ this->Makefile->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES") }; @@ -622,9 +626,10 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( std::vector> result; std::unordered_set uniqueOptions; - cmGeneratorExpressionDAGChecker dagChecker(this, "STATIC_LIBRARY_OPTIONS", - nullptr, nullptr, - this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "STATIC_LIBRARY_OPTIONS", nullptr, + nullptr, this->LocalGenerator, config, + }; EvaluatedTargetPropertyEntries entries; if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) { @@ -655,8 +660,9 @@ std::vector> cmGeneratorTarget::GetLinkDepends( { std::vector> result; std::unordered_set uniqueOptions; - cmGeneratorExpressionDAGChecker dagChecker( - this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config, + }; EvaluatedTargetPropertyEntries entries; if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) { diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index 94e88971a9..2540d810f9 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -264,8 +264,9 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( this->DebugSourcesDone = true; } - cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr, nullptr, - this->LocalGenerator, config); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "SOURCES", nullptr, nullptr, this->LocalGenerator, config, + }; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( this, config, std::string(), &dagChecker, this->SourceEntries); diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index ac929ebc6e..d88a5b55cb 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -109,9 +109,15 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( // Evaluate $ as if it were compiled. This is // a subset of TargetPropertyNode::Evaluate without stringify/parse steps // but sufficient for transitive interface properties. - cmGeneratorExpressionDAGChecker dagChecker( - context->Backtrace, this, prop, nullptr, dagCheckerParent, - this->LocalGenerator, context->Config); + cmGeneratorExpressionDAGChecker dagChecker{ + context->Backtrace, + this, + prop, + nullptr, + dagCheckerParent, + this->LocalGenerator, + context->Config, + }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: dagChecker.ReportError( diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index c9dd1547bc..5810d03713 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1922,9 +1922,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() if (this->MultiConfig) { for (auto const& cfg : this->ConfigsList) { if (!cfg.empty()) { - cmGeneratorExpressionDAGChecker dagChecker( - this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, - this->LocalGen, cfg); + cmGeneratorExpressionDAGChecker dagChecker{ + this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, + nullptr, this->LocalGen, cfg, + }; AddInterfaceEntries(this->GenTarget, cfg, "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker, InterfaceAutoMocMacroNamesEntries, @@ -1932,9 +1933,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } } } else { - cmGeneratorExpressionDAGChecker dagChecker( - this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, - this->LocalGen, this->ConfigDefault); + cmGeneratorExpressionDAGChecker dagChecker{ + this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, + nullptr, this->LocalGen, this->ConfigDefault, + }; AddInterfaceEntries(this->GenTarget, this->ConfigDefault, "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker, InterfaceAutoMocMacroNamesEntries,