From acaae6d265425a1cc82551c8bec158f07ddbaa0e Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Wed, 2 Apr 2025 15:18:00 -0400 Subject: cmState: Improve how state is reset Modify cmState::Reset to create a fresh BuildsystemDirectoryStateType for the root, rather than trying to reset the old one. This is less brittle with respect to changes made to BuildsystemDirectoryStateType (e.g. adding new members). --- Source/cmState.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 6c261f4..81f53c2 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -282,16 +282,12 @@ cmStateSnapshot cmState::Reset() { cmLinkedTree::iterator it = this->BuildsystemDirectory.Truncate(); - it->IncludeDirectories.clear(); - it->CompileDefinitions.clear(); - it->CompileOptions.clear(); - it->LinkOptions.clear(); - it->LinkDirectories.clear(); - it->CurrentScope = pos; - it->NormalTargetNames.clear(); - it->ImportedTargetNames.clear(); - it->Properties.Clear(); - it->Children.clear(); + + cmStateDetail::BuildsystemDirectoryStateType newState; + newState.Location = std::move(it->Location); + newState.OutputLocation = std::move(it->OutputLocation); + newState.CurrentScope = pos; + *it = std::move(newState); } this->PolicyStack.Clear(); -- cgit v0.12