https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/219874
Call deallocate() here directly instead of iterating the scope again in `InterpFrame::destroy()`. >From ef03c504f51174611b2ca3c9fc25ef8074e6ecc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sun, 30 Aug 2026 19:38:34 +0200 Subject: [PATCH] Destroy --- clang/lib/AST/ByteCode/Interp.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 896b2ab4494e7..258720981c4fb 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -3045,19 +3045,25 @@ bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind, bool Fatal) { return false; } +// Destroy one scope: deallocate all local variables of the scope and diagnose +// out-of-lifetime destroys. bool Destroy(InterpState &S, CodePtr OpPC, uint32_t I) { assert(S.Current->getFunction()); - // FIXME: We iterate the scope once here and then again in the destroy() call - // below. for (auto &Local : S.Current->getFunction()->getScope(I).locals_reverse()) { - if (!S.Current->getLocalBlock(Local.Offset)->isInitialized()) + Block *LocalBlock = S.Current->getLocalBlock(Local.Offset); + + if (!LocalBlock->isInitialized()) continue; - const Pointer &Ptr = S.Current->getLocalPointer(Local.Offset); - if (Ptr.getLifetime() == Lifetime::Ended) + + if (LocalBlock->getBlockDesc<InlineDescriptor>().LifeState == + Lifetime::Ended) { + const Pointer Ptr = S.Current->getLocalPointer(Local.Offset); return diagnoseOutOfLifetimeDestroy(S, OpPC, Ptr); + } + + S.deallocate(LocalBlock); } - S.Current->destroy(I); return true; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
