summaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.h
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-13 12:25:29 +0200
committerGitHub <noreply@github.com>2025-04-13 12:25:29 +0200
commit09588e93bbe486ce782de9fba604f5cd184ec446 (patch)
tree3d53506c44082f40aa43325260f6b363498f9613 /clang/lib/AST/ByteCode/Compiler.h
parentbeac727e48346efb84558696fb080b1bbd07e234 (diff)
[clang][bytecode] Fix an inconsistency with loop condition jumps (#135530)
When emitting the jump for e.g. a for loop condition, we used to jump out of the CondScope, leaving the scope initialized, because we skipped the corresponding Destroy opcode. If that loop was in a loop itself, that outer loop could then iterate once more, leading to us initializing a scope that was still initialized. Fix this by also destroying the scope after the EndLabel.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.h')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h
index 256e91772888..858957367d85 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -531,9 +531,10 @@ public:
if (!Idx)
return true;
+ // NB: We are *not* resetting Idx here as to allow multiple
+ // calls to destroyLocals().
bool Success = this->emitDestructors(E);
this->Ctx->emitDestroy(*Idx, E);
- this->Idx = std::nullopt;
return Success;
}