summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-03-25 17:41:26 +0000
committerLang Hames <lhames@gmail.com>2016-03-25 17:41:26 +0000
commit5d045a903115ff154560a844eda3bddb85d9115c (patch)
treebfa2e7f5e56a6350c3b1dc9b04ddddfb2bc93c14 /llvm/examples/Kaleidoscope/Chapter5/toy.cpp
parentf9878c54ae64816b411a998b54191fd6de119780 (diff)
downloadbcm5719-llvm-5d045a903115ff154560a844eda3bddb85d9115c.tar.gz
bcm5719-llvm-5d045a903115ff154560a844eda3bddb85d9115c.zip
[Kaleidoscope] Rename Error -> LogError in Chapters 2-5.
This keeps the naming consistent with Chapters 6-8, where Error was renamed to LogError in r264426 to avoid clashes with the new Error class in libSupport. llvm-svn: 264427
Diffstat (limited to 'llvm/examples/Kaleidoscope/Chapter5/toy.cpp')
-rw-r--r--llvm/examples/Kaleidoscope/Chapter5/toy.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
index afcb28ae247..d54c6696266 100644
--- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -238,14 +238,14 @@ static int GetTokPrecedence() {
return TokPrec;
}
-/// Error* - These are little helper functions for error handling.
-std::unique_ptr<ExprAST> Error(const char *Str) {
+/// LogError* - These are little helper functions for error handling.
+std::unique_ptr<ExprAST> LogError(const char *Str) {
fprintf(stderr, "Error: %s\n", Str);
return nullptr;
}
-std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
- Error(Str);
+std::unique_ptr<PrototypeAST> LogErrorP(const char *Str) {
+ LogError(Str);
return nullptr;
}
@@ -266,7 +266,7 @@ static std::unique_ptr<ExprAST> ParseParenExpr() {
return nullptr;
if (CurTok != ')')
- return Error("expected ')'");
+ return LogError("expected ')'");
getNextToken(); // eat ).
return V;
}
@@ -296,7 +296,7 @@ static std::unique_ptr<ExprAST> ParseIdentifierExpr() {
break;
if (CurTok != ',')
- return Error("Expected ')' or ',' in argument list");
+ return LogError("Expected ')' or ',' in argument list");
getNextToken();
}
}
@@ -317,7 +317,7 @@ static std::unique_ptr<ExprAST> ParseIfExpr() {
return nullptr;
if (CurTok != tok_then)
- return Error("expected then");
+ return LogError("expected then");
getNextToken(); // eat the then
auto Then = ParseExpression();
@@ -325,7 +325,7 @@ static std::unique_ptr<ExprAST> ParseIfExpr() {
return nullptr;
if (CurTok != tok_else)
- return Error("expected else");
+ return LogError("expected else");
getNextToken();
@@ -342,20 +342,20 @@ static std::unique_ptr<ExprAST> ParseForExpr() {
getNextToken(); // eat the for.
if (CurTok != tok_identifier)
- return Error("expected identifier after for");
+ return LogError("expected identifier after for");
std::string IdName = IdentifierStr;
getNextToken(); // eat identifier.
if (CurTok != '=')
- return Error("expected '=' after for");
+ return LogError("expected '=' after for");
getNextToken(); // eat '='.
auto Start = ParseExpression();
if (!Start)
return nullptr;
if (CurTok != ',')
- return Error("expected ',' after for start value");
+ return LogError("expected ',' after for start value");
getNextToken();
auto End = ParseExpression();
@@ -372,7 +372,7 @@ static std::unique_ptr<ExprAST> ParseForExpr() {
}
if (CurTok != tok_in)
- return Error("expected 'in' after for");
+ return LogError("expected 'in' after for");
getNextToken(); // eat 'in'.
auto Body = ParseExpression();
@@ -392,7 +392,7 @@ static std::unique_ptr<ExprAST> ParseForExpr() {
static std::unique_ptr<ExprAST> ParsePrimary() {
switch (CurTok) {
default:
- return Error("unknown token when expecting an expression");
+ return LogError("unknown token when expecting an expression");
case tok_identifier:
return ParseIdentifierExpr();
case tok_number:
@@ -458,19 +458,19 @@ static std::unique_ptr<ExprAST> ParseExpression() {
/// ::= id '(' id* ')'
static std::unique_ptr<PrototypeAST> ParsePrototype() {
if (CurTok != tok_identifier)
- return ErrorP("Expected function name in prototype");
+ return LogErrorP("Expected function name in prototype");
std::string FnName = IdentifierStr;
getNextToken();
if (CurTok != '(')
- return ErrorP("Expected '(' in prototype");
+ return LogErrorP("Expected '(' in prototype");
std::vector<std::string> ArgNames;
while (getNextToken() == tok_identifier)
ArgNames.push_back(IdentifierStr);
if (CurTok != ')')
- return ErrorP("Expected ')' in prototype");
+ return LogErrorP("Expected ')' in prototype");
// success.
getNextToken(); // eat ')'.
@@ -518,8 +518,8 @@ static std::unique_ptr<legacy::FunctionPassManager> TheFPM;
static std::unique_ptr<KaleidoscopeJIT> TheJIT;
static std::map<std::string, std::unique_ptr<PrototypeAST>> FunctionProtos;
-Value *ErrorV(const char *Str) {
- Error(Str);
+Value *LogErrorV(const char *Str) {
+ LogError(Str);
return nullptr;
}
@@ -546,7 +546,7 @@ Value *VariableExprAST::codegen() {
// Look this variable up in the function.
Value *V = NamedValues[Name];
if (!V)
- return ErrorV("Unknown variable name");
+ return LogErrorV("Unknown variable name");
return V;
}
@@ -569,7 +569,7 @@ Value *BinaryExprAST::codegen() {
return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()),
"booltmp");
default:
- return ErrorV("invalid binary operator");
+ return LogErrorV("invalid binary operator");
}
}
@@ -577,11 +577,11 @@ Value *CallExprAST::codegen() {
// Look up the name in the global module table.
Function *CalleeF = getFunction(Callee);
if (!CalleeF)
- return ErrorV("Unknown function referenced");
+ return LogErrorV("Unknown function referenced");
// If argument mismatch error.
if (CalleeF->arg_size() != Args.size())
- return ErrorV("Incorrect # arguments passed");
+ return LogErrorV("Incorrect # arguments passed");
std::vector<Value *> ArgsV;
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
OpenPOWER on IntegriCloud