[clang] [clang][bytecode] Add an assertion in initScope() op (PR #189972)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 08:55:52 PDT 2026


https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/189972

>From b75ab09f41f11d7c410e3694c9aa41bef4d5a619 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Wed, 1 Apr 2026 16:58:41 +0200
Subject: [PATCH] [clang][bytecode] Add an assertion in initScope() op

I've run into a problem in a branch lately that would've benefitted from
this assertion.
---
 clang/lib/AST/ByteCode/InterpFrame.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp
index 0d429e773f88f..6fd3d73e2d909 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -97,6 +97,7 @@ void InterpFrame::initScope(unsigned Idx) {
     return;
 
   for (auto &Local : Func->getScope(Idx).locals()) {
+    assert(!localBlock(Local.Offset)->isInitialized());
     localBlock(Local.Offset)->invokeCtor();
   }
 }
@@ -114,6 +115,7 @@ void InterpFrame::enableLocal(unsigned Idx) {
 
 void InterpFrame::destroy(unsigned Idx) {
   for (auto &Local : Func->getScope(Idx).locals_reverse()) {
+    assert(localBlock(Local.Offset)->isInitialized());
     S.deallocate(localBlock(Local.Offset));
   }
 }



More information about the cfe-commits mailing list