From bfe020bfa91640e7a6f1a516dc752fa754249088 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 21 Oct 2026 06:00:55 +0000 Subject: feat(codegen): support explicit template arguments Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/ExpressionGen.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/ExpressionGen.cc') diff --git a/lib/CodeGen/ExpressionGen.cc b/lib/CodeGen/ExpressionGen.cc index 15d0fe3..3377a39 100644 --- a/lib/CodeGen/ExpressionGen.cc +++ b/lib/CodeGen/ExpressionGen.cc @@ -150,7 +150,7 @@ Value *CodeGen::emitExpr(ExprAST *Expr) { return emitMemberCall(Call); if (auto *Call = dynamic_cast(Expr)) - return emitCall(Call->getCallee(), Call->getArgs(), Call->getLine()); + return emitCall(Call->getCallee(), Call->getArgs(), Call->getLine(), &Call->getTemplateArgs()); if (auto *D = dynamic_cast(Expr)) { LValueInfo LV; @@ -192,10 +192,15 @@ Value *CodeGen::emitBinaryOp(int Op, Value *L, const TypeInfo *LT, } Value *CodeGen::emitCall(const std::string &Callee, - const std::vector> &ArgExprs, int Line) { + const std::vector> &ArgExprs, int Line, + const std::vector *Explicit) { SaveAndRestore Location(DiagnosticLine, Line ? Line : DiagnosticLine); std::string Name = Callee; if (const BuiltinInfo *B = findBuiltin(Name)) { + if (Explicit && !Explicit->empty()) { + reportError("Explicit template arguments are not allowed on builtin %s", B->Name); + return nullptr; + } Name = B->Name; if (ArgExprs.size() != B->Arity) { reportError("%s expects %u arg%s", B->Name, B->Arity, B->Arity == 1 ? "" : "s"); @@ -230,7 +235,7 @@ Value *CodeGen::emitCall(const std::string &Callee, } std::vector Args; - const FuncSig *Sig = resolveCall(Name, ArgExprs); + const FuncSig *Sig = resolveCall(Name, ArgExprs, Explicit); if (!Sig || !marshalCallArgs(*Sig, ArgExprs, Line, Args)) return nullptr; return FuncGen->emitCall(*Sig, Args); } -- cgit v1.3.1-4-g156e