From 1749b2b4a3e55db7c9bed95376f99b7f07932b49 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 26 Jul 2026 12:15:33 +0000 Subject: refactor: drop per-type micro handlers and the parallel NamedValues map Integer/Real/Boolean/CharHandler carried only five one-line LLVM API wrappers (now inlined at their call sites in CodeGen.cc) plus dead emitDeclare methods that violated the documented two-table lock-step invariant. StringHandler::emitDeclare (also dead) and its NamedValues reference go too. With the dead writers gone, NamedValues held no information not already in Symbols[].Storage, so the parallel map is removed: getNamedValue reads Symbols, ArrayHandler/FunctionGen take one table, and function bodies save/restore a single map. Behavior unchanged. Co-Authored-By: Claude Fable 5 --- lib/CodeGen/StringHandler.cc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'lib/CodeGen/StringHandler.cc') diff --git a/lib/CodeGen/StringHandler.cc b/lib/CodeGen/StringHandler.cc index 56b5aea..463bf96 100644 --- a/lib/CodeGen/StringHandler.cc +++ b/lib/CodeGen/StringHandler.cc @@ -6,9 +6,8 @@ using namespace llvm; using namespace cps; -StringHandler::StringHandler(LLVMContext &Ctx, IRBuilder<> &B, llvm::Module &M, - std::map &NV) - : Context(Ctx), Builder(B), Module(M), NamedValues(NV) { +StringHandler::StringHandler(LLVMContext &Ctx, IRBuilder<> &B, llvm::Module &M) + : Context(Ctx), Builder(B), Module(M) { setupExternalFunctions(); } @@ -34,16 +33,6 @@ void StringHandler::setupExternalFunctions() { ToLowerFunc = Module.getOrInsertFunction("tolower", CharCaseType); } -void StringHandler::emitDeclare(const std::string &Name) { - Function *TheFunction = Builder.GetInsertBlock()->getParent(); - IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); - AllocaInst *Alloca = TmpB.CreateAlloca(PointerType::getUnqual(Context), nullptr, Name); - - Value *EmptyStr = createLiteral(""); - Builder.CreateStore(EmptyStr, Alloca); - NamedValues[Name] = Alloca; -} - Value *StringHandler::createLiteral(const std::string &Val) { return Builder.CreateGlobalStringPtr(Val); } -- cgit v1.3.1-4-g156e