Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.

In order to produce debug info for clang modules CGDebugInfo it needs
access to macros passed on the command line and the isysroot.

llvm-svn: 241035
This commit is contained in:
Adrian Prantl
2015-06-30 02:26:03 +00:00
parent 08a388ba8f
commit e74f525bc9
7 changed files with 66 additions and 26 deletions

View File

@@ -32,6 +32,8 @@ namespace {
DiagnosticsEngine &Diags;
std::unique_ptr<const llvm::DataLayout> TD;
ASTContext *Ctx;
const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
const CodeGenOptions CodeGenOpts; // Intentionally copied in.
unsigned HandlingTopLevelDecls;
@@ -56,12 +58,15 @@ namespace {
SmallVector<CXXMethodDecl *, 8> DeferredInlineMethodDefinitions;
public:
CodeGeneratorImpl(DiagnosticsEngine &diags, const std::string& ModuleName,
const CodeGenOptions &CGO, llvm::LLVMContext& C,
CodeGeneratorImpl(DiagnosticsEngine &diags, const std::string &ModuleName,
const HeaderSearchOptions &HSO,
const PreprocessorOptions &PPO, const CodeGenOptions &CGO,
llvm::LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr)
: Diags(diags), Ctx(nullptr), CodeGenOpts(CGO), HandlingTopLevelDecls(0),
CoverageInfo(CoverageInfo),
M(new llvm::Module(ModuleName, C)) {}
: Diags(diags), Ctx(nullptr), HeaderSearchOpts(HSO),
PreprocessorOpts(PPO), CodeGenOpts(CGO), HandlingTopLevelDecls(0),
CoverageInfo(CoverageInfo),
M(new llvm::Module(ModuleName, C)) {}
~CodeGeneratorImpl() override {
// There should normally not be any leftover inline method definitions.
@@ -97,7 +102,10 @@ namespace {
M->setDataLayout(Ctx->getTargetInfo().getTargetDescription());
TD.reset(
new llvm::DataLayout(Ctx->getTargetInfo().getTargetDescription()));
Builder.reset(new CodeGen::CodeGenModule(Context, CodeGenOpts, *M, *TD,
Builder.reset(new CodeGen::CodeGenModule(Context,
HeaderSearchOpts,
PreprocessorOpts,
CodeGenOpts, *M, *TD,
Diags, CoverageInfo));
for (size_t i = 0, e = CodeGenOpts.DependentLibraries.size(); i < e; ++i)
@@ -236,10 +244,11 @@ namespace {
void CodeGenerator::anchor() { }
CodeGenerator *clang::CreateLLVMCodeGen(DiagnosticsEngine &Diags,
const std::string& ModuleName,
const CodeGenOptions &CGO,
llvm::LLVMContext& C,
CoverageSourceInfo *CoverageInfo) {
return new CodeGeneratorImpl(Diags, ModuleName, CGO, C, CoverageInfo);
CodeGenerator *clang::CreateLLVMCodeGen(
DiagnosticsEngine &Diags, const std::string &ModuleName,
const HeaderSearchOptions &HeaderSearchOpts,
const PreprocessorOptions &PreprocessorOpts, const CodeGenOptions &CGO,
llvm::LLVMContext &C, CoverageSourceInfo *CoverageInfo) {
return new CodeGeneratorImpl(Diags, ModuleName, HeaderSearchOpts,
PreprocessorOpts, CGO, C, CoverageInfo);
}