r241035 - Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.
Adrian Prantl
aprantl at apple.com
Mon Jun 29 19:26:03 PDT 2015
Author: adrian
Date: Mon Jun 29 21:26:03 2015
New Revision: 241035
URL: http://llvm.org/viewvc/llvm-project?rev=241035&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Jun 29 21:26:03 2015
@@ -37,9 +37,11 @@ namespace clang {
class ASTContext;
class CXXRecordDecl;
class CodeGenOptions;
+class CoverageSourceInfo;
class DiagnosticsEngine;
+class HeaderSearchOptions;
class ObjCMethodDecl;
-class CoverageSourceInfo;
+class PreprocessorOptions;
namespace CodeGen {
class CGFunctionInfo;
@@ -74,6 +76,8 @@ private:
/// CodeGenModule and otherwise not used. More specifically, it is
/// not used in ABI type generation, so none of the options matter.
CodeGenOptions *CGO;
+ HeaderSearchOptions *HSO;
+ PreprocessorOptions *PPO;
/// The CodeGenModule we use get to the CodeGenTypes object.
CodeGen::CodeGenModule *CGM;
Modified: cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ModuleBuilder.h?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/ModuleBuilder.h (original)
+++ cfe/trunk/include/clang/CodeGen/ModuleBuilder.h Mon Jun 29 21:26:03 2015
@@ -26,6 +26,8 @@ namespace clang {
class DiagnosticsEngine;
class CoverageSourceInfo;
class LangOptions;
+ class HeaderSearchOptions;
+ class PreprocessorOptions;
class CodeGenOptions;
class Decl;
@@ -42,6 +44,8 @@ namespace clang {
/// the allocated CodeGenerator instance.
CodeGenerator *CreateLLVMCodeGen(DiagnosticsEngine &Diags,
const std::string &ModuleName,
+ const HeaderSearchOptions &HeaderSearchOpts,
+ const PreprocessorOptions &PreprocessorOpts,
const CodeGenOptions &CGO,
llvm::LLVMContext& C,
CoverageSourceInfo *CoverageInfo = nullptr);
Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Jun 29 21:26:03 2015
@@ -20,6 +20,8 @@
#include "CodeGenModule.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
using namespace clang;
using namespace CodeGen;
@@ -29,7 +31,10 @@ CodeGenABITypes::CodeGenABITypes(ASTCont
const llvm::DataLayout &TD,
CoverageSourceInfo *CoverageInfo)
: CGO(new CodeGenOptions),
- CGM(new CodeGen::CodeGenModule(C, *CGO, M, TD, C.getDiagnostics(),
+ HSO(new HeaderSearchOptions),
+ PPO(new PreprocessorOptions),
+ CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO,
+ M, TD, C.getDiagnostics(),
CoverageInfo)) {
}
Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Jun 29 21:26:03 2015
@@ -57,6 +57,8 @@ namespace clang {
public:
BackendConsumer(BackendAction Action, DiagnosticsEngine &Diags,
+ const HeaderSearchOptions &HeaderSearchOpts,
+ const PreprocessorOptions &PPOpts,
const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts,
const LangOptions &LangOpts, bool TimePasses,
@@ -66,7 +68,8 @@ namespace clang {
: Diags(Diags), Action(Action), CodeGenOpts(CodeGenOpts),
TargetOpts(TargetOpts), LangOpts(LangOpts), AsmOutStream(OS),
Context(nullptr), LLVMIRGeneration("LLVM IR Generation Time"),
- Gen(CreateLLVMCodeGen(Diags, InFile, CodeGenOpts, C, CoverageInfo)),
+ Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
+ CodeGenOpts, C, CoverageInfo)),
LinkModule(LinkModule) {
llvm::TimePassesIsEnabled = TimePasses;
}
@@ -667,7 +670,8 @@ CodeGenAction::CreateASTConsumer(Compile
std::unique_ptr<PPCallbacks>(CoverageInfo));
}
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
- BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(),
+ BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
+ CI.getPreprocessorOpts(), CI.getCodeGenOpts(), CI.getTargetOpts(),
CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
LinkModuleToUse, OS, *VMContext, CoverageInfo));
BEConsumer = Result.get();
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 29 21:26:03 2015
@@ -74,16 +74,19 @@ static CGCXXABI *createCXXABI(CodeGenMod
llvm_unreachable("invalid C++ ABI kind");
}
-CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
- llvm::Module &M, const llvm::DataLayout &TD,
+CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO,
+ const PreprocessorOptions &PPO,
+ const CodeGenOptions &CGO, llvm::Module &M,
+ const llvm::DataLayout &TD,
DiagnosticsEngine &diags,
CoverageSourceInfo *CoverageInfo)
- : Context(C), LangOpts(C.getLangOpts()), CodeGenOpts(CGO), TheModule(M),
- Diags(diags), TheDataLayout(TD), Target(C.getTargetInfo()),
- ABI(createCXXABI(*this)), VMContext(M.getContext()), TBAA(nullptr),
- TheTargetCodeGenInfo(nullptr), Types(*this), VTables(*this),
- ObjCRuntime(nullptr), OpenCLRuntime(nullptr), OpenMPRuntime(nullptr),
- CUDARuntime(nullptr), DebugInfo(nullptr), ARCData(nullptr),
+ : Context(C), LangOpts(C.getLangOpts()), HeaderSearchOpts(HSO),
+ PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
+ TheDataLayout(TD), Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
+ VMContext(M.getContext()), TBAA(nullptr), TheTargetCodeGenInfo(nullptr),
+ Types(*this), VTables(*this), ObjCRuntime(nullptr),
+ OpenCLRuntime(nullptr), OpenMPRuntime(nullptr), CUDARuntime(nullptr),
+ DebugInfo(nullptr), ARCData(nullptr),
NoObjCARCExceptionsMetadata(nullptr), RRData(nullptr), PGOReader(nullptr),
CFConstantStringClassRef(nullptr), ConstantStringClassRef(nullptr),
NSConstantStringType(nullptr), NSConcreteGlobalBlock(nullptr),
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Jun 29 21:26:03 2015
@@ -69,6 +69,8 @@ class ValueDecl;
class VarDecl;
class LangOptions;
class CodeGenOptions;
+class HeaderSearchOptions;
+class PreprocessorOptions;
class DiagnosticsEngine;
class AnnotateAttr;
class CXXDestructorDecl;
@@ -278,6 +280,8 @@ public:
private:
ASTContext &Context;
const LangOptions &LangOpts;
+ const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
+ const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
const CodeGenOptions &CodeGenOpts;
llvm::Module &TheModule;
DiagnosticsEngine &Diags;
@@ -488,7 +492,10 @@ private:
std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
public:
- CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts,
+ CodeGenModule(ASTContext &C,
+ const HeaderSearchOptions &headersearchopts,
+ const PreprocessorOptions &ppopts,
+ const CodeGenOptions &CodeGenOpts,
llvm::Module &M, const llvm::DataLayout &TD,
DiagnosticsEngine &Diags,
CoverageSourceInfo *CoverageInfo = nullptr);
@@ -600,6 +607,10 @@ public:
ASTContext &getContext() const { return Context; }
const LangOptions &getLangOpts() const { return LangOpts; }
+ const HeaderSearchOptions &getHeaderSearchOpts()
+ const { return HeaderSearchOpts; }
+ const PreprocessorOptions &getPreprocessorOpts()
+ const { return PreprocessorOpts; }
const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
llvm::Module &getModule() const { return TheModule; }
DiagnosticsEngine &getDiags() const { return Diags; }
Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=241035&r1=241034&r2=241035&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Mon Jun 29 21:26:03 2015
@@ -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);
}
More information about the cfe-commits
mailing list