summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ModuleBuilder.cpp
diff options
context:
space:
mode:
authorVassil Vassilev <v.g.vassilev@gmail.com>2017-08-27 10:58:03 +0000
committerVassil Vassilev <v.g.vassilev@gmail.com>2017-08-27 10:58:03 +0000
commit4d54e543abd5d0a8b0a321f8c292252f4895693a (patch)
treeaf6d54cfab48072ed076c120fe677d04b30eb2e5 /clang/lib/CodeGen/ModuleBuilder.cpp
parent34ca7168aea46a14f5d613a16152095ed3a25593 (diff)
downloadbcm5719-llvm-4d54e543abd5d0a8b0a321f8c292252f4895693a.tar.gz
bcm5719-llvm-4d54e543abd5d0a8b0a321f8c292252f4895693a.zip
D34444: Teach codegen to work in incremental processing mode.
When isIncrementalProcessingEnabled is on we might want to produce multiple llvm::Modules. This patch allows the clients to start a new llvm::Module, allowing CodeGen to continue working after a HandleEndOfTranslationUnit call. This should give the necessary facilities to write a unittest for D34059. As discussed in the review this is meant to give us a way to proceed forward in our efforts to upstream our interpreter-related patches. The design of this will likely change soon. llvm-svn: 311843
Diffstat (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp')
-rw-r--r--clang/lib/CodeGen/ModuleBuilder.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp
index fc642850d60..8aa9bfb421b 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -119,6 +119,14 @@ namespace {
return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition));
}
+ llvm::Module *StartModule(llvm::StringRef ModuleName,
+ llvm::LLVMContext &C) {
+ 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 @@ llvm::Constant *CodeGenerator::GetAddrOfGlobal(GlobalDecl global,
->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,
OpenPOWER on IntegriCloud