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).
This commit is contained in:
Matthew Woehlke
2025-04-02 15:18:00 -04:00
parent 1063a1c603
commit acaae6d265

View File

@@ -282,16 +282,12 @@ cmStateSnapshot cmState::Reset()
{
cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::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();