summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-08-19 18:32:58 +0000
committerLang Hames <lhames@gmail.com>2015-08-19 18:32:58 +0000
commit596aec96aca7e8b3b88168c07f4d8fb029e68a17 (patch)
tree498bdea19633604b86093c33e07e70189b79fb4a
parentcb23639d392011704611721c0e5ec7a1c7af38c3 (diff)
downloadbcm5719-llvm-596aec96aca7e8b3b88168c07f4d8fb029e68a17.tar.gz
bcm5719-llvm-596aec96aca7e8b3b88168c07f4d8fb029e68a17.zip
[Kaleidoscope] More inter-chapter diff reduction.
llvm-svn: 245474
-rw-r--r--llvm/docs/tutorial/LangImpl3.rst4
-rw-r--r--llvm/examples/Kaleidoscope/Chapter3/toy.cpp4
-rw-r--r--llvm/examples/Kaleidoscope/Chapter4/toy.cpp4
-rw-r--r--llvm/examples/Kaleidoscope/Chapter5/toy.cpp4
-rw-r--r--llvm/examples/Kaleidoscope/Chapter6/toy.cpp1
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;
}
OpenPOWER on IntegriCloud