diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 05:33:33 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 05:33:33 +0000 |
| commit | 4e22f464387725a5a282f3d72e11cfb694a31a5a (patch) | |
| tree | 17fed09b30633e6aae583f490a0ad9c0c95fb045 /lib/CodeGen/ExpressionGen.cc | |
| parent | 4dd85fd6ecd9a67e5c2b68380873e6e114714355 (diff) | |
feat(memory): add checked REALLOC with failure preservation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ExpressionGen.cc')
| -rw-r--r-- | lib/CodeGen/ExpressionGen.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/CodeGen/ExpressionGen.cc b/lib/CodeGen/ExpressionGen.cc index 0a24c8d..9ea79d8 100644 --- a/lib/CodeGen/ExpressionGen.cc +++ b/lib/CodeGen/ExpressionGen.cc @@ -192,6 +192,13 @@ Value *CodeGen::emitCall(const std::string &Callee, if (!Size) return nullptr; return Memory->emitAllocate(Size, Line); } + if (Name == "REALLOC") { + Value *Address = emitCoercedExpr(ArgExprs[0].get(), resolveType("C_TYPE(\"void*\")")); + if (!Address) return nullptr; + Value *Size = emitAllocationSize(ArgExprs[1].get()); + if (!Size) return nullptr; + return Memory->emitResize(Address, Size, Line); + } if (Name == "FREE") { Value *Address = emitCoercedExpr(ArgExprs[0].get(), resolveType("C_TYPE(\"void*\")")); if (!Address) return nullptr; |
