summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/examples/Kaleidoscope')
-rw-r--r--llvm/examples/Kaleidoscope/Chapter2/toy.cpp2
-rw-r--r--llvm/examples/Kaleidoscope/Chapter3/toy.cpp4
-rw-r--r--llvm/examples/Kaleidoscope/Chapter4/toy.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter5/toy.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter6/toy.cpp3
-rw-r--r--llvm/examples/Kaleidoscope/Chapter7/toy.cpp5
-rw-r--r--llvm/examples/Kaleidoscope/Chapter8/toy.cpp5
-rw-r--r--llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp12
-rw-r--r--llvm/examples/Kaleidoscope/Orc/initial/toy.cpp10
-rw-r--r--llvm/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp10
-rw-r--r--llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp12
11 files changed, 34 insertions, 35 deletions
diff --git a/llvm/examples/Kaleidoscope/Chapter2/toy.cpp b/llvm/examples/Kaleidoscope/Chapter2/toy.cpp
index 14cba32f5f9..bcba554b246 100644
--- a/llvm/examples/Kaleidoscope/Chapter2/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter2/toy.cpp
@@ -53,7 +53,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
diff --git a/llvm/examples/Kaleidoscope/Chapter3/toy.cpp b/llvm/examples/Kaleidoscope/Chapter3/toy.cpp
index 328189c1184..05697ea70a4 100644
--- a/llvm/examples/Kaleidoscope/Chapter3/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter3/toy.cpp
@@ -8,6 +8,7 @@
#include <map>
#include <string>
#include <vector>
+
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -58,7 +59,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -193,6 +194,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
+
std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
Error(Str);
return nullptr;
diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
index 8c96444ad40..4f77ec862b1 100644
--- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -65,7 +65,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -200,6 +200,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
+
std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
Error(Str);
return nullptr;
diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
index 57edf1aa845..eeca4775eeb 100644
--- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -82,7 +82,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -242,6 +242,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
+
std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
Error(Str);
return nullptr;
diff --git a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
index 0b4ef3dbb98..4d04f7e888a 100644
--- a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
@@ -90,7 +90,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -275,6 +275,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
+
std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
Error(Str);
return nullptr;
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index cf3fbdf15da..5c0094013d9 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -95,7 +95,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -294,6 +294,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
+
std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
Error(Str);
return nullptr;
@@ -703,7 +704,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
VarName.c_str());
}
diff --git a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp
index b78d901db2d..d58dadf08bb 100644
--- a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp
@@ -163,7 +163,7 @@ static int gettok() {
LastChar = advance();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -431,6 +431,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
+
std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
Error(Str);
return nullptr;
@@ -886,7 +887,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
VarName.c_str());
}
diff --git a/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp b/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
index 7e5b38cafe7..667bca46afd 100644
--- a/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
@@ -87,7 +87,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -387,7 +387,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
return ErrorU<ForExprAST>("expected '=' after for");
getNextToken(); // eat '='.
-
auto Start = ParseExpression();
if (!Start)
return nullptr;
@@ -748,7 +747,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
VarName.c_str());
}
@@ -760,7 +759,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
// Look this variable up in the function.
Value *V = C.NamedValues[Name];
- if (V == 0)
+ if (!V)
return ErrorP<Value>("Unknown variable name '" + Name + "'");
// Load the value.
@@ -960,7 +959,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
// Compute the end condition.
Value *EndCond = End->IRGen(C);
- if (EndCond == 0) return EndCond;
+ if (!EndCond) return nullptr;
// Reload, increment, and restore the alloca. This handles the case where
// the body of the loop mutates the variable.
@@ -988,7 +987,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
else
C.NamedValues.erase(VarName);
-
// for expr always returns 0.0.
return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
@@ -1236,7 +1234,7 @@ private:
RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
auto DefI = FunctionDefs.find(Name);
if (DefI == FunctionDefs.end())
- return 0;
+ return nullptr;
// Return the address of the stub.
// Take the FunctionAST out of the map.
diff --git a/llvm/examples/Kaleidoscope/Orc/initial/toy.cpp b/llvm/examples/Kaleidoscope/Orc/initial/toy.cpp
index 662c871904c..8dab73bf73a 100644
--- a/llvm/examples/Kaleidoscope/Orc/initial/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Orc/initial/toy.cpp
@@ -86,7 +86,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -386,7 +386,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
return ErrorU<ForExprAST>("expected '=' after for");
getNextToken(); // eat '='.
-
auto Start = ParseExpression();
if (!Start)
return nullptr;
@@ -747,7 +746,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
VarName.c_str());
}
@@ -759,7 +758,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
// Look this variable up in the function.
Value *V = C.NamedValues[Name];
- if (V == 0)
+ if (!V)
return ErrorP<Value>("Unknown variable name '" + Name + "'");
// Load the value.
@@ -959,7 +958,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
// Compute the end condition.
Value *EndCond = End->IRGen(C);
- if (EndCond == 0) return EndCond;
+ if (!EndCond) return nullptr;
// Reload, increment, and restore the alloca. This handles the case where
// the body of the loop mutates the variable.
@@ -987,7 +986,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
else
C.NamedValues.erase(VarName);
-
// for expr always returns 0.0.
return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
diff --git a/llvm/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp b/llvm/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
index fc71849bebb..f5a6c19614b 100644
--- a/llvm/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
@@ -86,7 +86,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -386,7 +386,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
return ErrorU<ForExprAST>("expected '=' after for");
getNextToken(); // eat '='.
-
auto Start = ParseExpression();
if (!Start)
return nullptr;
@@ -747,7 +746,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
VarName.c_str());
}
@@ -759,7 +758,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
// Look this variable up in the function.
Value *V = C.NamedValues[Name];
- if (V == 0)
+ if (!V)
return ErrorP<Value>("Unknown variable name '" + Name + "'");
// Load the value.
@@ -959,7 +958,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
// Compute the end condition.
Value *EndCond = End->IRGen(C);
- if (EndCond == 0) return EndCond;
+ if (!EndCond) return nullptr;
// Reload, increment, and restore the alloca. This handles the case where
// the body of the loop mutates the variable.
@@ -987,7 +986,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
else
C.NamedValues.erase(VarName);
-
// for expr always returns 0.0.
return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
diff --git a/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp b/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
index a1779c7e1bf..f9b972e8294 100644
--- a/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
@@ -86,7 +86,7 @@ static int gettok() {
LastChar = getchar();
} while (isdigit(LastChar) || LastChar == '.');
- NumVal = strtod(NumStr.c_str(), 0);
+ NumVal = strtod(NumStr.c_str(), nullptr);
return tok_number;
}
@@ -386,7 +386,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
return ErrorU<ForExprAST>("expected '=' after for");
getNextToken(); // eat '='.
-
auto Start = ParseExpression();
if (!Start)
return nullptr;
@@ -747,7 +746,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
VarName.c_str());
}
@@ -759,7 +758,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
// Look this variable up in the function.
Value *V = C.NamedValues[Name];
- if (V == 0)
+ if (!V)
return ErrorP<Value>("Unknown variable name '" + Name + "'");
// Load the value.
@@ -959,7 +958,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
// Compute the end condition.
Value *EndCond = End->IRGen(C);
- if (EndCond == 0) return EndCond;
+ if (!EndCond) return nullptr;
// Reload, increment, and restore the alloca. This handles the case where
// the body of the loop mutates the variable.
@@ -987,7 +986,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
else
C.NamedValues.erase(VarName);
-
// for expr always returns 0.0.
return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
@@ -1223,7 +1221,7 @@ private:
RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
auto DefI = FunctionDefs.find(Name);
if (DefI == FunctionDefs.end())
- return 0;
+ return nullptr;
// Take the FunctionAST out of the map.
auto FnAST = std::move(DefI->second);
OpenPOWER on IntegriCloud