diff options
| author | Lang Hames <lhames@gmail.com> | 2015-08-19 18:32:58 +0000 |
|---|---|---|
| committer | Lang Hames <lhames@gmail.com> | 2015-08-19 18:32:58 +0000 |
| commit | 596aec96aca7e8b3b88168c07f4d8fb029e68a17 (patch) | |
| tree | 498bdea19633604b86093c33e07e70189b79fb4a | |
| parent | cb23639d392011704611721c0e5ec7a1c7af38c3 (diff) | |
| download | bcm5719-llvm-596aec96aca7e8b3b88168c07f4d8fb029e68a17.tar.gz bcm5719-llvm-596aec96aca7e8b3b88168c07f4d8fb029e68a17.zip | |
[Kaleidoscope] More inter-chapter diff reduction.
llvm-svn: 245474
| -rw-r--r-- | llvm/docs/tutorial/LangImpl3.rst | 4 | ||||
| -rw-r--r-- | llvm/examples/Kaleidoscope/Chapter3/toy.cpp | 4 | ||||
| -rw-r--r-- | llvm/examples/Kaleidoscope/Chapter4/toy.cpp | 4 | ||||
| -rw-r--r-- | llvm/examples/Kaleidoscope/Chapter5/toy.cpp | 4 | ||||
| -rw-r--r-- | llvm/examples/Kaleidoscope/Chapter6/toy.cpp | 1 |
5 files changed, 12 insertions, 5 deletions
diff --git a/llvm/docs/tutorial/LangImpl3.rst b/llvm/docs/tutorial/LangImpl3.rst index a2d23e7bcf9..d80140ef241 100644 --- a/llvm/docs/tutorial/LangImpl3.rst +++ b/llvm/docs/tutorial/LangImpl3.rst @@ -131,7 +131,9 @@ are all uniqued together and shared. For this reason, the API uses the Value *VariableExprAST::Codegen() { // Look this variable up in the function. Value *V = NamedValues[Name]; - return V ? V : ErrorV("Unknown variable name"); + if (!V) + ErrorV("Unknown variable name"); + return V; } References to variables are also quite simple using LLVM. In the simple diff --git a/llvm/examples/Kaleidoscope/Chapter3/toy.cpp b/llvm/examples/Kaleidoscope/Chapter3/toy.cpp index 29914aa0331..cb4f75f7917 100644 --- a/llvm/examples/Kaleidoscope/Chapter3/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter3/toy.cpp @@ -398,7 +398,9 @@ Value *NumberExprAST::Codegen() { Value *VariableExprAST::Codegen() { // Look this variable up in the function. Value *V = NamedValues[Name]; - return V ? V : ErrorV("Unknown variable name"); + if (!V) + return ErrorV("Unknown variable name"); + return V; } Value *BinaryExprAST::Codegen() { diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp index eba0ab1f27d..9b0d2ecf67c 100644 --- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp @@ -642,7 +642,9 @@ Value *NumberExprAST::Codegen() { Value *VariableExprAST::Codegen() { // Look this variable up in the function. Value *V = NamedValues[Name]; - return V ? V : ErrorV("Unknown variable name"); + if (!V) + return ErrorV("Unknown variable name"); + return V; } Value *BinaryExprAST::Codegen() { diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp index c191d61d562..da7a81c6776 100644 --- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp @@ -532,7 +532,9 @@ Value *NumberExprAST::Codegen() { Value *VariableExprAST::Codegen() { // Look this variable up in the function. Value *V = NamedValues[Name]; - return V ? V : ErrorV("Unknown variable name"); + if (!V) + return ErrorV("Unknown variable name"); + return V; } Value *BinaryExprAST::Codegen() { diff --git a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp index 87048bb2da4..b4e8397e9e6 100644 --- a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp @@ -626,7 +626,6 @@ Value *VariableExprAST::Codegen() { Value *V = NamedValues[Name]; if (!V) return ErrorV("Unknown variable name"); - return V; } |

