From b9b7f048b0874df0f034f6b1e15e1a4ee2131475 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 26 Jul 2026 12:12:59 +0000 Subject: 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 --- lib/CodeGen/ArrayHandler.cc | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lib/CodeGen/ArrayHandler.cc') diff --git a/lib/CodeGen/ArrayHandler.cc b/lib/CodeGen/ArrayHandler.cc index aa7230a..af16692 100644 --- a/lib/CodeGen/ArrayHandler.cc +++ b/lib/CodeGen/ArrayHandler.cc @@ -32,11 +32,6 @@ void ArrayHandler::setupExternalFunctions() { FunctionType *MallocType = FunctionType::get(PointerType::getUnqual(*TheContext), MallocArgs, false); MallocFunc = TheModule->getOrInsertFunction("malloc", MallocType); - - std::vector FreeArgs; - FreeArgs.push_back(PointerType::getUnqual(*TheContext)); - FunctionType *FreeType = FunctionType::get(Type::getVoidTy(*TheContext), FreeArgs, false); - FreeFunc = TheModule->getOrInsertFunction("free", FreeType); } const ArrayMetadata *ArrayHandler::getMetadata(const std::string &Name) const { -- cgit v1.3.1-4-g156e