diff options
author | Lang Hames <lhames@gmail.com> | 2016-03-25 17:33:32 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2016-03-25 17:33:32 +0000 |
commit | f9878c54ae64816b411a998b54191fd6de119780 (patch) | |
tree | 8933a165a267cf3912a87a1b577f8301eec3a628 /llvm/docs/tutorial | |
parent | 9e964f3728b148ac26bdb80ae0d1c00eff34fa7b (diff) | |
download | bcm5719-llvm-f9878c54ae64816b411a998b54191fd6de119780.tar.gz bcm5719-llvm-f9878c54ae64816b411a998b54191fd6de119780.zip |
[Kaleidoscope] Fix 'Error' name clashes.
llvm-svn: 264426
Diffstat (limited to 'llvm/docs/tutorial')
-rw-r--r-- | llvm/docs/tutorial/LangImpl6.rst | 18 | ||||
-rw-r--r-- | llvm/docs/tutorial/LangImpl7.rst | 14 |
2 files changed, 16 insertions, 16 deletions
diff --git a/llvm/docs/tutorial/LangImpl6.rst b/llvm/docs/tutorial/LangImpl6.rst index 827cd392eff..5a77d6dcd72 100644 --- a/llvm/docs/tutorial/LangImpl6.rst +++ b/llvm/docs/tutorial/LangImpl6.rst @@ -176,7 +176,7 @@ user-defined operator, we need to parse it: switch (CurTok) { default: - return ErrorP("Expected function name in prototype"); + return LogErrorP("Expected function name in prototype"); case tok_identifier: FnName = IdentifierStr; Kind = 0; @@ -185,7 +185,7 @@ user-defined operator, we need to parse it: case tok_binary: getNextToken(); if (!isascii(CurTok)) - return ErrorP("Expected binary operator"); + return LogErrorP("Expected binary operator"); FnName = "binary"; FnName += (char)CurTok; Kind = 2; @@ -194,7 +194,7 @@ user-defined operator, we need to parse it: // Read the precedence if present. if (CurTok == tok_number) { if (NumVal < 1 || NumVal > 100) - return ErrorP("Invalid precedecnce: must be 1..100"); + return LogErrorP("Invalid precedecnce: must be 1..100"); BinaryPrecedence = (unsigned)NumVal; getNextToken(); } @@ -202,20 +202,20 @@ user-defined operator, we need to parse it: } 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 ')'. // Verify right number of names for operator. if (Kind && ArgNames.size() != Kind) - return ErrorP("Invalid number of operands for operator"); + return LogErrorP("Invalid number of operands for operator"); return llvm::make_unique<PrototypeAST>(FnName, std::move(ArgNames), Kind != 0, BinaryPrecedence); @@ -403,7 +403,7 @@ operator code above with: switch (CurTok) { default: - return ErrorP("Expected function name in prototype"); + return LogErrorP("Expected function name in prototype"); case tok_identifier: FnName = IdentifierStr; Kind = 0; @@ -412,7 +412,7 @@ operator code above with: case tok_unary: getNextToken(); if (!isascii(CurTok)) - return ErrorP("Expected unary operator"); + return LogErrorP("Expected unary operator"); FnName = "unary"; FnName += (char)CurTok; Kind = 1; @@ -435,7 +435,7 @@ unary operators. It looks like this: Function *F = TheModule->getFunction(std::string("unary")+Opcode); if (!F) - return ErrorV("Unknown unary operator"); + return LogErrorV("Unknown unary operator"); return Builder.CreateCall(F, OperandV, "unop"); } diff --git a/llvm/docs/tutorial/LangImpl7.rst b/llvm/docs/tutorial/LangImpl7.rst index aa8d86c9424..5d536bf8572 100644 --- a/llvm/docs/tutorial/LangImpl7.rst +++ b/llvm/docs/tutorial/LangImpl7.rst @@ -359,7 +359,7 @@ from the stack slot: // Look this variable up in the function. Value *V = NamedValues[Name]; if (!V) - return ErrorV("Unknown variable name"); + return LogErrorV("Unknown variable name"); // Load the value. return Builder.CreateLoad(V, Name.c_str()); @@ -578,7 +578,7 @@ implement codegen for the assignment operator. This looks like: // Assignment requires the LHS to be an identifier. VariableExprAST *LHSE = dynamic_cast<VariableExprAST*>(LHS.get()); if (!LHSE) - return ErrorV("destination of '=' must be a variable"); + return LogErrorV("destination of '=' must be a variable"); Unlike the rest of the binary operators, our assignment operator doesn't follow the "emit LHS, emit RHS, do computation" model. As such, it is @@ -597,7 +597,7 @@ allowed. // Look up the name. Value *Variable = NamedValues[LHSE->getName()]; if (!Variable) - return ErrorV("Unknown variable name"); + return LogErrorV("Unknown variable name"); Builder.CreateStore(Val, Variable); return Val; @@ -703,7 +703,7 @@ do is add it as a primary expression: 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: @@ -732,7 +732,7 @@ Next we define ParseVarExpr: // At least one variable name is required. if (CurTok != tok_identifier) - return Error("expected identifier after var"); + return LogError("expected identifier after var"); The first part of this code parses the list of identifier/expr pairs into the local ``VarNames`` vector. @@ -759,7 +759,7 @@ into the local ``VarNames`` vector. getNextToken(); // eat the ','. if (CurTok != tok_identifier) - return Error("expected identifier list after var"); + return LogError("expected identifier list after var"); } Once all the variables are parsed, we then parse the body and create the @@ -769,7 +769,7 @@ AST node: // At this point, we have to have 'in'. if (CurTok != tok_in) - return Error("expected 'in' keyword after 'var'"); + return LogError("expected 'in' keyword after 'var'"); getNextToken(); // eat 'in'. auto Body = ParseExpression(); |