From abd56ef20bc8061bbecec29edd1301d324c2cb34 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 08:34:42 +0000 Subject: feat(classes): destroy stack objects at scope exit Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/CodeGen.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/CodeGen/CodeGen.cc') diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc index 68dec5c..8117434 100644 --- a/lib/CodeGen/CodeGen.cc +++ b/lib/CodeGen/CodeGen.cc @@ -74,6 +74,10 @@ CodeGen::CodeGen() { /*MakeCopy=*/P.Mode == PassMode::ByVal, *this); }); + FuncGen->setCopyRegistrar([this](Value *Addr, const std::string &TypeName, int Line) { + activateStackObject(registerStackObject(Addr, TypeName, Line, false, true)); + }); + SetupExternalFunctions(); } @@ -185,6 +189,7 @@ void CodeGen::compile(const std::vector> &Statements) { Builder->CreateRet(ConstantInt::get(*TheContext, APInt(32, 0))); } + finishStackObjects(F); auto *Exception = Exceptions->popHandler(); Builder->SetInsertPoint(UnhandledBB); Exceptions->beginCatch(Exception); -- cgit v1.3.1-4-g156e