diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 08:34:42 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 08:34:42 +0000 |
| commit | abd56ef20bc8061bbecec29edd1301d324c2cb34 (patch) | |
| tree | 8da9a14372a60d4df8bf58693c62c187765e7240 /lib/CodeGen/ArrayHandler.cc | |
| parent | 59e3c50bcd58130e81e1f57b21d6e57b4d4aba6d (diff) | |
feat(classes): destroy stack objects at scope exit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ArrayHandler.cc')
| -rw-r--r-- | lib/CodeGen/ArrayHandler.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/ArrayHandler.cc b/lib/CodeGen/ArrayHandler.cc index 8da6cd3..7eefc20 100644 --- a/lib/CodeGen/ArrayHandler.cc +++ b/lib/CodeGen/ArrayHandler.cc @@ -97,6 +97,10 @@ void ArrayHandler::emitArrayDeclare(ArrayDeclareStmtAST *Stmt, CodeGen &CG) { if (!CG.prepareSymbolDeclaration(Name)) return; + Function *TheFunction = Builder->GetInsertBlock()->getParent(); + AllocaInst *Alloca = CG.CreateEntryBlockAlloca(TheFunction, PointerType::getUnqual(*TheContext), Name); + size_t Lifetime = CG.registerStackObject(Alloca, ElemInfo->Name, Stmt->getLine(), true); + std::vector<Value*> Lows; std::vector<Value*> Highs; @@ -134,8 +138,6 @@ void ArrayHandler::emitArrayDeclare(ArrayDeclareStmtAST *Stmt, CodeGen &CG) { Builder->CreateCall(MemsetFunc, {Ptr, ConstantInt::get(Type::getInt32Ty(*TheContext), 0), TotalBytes}); - Function *TheFunction = Builder->GetInsertBlock()->getParent(); - AllocaInst *Alloca = CG.CreateEntryBlockAlloca(TheFunction, PointerType::getUnqual(*TheContext), Name); Builder->CreateStore(Ptr, Alloca); CG.registerSymbol(Name, Alloca, ElemInfo->Name, true); @@ -157,6 +159,7 @@ void ArrayHandler::emitArrayDeclare(ArrayDeclareStmtAST *Stmt, CodeGen &CG) { Builder->CreateBr(Loop); Builder->SetInsertPoint(Done); } + CG.activateStackObject(Lifetime, TotalElements); } void ArrayHandler::computeDimsAndMultipliers(const std::string &Name, |
