r241035 - Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.
Eric Christopher via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 16:40:12 PDT 2015
Actually using the right list now...
On Mon, Sep 28, 2015 at 4:39 PM Eric Christopher <echristo at gmail.com> wrote:
> Hi Adrian,
>
>
>> : 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)) {
>> }
>>
>>
>>
> Sorry to do archaeology on this thread, but I see you added these as "new"
> here, but didn't use delete on them a few lines down. Any reason?
>
> Also, might want to make them use unique_ptr while you're at it :)
>
> -eric
>
>
>> 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);
>> }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150928/e582d084/attachment-0001.html>
More information about the cfe-commits
mailing list