[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:
parent
630f30ca57
commit
dbaa5e601c
2 changed files with 6 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
...
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue