block: Fix incorrect policy scope creation order

Creates the policy scope after the variable scope instead of the other
way round. This ensures that the cmStateSnapshot which the policy is
registered to is the same as the one created with the variable scope so
that reading a policy from the parent snapshot does not incorrectly read
policies from the new snapshot.
This commit is contained in:
Arha Gatram
2026-06-25 16:36:02 -07:00
committed by Brad King
parent 5190a9d88e
commit 220fc8622d

View File

@@ -40,19 +40,19 @@ public:
BlockScopePushPop& operator=(BlockScopePushPop const&) = delete;
private:
std::unique_ptr<cmMakefile::PolicyPushPop> PolicyScope;
std::unique_ptr<cmMakefile::VariablePushPop> VariableScope;
std::unique_ptr<cmMakefile::PolicyPushPop> PolicyScope;
std::unique_ptr<cmMakefile::DiagnosticPushPop> DiagnosticScope;
};
BlockScopePushPop::BlockScopePushPop(cmMakefile* mf, ScopeSet const& scopes)
{
if (scopes.contains(ScopeType::POLICIES)) {
this->PolicyScope = cm::make_unique<cmMakefile::PolicyPushPop>(mf);
}
if (scopes.contains(ScopeType::VARIABLES)) {
this->VariableScope = cm::make_unique<cmMakefile::VariablePushPop>(mf);
}
if (scopes.contains(ScopeType::POLICIES)) {
this->PolicyScope = cm::make_unique<cmMakefile::PolicyPushPop>(mf);
}
if (scopes.contains(ScopeType::DIAGNOSTICS)) {
this->DiagnosticScope = cm::make_unique<cmMakefile::DiagnosticPushPop>(mf);
}