mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-25 16:01:11 +00:00
Destroy locals at the end of blocks, not only on return (#7448)
Destroy local variables and temporaries at each `}`, and when branching with `break` and `continue`. In `for` statements, destroy loop variables along with anything created within the loop at the end of each loop iteration, and destroy the cursor and range object when the loop terminates. Assisted-by: Gemini via Antigravity --------- Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
1 parent
8bae79f44a
commit
6e62a7d4a2
29 files changed
+1803
-266
No files matched your search
@@ -748,7 +748,7 @@ auto HandleParseNode(Context& context, Parse::FunctionDefinitionId node_id)
|
||||
context.emitter().Emit(LocIdForDiagnostics::TokenOnly(node_id),
|
||||
MissingReturnStatement);
|
||||
} else {
|
||||
AddReturnCleanupBlock(context, node_id);
|
||||
AddReturnInstWithCleanups(context, node_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user