diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 08:36:19 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 08:36:19 +0000 |
| commit | 6a3b31af5dbb22749e6d5a1cad9dfaab6863b615 (patch) | |
| tree | 58d2e7d956c8c605599a3f760040234ec2556d29 /include/cps/ExceptionHandler.h | |
| parent | abd56ef20bc8061bbecec29edd1301d324c2cb34 (diff) | |
feat(classes): destroy stack objects during exception unwinding
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps/ExceptionHandler.h')
| -rw-r--r-- | include/cps/ExceptionHandler.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/cps/ExceptionHandler.h b/include/cps/ExceptionHandler.h index 5c846ae..a2dc5d0 100644 --- a/include/cps/ExceptionHandler.h +++ b/include/cps/ExceptionHandler.h @@ -2,6 +2,7 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Module.h" #include <map> +#include <functional> #include <vector> namespace cps { @@ -17,8 +18,16 @@ class ExceptionHandler { struct FunctionState { std::vector<Handler> Handlers; unsigned CatchDepth = 0; + bool HasCleanups = false; }; + struct CleanupPoint { + llvm::Instruction *Before; + FunctionState State; + bool Unwinding; + }; + std::map<llvm::Function *, std::vector<CleanupPoint>> CleanupPoints; + bool FillingUnwind = false; llvm::LLVMContext &Context; llvm::IRBuilder<> &Builder; llvm::Module &Module; @@ -38,7 +47,10 @@ public: llvm::AllocaInst *popHandler(); void beginCatch(llvm::AllocaInst *Exception); void endCatch(); - void emitReturnCleanup(); + llvm::Instruction *emitReturnCleanup(); + void enableCleanups(llvm::Function *F); + void recordExit(llvm::Instruction *Before, bool Unwinding = false); + void fillCleanups(llvm::Function *F, const std::function<void()> &Destroy); llvm::Value *emitCall(llvm::FunctionCallee Callee, llvm::ArrayRef<llvm::Value *> Args, const llvm::Twine &Name = ""); |
