[PATCH] D34444: Teach codegen to work in incremental processing mode.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 27 03:21:42 PDT 2017


v.g.vassilev updated this revision to Diff 112813.
v.g.vassilev added a comment.

Type& name -> Type &name.


https://reviews.llvm.org/D34444

Files:
  include/clang/CodeGen/ModuleBuilder.h
  lib/CodeGen/ModuleBuilder.cpp


Index: lib/CodeGen/ModuleBuilder.cpp
===================================================================
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -119,6 +119,14 @@
       return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition));
     }
 
+    llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C,
+                              const CodeGenOptions &CGO) {
+      assert(!M && "Replacing existing Module?");
+      M.reset(new llvm::Module(ModuleName, C));
+      Initialize(*Ctx);
+      return M.get();
+    }
+
     void Initialize(ASTContext &Context) override {
       Ctx = &Context;
 
@@ -317,6 +325,11 @@
            ->GetAddrOfGlobal(global, isForDefinition);
 }
 
+llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName,
+                                         llvm::LLVMContext &C) {
+   return static_cast<CodeGeneratorImpl*>(this)->StartModule(ModuleName, C);
+}
+
 CodeGenerator *clang::CreateLLVMCodeGen(
     DiagnosticsEngine &Diags, llvm::StringRef ModuleName,
     const HeaderSearchOptions &HeaderSearchOpts,
Index: include/clang/CodeGen/ModuleBuilder.h
===================================================================
--- include/clang/CodeGen/ModuleBuilder.h
+++ include/clang/CodeGen/ModuleBuilder.h
@@ -84,6 +84,11 @@
   ///   code generator will schedule the entity for emission if a
   ///   definition has been registered with this code generator.
   llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition);
+
+  /// Create a new \c llvm::Module after calling HandleTranslationUnit. This
+  /// enable codegen in interactive processing environments.
+  llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C,
+                            const CodeGenOptions &CGO);
 };
 
 /// CreateLLVMCodeGen - Create a CodeGenerator instance.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34444.112813.patch
Type: text/x-patch
Size: 1879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170827/2d0eb5d1/attachment.bin>


More information about the cfe-commits mailing list