kaleidoscope: add missing check in the FunctionAST::codegen (#76322)

kaleidoscope chapter 03 explanation has this function redefine check,
but it was missing in the code sample.

Signed-off-by: amila <amila.15@cse.mrt.ac.lk>
This commit is contained in:
Amila Senadheera 2026-03-09 14:59:35 +04:00 committed by GitHub
parent 4994bcef13
commit 56fe9097fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -490,6 +490,9 @@ Function *FunctionAST::codegen() {
if (!TheFunction)
return nullptr;
if (!TheFunction->empty())
return (Function *)LogErrorV("Function cannot be redefined.");
// Create a new basic block to start insertion into.
BasicBlock *BB = BasicBlock::Create(*TheContext, "entry", TheFunction);
Builder->SetInsertPoint(BB);