diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-27 14:00:16 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-27 14:00:16 +0000 |
| commit | 3d7d1d7cf8685f0d9230cd89d06017869da1c6d8 (patch) | |
| tree | 3b5ea9523e94f4193eb1a28b237f41d81a2cde03 /lib/CodeGen/ConstructorGen.cc | |
| parent | a91bd145008432fb8c5d91d94ab6f50473a277f5 (diff) | |
feat(library)!: replace #LIB with __LIB source regions
Track library mode by original source line, including deferred template bodies
and automatic object cleanup. Update call lines from ordinary code and migrate
the embedded standard library to PP_DEFINE __LIB.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ConstructorGen.cc')
| -rw-r--r-- | lib/CodeGen/ConstructorGen.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/CodeGen/ConstructorGen.cc b/lib/CodeGen/ConstructorGen.cc index b029385..da89f59 100644 --- a/lib/CodeGen/ConstructorGen.cc +++ b/lib/CodeGen/ConstructorGen.cc @@ -284,7 +284,7 @@ size_t CodeGen::registerStackObject(Value *Addr, const std::string &TypeName, in Count = Entry.CreateAlloca(Entry.getInt64Ty(), nullptr, "object_count"); Entry.CreateStore(Entry.getInt64(0), Count); } - StackObjects.push_back({Addr, TypeName, Alive, Count, Line}); + StackObjects.push_back({Addr, TypeName, Alive, Count, Line, CurrentUnit}); // This DECLARE can execute repeatedly, including after a backward loop edge. emitStackObjectCleanup(StackObjects.back()); return StackObjects.size() - 1; @@ -298,6 +298,8 @@ void CodeGen::activateStackObject(size_t Index, Value *Count) { } void CodeGen::emitStackObjectCleanup(const StackObject &Object) { + size_t SavedUnit = CurrentUnit; + selectUnit(Object.OwnerUnit); auto *F = Builder->GetInsertBlock()->getParent(); auto *Destroy = BasicBlock::Create(*TheContext, "destroy_object", F); auto *Done = BasicBlock::Create(*TheContext, "destroyed_object", F); @@ -339,6 +341,7 @@ void CodeGen::emitStackObjectCleanup(const StackObject &Object) { } Builder->CreateBr(Done); Builder->SetInsertPoint(Done); + selectUnit(SavedUnit); } void CodeGen::finishStackObjects(Function *F) { |
