diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-11-18 21:57:58 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-11-18 21:57:58 +0000 |
commit | ae7ac95cc9fd34ce55b404050e523abe1a943260 (patch) | |
tree | 40c557e513ab5e7baabaeebe539190faa59620a7 /llvm/examples/Kaleidoscope/Chapter5/toy.cpp | |
parent | 09c311b9a46c72ffea99026755db046cc2b0364f (diff) | |
download | bcm5719-llvm-ae7ac95cc9fd34ce55b404050e523abe1a943260.tar.gz bcm5719-llvm-ae7ac95cc9fd34ce55b404050e523abe1a943260.zip |
[Examples] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26433
llvm-svn: 287384
Diffstat (limited to 'llvm/examples/Kaleidoscope/Chapter5/toy.cpp')
-rw-r--r-- | llvm/examples/Kaleidoscope/Chapter5/toy.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp index a080bd00cb5..568ec8de5c3 100644 --- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp @@ -16,6 +16,7 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/GVN.h" #include "../include/KaleidoscopeJIT.h" +#include <algorithm> #include <cassert> #include <cctype> #include <cstdint> @@ -121,11 +122,14 @@ static int gettok() { //===----------------------------------------------------------------------===// // Abstract Syntax Tree (aka Parse Tree) //===----------------------------------------------------------------------===// + namespace { + /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST() {} + virtual ~ExprAST() = default; + virtual Value *codegen() = 0; }; @@ -135,6 +139,7 @@ class NumberExprAST : public ExprAST { public: NumberExprAST(double Val) : Val(Val) {} + Value *codegen() override; }; @@ -144,6 +149,7 @@ class VariableExprAST : public ExprAST { public: VariableExprAST(const std::string &Name) : Name(Name) {} + Value *codegen() override; }; @@ -156,6 +162,7 @@ public: BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS, std::unique_ptr<ExprAST> RHS) : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {} + Value *codegen() override; }; @@ -168,6 +175,7 @@ public: CallExprAST(const std::string &Callee, std::vector<std::unique_ptr<ExprAST>> Args) : Callee(Callee), Args(std::move(Args)) {} + Value *codegen() override; }; @@ -179,6 +187,7 @@ public: IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then, std::unique_ptr<ExprAST> Else) : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {} + Value *codegen() override; }; @@ -193,6 +202,7 @@ public: std::unique_ptr<ExprAST> Body) : VarName(VarName), Start(std::move(Start)), End(std::move(End)), Step(std::move(Step)), Body(std::move(Body)) {} + Value *codegen() override; }; @@ -206,6 +216,7 @@ class PrototypeAST { public: PrototypeAST(const std::string &Name, std::vector<std::string> Args) : Name(Name), Args(std::move(Args)) {} + Function *codegen(); const std::string &getName() const { return Name; } }; @@ -219,8 +230,10 @@ public: FunctionAST(std::unique_ptr<PrototypeAST> Proto, std::unique_ptr<ExprAST> Body) : Proto(std::move(Proto)), Body(std::move(Body)) {} + Function *codegen(); }; + } // end anonymous namespace //===----------------------------------------------------------------------===// |