[Orc][Kaleidoscope] Remove dead AST map in SessionContext.
[oota-llvm.git] / examples / Kaleidoscope / Orc / fully_lazy / toy.cpp
index f29a6f52f189d57913023e0fee24d524e2cf8db3..56123bb41e3612a3c956dc277229200e4c36650c 100644 (file)
@@ -20,7 +20,9 @@
 #include <sstream>
 #include <string>
 #include <vector>
+
 using namespace llvm;
+using namespace llvm::orc;
 
 //===----------------------------------------------------------------------===//
 // Lexer
@@ -684,7 +686,6 @@ public:
   LLVMContext& getLLVMContext() const { return Context; }
   void addPrototypeAST(std::unique_ptr<PrototypeAST> P);
   PrototypeAST* getPrototypeAST(const std::string &Name);
-  std::map<std::string, std::unique_ptr<FunctionAST>> FunctionDefs; 
 private:
   typedef std::map<std::string, std::unique_ptr<PrototypeAST>> PrototypeMap;
   LLVMContext &Context;
@@ -1236,7 +1237,7 @@ private:
     auto H = irGenStub(std::move(DefI->second));
 
     // Remove the map entry now that we're done with it.
-    Session.FunctionDefs.erase(DefI);
+    FunctionDefs.erase(DefI);
 
     // Return the address of the stub.
     return findMangledSymbolIn(H, Name).getAddress();
@@ -1280,11 +1281,11 @@ private:
     //
     //   The update action will update FunctionBodyPointer to point at the newly
     // compiled function.
-    CallbackInfo.setCompileAction(
-      [this, Fn = std::shared_ptr<FunctionAST>(std::move(FnAST))](){
-        auto H = addModule(IRGen(Session, *Fn));
-        return findSymbolIn(H, Fn->Proto->Name).getAddress();
-      });
+    std::shared_ptr<FunctionAST> Fn = std::move(FnAST);
+    CallbackInfo.setCompileAction([this, Fn]() {
+      auto H = addModule(IRGen(Session, *Fn));
+      return findSymbolIn(H, Fn->Proto->Name).getAddress();
+    });
     CallbackInfo.setUpdateAction(
       CompileCallbacks.getLocalFPUpdater(H, Mangle(BodyPtrName)));