[PATCH] D145545: [clang][Interp] Fix local variable (destructor) management in loop bodies
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 29 03:17:13 PDT 2023
tbaeder marked an inline comment as done.
tbaeder added inline comments.
================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:338
+ this->emitDestructors();
+ this->Ctx->emitDestroy(*Idx, SourceInfo{});
+ }
----------------
aaron.ballman wrote:
> Should we be setting `Idx = std::nullopt;` after this so that the `LocalScope` destructor does not also emit a destroy for the same `Idx`?
Yeah I think that makes sense, thanks.
================
Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:199-200
+bool ByteCodeStmtGen<Emitter>::visitUnscopedCompoundStmt(const Stmt *S) {
+ if (isa<NullStmt>(S))
+ return true;
+
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > Errr, I'm surprised it isn't UB to call this with anything but a `CompoundStmt` given the function name.
> Yeah, I'm not too happy about that either. I'll see what I can do.
Renamed it to `visitLoopBody` and added a doc comment explaining its purpose.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145545/new/
https://reviews.llvm.org/D145545
More information about the cfe-commits
mailing list