Skip to content

Commit 811e6c5

Browse files
Axel-Naumanndevajithvs
authored andcommitted
Provide (possibly updated) CodegenOpts to StartModule.
1 parent 5929c66 commit 811e6c5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clang/include/clang/CodeGen/ModuleBuilder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class CodeGenerator : public ASTConsumer {
101101
/// enable codegen in interactive processing environments.
102102
llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C);
103103

104+
llvm::Module* StartModule(llvm::StringRef ModuleName,
105+
llvm::LLVMContext& C,
106+
const CodeGenOptions& CGO);
107+
104108
void forgetGlobal(llvm::GlobalValue* GV);
105109
};
106110

clang/lib/CodeGen/ModuleBuilder.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace clang {
3636
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS; // Only used for debug info.
3737
const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
3838
const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
39-
const CodeGenOptions &CodeGenOpts;
39+
CodeGenOptions CodeGenOpts; // Intentionally copied in.
4040

4141
unsigned HandlingTopLevelDecls;
4242

@@ -261,6 +261,13 @@ namespace clang {
261261
return M.get();
262262
}
263263

264+
llvm::Module *StartModule(llvm::StringRef ModuleName,
265+
llvm::LLVMContext& C,
266+
const CodeGenOptions& CGO) {
267+
CodeGenOpts = CGO;
268+
return StartModule(ModuleName, C);
269+
}
270+
264271
void forgetGlobal(llvm::GlobalValue* GV) {
265272
for (auto I = Builder->ConstantStringMap.begin(),
266273
E = Builder->ConstantStringMap.end(); I != E; ++I) {
@@ -487,6 +494,12 @@ llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName,
487494
return static_cast<CodeGeneratorImpl*>(this)->StartModule(ModuleName, C);
488495
}
489496

497+
llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName,
498+
llvm::LLVMContext& C,
499+
const CodeGenOptions& CGO) {
500+
return static_cast<CodeGeneratorImpl*>(this)->StartModule(ModuleName, C, CGO);
501+
}
502+
490503
void CodeGenerator::forgetGlobal(llvm::GlobalValue* GV) {
491504
static_cast<CodeGeneratorImpl*>(this)->forgetGlobal(GV);
492505
}

0 commit comments

Comments
 (0)