From dc645a36aaade7087ade574cefe69ce7bb29753e Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 09:09:03 +0000 Subject: refactor(diag): file-qualified diagnostic locations Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/FunctionGen.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/CodeGen/FunctionGen.cc') diff --git a/lib/CodeGen/FunctionGen.cc b/lib/CodeGen/FunctionGen.cc index 59e9bbe..b66b55a 100644 --- a/lib/CodeGen/FunctionGen.cc +++ b/lib/CodeGen/FunctionGen.cc @@ -1,3 +1,4 @@ +#include "cps/Diagnostics.h" #include "cps/FunctionGen.h" #include "cps/CodeGen.h" #include "cps/ExceptionHandler.h" @@ -30,7 +31,7 @@ void FunctionGen::reportError(const char *Fmt, ...) { va_start(Args, Fmt); fprintf(stderr, "error: "); vfprintf(stderr, Fmt, Args); - if (DiagnosticLine) fprintf(stderr, " at line %d", DiagnosticLine); + if (DiagnosticLine) fprintf(stderr, "%s", lineSuffix(DiagnosticLine).c_str()); fprintf(stderr, "\n"); va_end(Args); HadError = true; @@ -258,10 +259,10 @@ static Value *GenerateCall(llvm::Module &Module, ExceptionHandler &Exceptions, const std::string &CalleeName, const std::vector &Args, - bool &HadError) { + bool &HadError, int DiagnosticLine) { Function *CalleeF = Module.getFunction(CalleeName); if (!CalleeF) { - fprintf(stderr, "error: Call to undefined function %s\n", CalleeName.c_str()); + sourceDiagnostic(DiagnosticLine, "error: Call to undefined function %s\n", CalleeName.c_str()); HadError = true; return nullptr; } @@ -275,7 +276,7 @@ static Value *GenerateCall(llvm::Module &Module, llvm::Value *FunctionGen::emitCall(const std::string &Callee, const std::vector &Args) { const FuncSig *Sig = getSignature(Callee); - return GenerateCall(Module, Exceptions, Sig ? Sig->Name : Callee, Args, HadError); + return GenerateCall(Module, Exceptions, Sig ? Sig->Name : Callee, Args, HadError, DiagnosticLine); } void FunctionGen::emitReturn(ReturnStmtAST *Ret, llvm::Value *RetVal) { -- cgit v1.3.1-4-g156e