summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2016-05-19 01:08:04 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2016-05-19 01:08:04 +0000
commitf981ec4582a4c4e8411cda3bd311c461afcd96f6 (patch)
treeeee989a4464a13603ae1adc817a7304286a66505 /llvm/examples/Kaleidoscope/Chapter7/toy.cpp
parentb2bcd95aab74ffd6a0ea4115335a992587f10d19 (diff)
downloadbcm5719-llvm-f981ec4582a4c4e8411cda3bd311c461afcd96f6.tar.gz
bcm5719-llvm-f981ec4582a4c4e8411cda3bd311c461afcd96f6.zip
Fix some Clang-tidy modernize-use-bool-literals and Include What You Use warnings in examples; other minor fixes.
Differential revision: http://reviews.llvm.org/D20397 llvm-svn: 270008
Diffstat (limited to 'llvm/examples/Kaleidoscope/Chapter7/toy.cpp')
-rw-r--r--llvm/examples/Kaleidoscope/Chapter7/toy.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index 18401de5266..fffbfba286c 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -1,19 +1,31 @@
+#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Analysis/Passes.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/TargetSelect.h"
+#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/GVN.h"
+#include "../include/KaleidoscopeJIT.h"
+#include <cassert>
#include <cctype>
+#include <cstdint>
#include <cstdio>
+#include <cstdlib>
#include <map>
+#include <memory>
#include <string>
+#include <utility>
#include <vector>
-#include "../include/KaleidoscopeJIT.h"
using namespace llvm;
using namespace llvm::orc;
@@ -338,7 +350,7 @@ static std::unique_ptr<ExprAST> ParseIdentifierExpr() {
getNextToken(); // eat (
std::vector<std::unique_ptr<ExprAST>> Args;
if (CurTok != ')') {
- while (1) {
+ while (true) {
if (auto Arg = ParseExpression())
Args.push_back(std::move(Arg));
else
@@ -446,7 +458,7 @@ static std::unique_ptr<ExprAST> ParseVarExpr() {
if (CurTok != tok_identifier)
return LogError("expected identifier after var");
- while (1) {
+ while (true) {
std::string Name = IdentifierStr;
getNextToken(); // eat identifier.
@@ -530,7 +542,7 @@ static std::unique_ptr<ExprAST> ParseUnary() {
static std::unique_ptr<ExprAST> ParseBinOpRHS(int ExprPrec,
std::unique_ptr<ExprAST> LHS) {
// If this is a binop, find its precedence.
- while (1) {
+ while (true) {
int TokPrec = GetTokPrecedence();
// If this is a binop that binds at least as tightly as the current binop,
@@ -706,8 +718,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr,
- VarName.c_str());
+ return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName);
}
Value *NumberExprAST::codegen() {
@@ -1132,7 +1143,6 @@ static void HandleTopLevelExpression() {
// Evaluate a top-level expression into an anonymous function.
if (auto FnAST = ParseTopLevelExpr()) {
if (FnAST->codegen()) {
-
// JIT the module containing the anonymous expression, keeping a handle so
// we can free it later.
auto H = TheJIT->addModule(std::move(TheModule));
@@ -1158,7 +1168,7 @@ static void HandleTopLevelExpression() {
/// top ::= definition | external | expression | ';'
static void MainLoop() {
- while (1) {
+ while (true) {
fprintf(stderr, "ready> ");
switch (CurTok) {
case tok_eof:
OpenPOWER on IntegriCloud