[Kaleidoscope] More inter-chapter diff reduction.
authorLang Hames <lhames@gmail.com>
Wed, 19 Aug 2015 18:32:58 +0000 (18:32 +0000)
committerLang Hames <lhames@gmail.com>
Wed, 19 Aug 2015 18:32:58 +0000 (18:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245474 91177308-0d34-0410-b5e6-96231b3b80d8

docs/tutorial/LangImpl3.rst
examples/Kaleidoscope/Chapter3/toy.cpp
examples/Kaleidoscope/Chapter4/toy.cpp
examples/Kaleidoscope/Chapter5/toy.cpp
examples/Kaleidoscope/Chapter6/toy.cpp

index a2d23e7bcf9aabdb81adde7b5b570374be7e6a34..d80140ef241b1b724bff64f34334a5d7e99e749b 100644 (file)
@@ -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
index 29914aa03311cece6fe6f2ae8e5461ace2c688b3..cb4f75f7917debd5dd7ee00c94a49f00163740bf 100644 (file)
@@ -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() {
index eba0ab1f27da369a3b43ff8836f25acafde22fe5..9b0d2ecf67c602ae29dcedad186f436d0f4ee33e 100644 (file)
@@ -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() {
index c191d61d562ce20b2ce813d8b12d10c0899616fa..da7a81c6776f833e6708784c1428bc74b39cdcc9 100644 (file)
@@ -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() {
index 87048bb2da40d33c6ecf7e148bed43d26c63887b..b4e8397e9e6a01d4286352c29cfb780ae55ac0b2 100644 (file)
@@ -626,7 +626,6 @@ Value *VariableExprAST::Codegen() {
   Value *V = NamedValues[Name];
   if (!V)
     return ErrorV("Unknown variable name");
-
   return V;
 }