[docs] Kaleidoscope Tutorial Chapter 7 - base class Value* used for AllocaInst for assignment expression (#202101)

Eariler in this chapther, the value type of `NamedValues` was changed to
`AllocaInst*`, and so did all other occurs for example in
`VariableExprAST` and `ForExprAST`.


6f8a363a48/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst (L321-L324)

However, the newly added assignment expression is still using `Value*`
as the type for LHS. Although `Value` is the base class of `AllocaInst`
therefore the code compiles and works well, it's better to keep it
consistent
This commit is contained in:
Fan Mo 2026-06-12 03:22:50 -05:00 committed by GitHub
parent 630f30ca57
commit dbaa5e601c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -600,11 +600,11 @@ allowed.
return nullptr;
// Look up the name.
Value *Variable = NamedValues[LHSE->getName()];
if (!Variable)
AllocaInst *Alloca = NamedValues[LHSE->getName()];
if (!Alloca)
return LogErrorV("Unknown variable name");
Builder->CreateStore(Val, Variable);
Builder->CreateStore(Val, Alloca);
return Val;
}
...

View file

@ -791,11 +791,11 @@ Value *BinaryExprAST::codegen() {
return nullptr;
// Look up the name.
Value *Variable = NamedValues[LHSE->getName()];
if (!Variable)
AllocaInst *Alloca = NamedValues[LHSE->getName()];
if (!Alloca)
return LogErrorV("Unknown variable name");
Builder->CreateStore(Val, Variable);
Builder->CreateStore(Val, Alloca);
return Val;
}