aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/ArithmeticHandler.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-07-26 12:12:59 +0000
committer_ov4 <ov4@ov4.org>2026-07-26 12:12:59 +0000
commitb9b7f048b0874df0f034f6b1e15e1a4ee2131475 (patch)
treeccbe2f45205c6e05ac536e6ac73e1d5830769787 /lib/CodeGen/ArithmeticHandler.cc
parentfdef2814d0d7e65573d1b666ae9bc561fa35a9f9 (diff)
refactor: centralize libc declarations, move '&' concat into StringHandler
CodeGen declares its own MallocFunc in SetupExternalFunctions and uses it for char->STRING coercion and INPUT STRING buffers, removing two bare getFunction("malloc") calls that null-deref'd if no handler happened to declare malloc first. The CHR branch reuses the char->STRING coercion path instead of a second hand-rolled heap wrapper. String concatenation moves from ArithmeticHandler (which re-declared four externs per '&' and was the LLVM 19 build-pin root cause) to StringHandler::emitConcat; ArithmeticHandler no longer touches the Module. Dead FreeFunc declarations removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ArithmeticHandler.cc')
-rw-r--r--lib/CodeGen/ArithmeticHandler.cc26
1 files changed, 0 insertions, 26 deletions
diff --git a/lib/CodeGen/ArithmeticHandler.cc b/lib/CodeGen/ArithmeticHandler.cc
index b909abc..bfee395 100644
--- a/lib/CodeGen/ArithmeticHandler.cc
+++ b/lib/CodeGen/ArithmeticHandler.cc
@@ -11,32 +11,6 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line)
bool LIsDouble = LHS->getType()->isDoubleTy();
bool RIsDouble = RHS->getType()->isDoubleTy();
- if (Op == '&') {
- Module *M = Builder.GetInsertBlock()->getParent()->getParent();
-
- FunctionType *StrLenTy = FunctionType::get(Type::getInt64Ty(Context), {PointerType::getUnqual(Context)}, false);
- FunctionCallee StrLenF = M->getOrInsertFunction("strlen", StrLenTy);
-
- FunctionType *MallocTy = FunctionType::get(PointerType::getUnqual(Context), {Type::getInt64Ty(Context)}, false);
- FunctionCallee MallocF = M->getOrInsertFunction("malloc", MallocTy);
-
- FunctionType *StrCpyTy = FunctionType::get(PointerType::getUnqual(Context), {PointerType::getUnqual(Context), PointerType::getUnqual(Context)}, false);
- FunctionCallee StrCpyF = M->getOrInsertFunction("strcpy", StrCpyTy);
- FunctionCallee StrCatF = M->getOrInsertFunction("strcat", StrCpyTy);
-
- Value *LLen = Builder.CreateCall(StrLenF, {LHS}, "llen");
- Value *RLen = Builder.CreateCall(StrLenF, {RHS}, "rlen");
- Value *TotalLen = Builder.CreateAdd(LLen, RLen, "totallen");
- Value *AllocSize = Builder.CreateAdd(TotalLen, ConstantInt::get(Type::getInt64Ty(Context), 1), "allocsize");
-
- Value *NewStr = Builder.CreateCall(MallocF, {AllocSize}, "concat_str");
-
- Builder.CreateCall(StrCpyF, {NewStr, LHS});
- Builder.CreateCall(StrCatF, {NewStr, RHS});
-
- return NewStr;
- }
-
if (Op == '/') {
Value *LVal = LHS;
Value *RVal = RHS;