r248053 - Simplify the interface of PCHContainerGenerator and friends
Adrian Prantl via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 15:11:00 PDT 2015
Author: adrian
Date: Fri Sep 18 17:10:59 2015
New Revision: 248053
URL: http://llvm.org/viewvc/llvm-project?rev=248053&view=rev
Log:
Simplify the interface of PCHContainerGenerator and friends
by passing in a CompilerInstance instead of all its individual members.
NFC.
Modified:
cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
Modified: cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h?rev=248053&r1=248052&r2=248053&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h (original)
+++ cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h Fri Sep 18 17:10:59 2015
@@ -23,10 +23,9 @@ class ObjectFilePCHContainerWriter : pub
/// PCHGenerator that produces a wrapper file format
/// that also contains full debug info for the module.
std::unique_ptr<ASTConsumer> CreatePCHContainerGenerator(
- DiagnosticsEngine &Diags, const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO, const TargetOptions &TO,
- const LangOptions &LO, const std::string &MainFileName,
- const std::string &OutputFileName, llvm::raw_pwrite_stream *OS,
+ DiagnosticsEngine &Diags, const CompilerInstance &CI,
+ const std::string &MainFileName, const std::string &OutputFileName,
+ llvm::raw_pwrite_stream *OS,
std::shared_ptr<PCHBuffer> Buffer) const override;
};
Modified: cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHContainerOperations.h?rev=248053&r1=248052&r2=248053&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHContainerOperations.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHContainerOperations.h Fri Sep 18 17:10:59 2015
@@ -27,10 +27,7 @@ namespace clang {
class ASTConsumer;
class CodeGenOptions;
class DiagnosticsEngine;
-class HeaderSearchOptions;
-class LangOptions;
-class PreprocessorOptions;
-class TargetOptions;
+class CompilerInstance;
struct PCHBuffer {
bool IsComplete;
@@ -49,11 +46,9 @@ public:
/// PCHGenerator that produces a wrapper file format containing a
/// serialized AST bitstream.
virtual std::unique_ptr<ASTConsumer> CreatePCHContainerGenerator(
- DiagnosticsEngine &Diags, const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO, const TargetOptions &TO,
- const LangOptions &LO, const std::string &MainFileName,
- const std::string &OutputFileName, llvm::raw_pwrite_stream *OS,
- std::shared_ptr<PCHBuffer> Buffer) const = 0;
+ DiagnosticsEngine &Diags, const CompilerInstance &CI,
+ const std::string &MainFileName, const std::string &OutputFileName,
+ llvm::raw_pwrite_stream *OS, std::shared_ptr<PCHBuffer> Buffer) const = 0;
};
/// This abstract interface provides operations for unwrapping
@@ -78,10 +73,9 @@ class RawPCHContainerWriter : public PCH
/// Return an ASTConsumer that can be chained with a
/// PCHGenerator that writes the module to a flat file.
std::unique_ptr<ASTConsumer> CreatePCHContainerGenerator(
- DiagnosticsEngine &Diags, const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO, const TargetOptions &TO,
- const LangOptions &LO, const std::string &MainFileName,
- const std::string &OutputFileName, llvm::raw_pwrite_stream *OS,
+ DiagnosticsEngine &Diags, const CompilerInstance &CI,
+ const std::string &MainFileName, const std::string &OutputFileName,
+ llvm::raw_pwrite_stream *OS,
std::shared_ptr<PCHBuffer> Buffer) const override;
};
Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=248053&r1=248052&r2=248053&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Sep 18 17:10:59 2015
@@ -18,6 +18,7 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/BackendUtil.h"
#include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/CompilerInstance.h"
#include "clang/Serialization/ASTWriter.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Bitcode/BitstreamReader.h"
@@ -115,15 +116,15 @@ class PCHContainerGenerator : public AST
};
public:
- PCHContainerGenerator(DiagnosticsEngine &diags,
- const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO, const TargetOptions &TO,
- const LangOptions &LO, const std::string &MainFileName,
+ PCHContainerGenerator(DiagnosticsEngine &diags, const CompilerInstance &CI,
+ const std::string &MainFileName,
const std::string &OutputFileName,
raw_pwrite_stream *OS,
std::shared_ptr<PCHBuffer> Buffer)
- : Diags(diags), Ctx(nullptr), HeaderSearchOpts(HSO), PreprocessorOpts(PPO),
- TargetOpts(TO), LangOpts(LO), OS(OS), Buffer(Buffer) {
+ : Diags(diags), Ctx(nullptr), HeaderSearchOpts(CI.getHeaderSearchOpts()),
+ PreprocessorOpts(CI.getPreprocessorOpts()),
+ TargetOpts(CI.getTargetOpts()), LangOpts(CI.getLangOpts()), OS(OS),
+ Buffer(Buffer) {
// The debug info output isn't affected by CodeModel and
// ThreadModel, but the backend expects them to be nonempty.
CodeGenOpts.CodeModel = "default";
@@ -252,13 +253,11 @@ public:
std::unique_ptr<ASTConsumer>
ObjectFilePCHContainerWriter::CreatePCHContainerGenerator(
- DiagnosticsEngine &Diags, const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO, const TargetOptions &TO,
- const LangOptions &LO, const std::string &MainFileName,
- const std::string &OutputFileName, llvm::raw_pwrite_stream *OS,
- std::shared_ptr<PCHBuffer> Buffer) const {
- return llvm::make_unique<PCHContainerGenerator>(
- Diags, HSO, PPO, TO, LO, MainFileName, OutputFileName, OS, Buffer);
+ DiagnosticsEngine &Diags, const CompilerInstance &CI,
+ const std::string &MainFileName, const std::string &OutputFileName,
+ llvm::raw_pwrite_stream *OS, std::shared_ptr<PCHBuffer> Buffer) const {
+ return llvm::make_unique<PCHContainerGenerator>(Diags, CI, MainFileName,
+ OutputFileName, OS, Buffer);
}
void ObjectFilePCHContainerReader::ExtractPCH(
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=248053&r1=248052&r2=248053&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Sep 18 17:10:59 2015
@@ -92,11 +92,8 @@ GeneratePCHAction::CreateASTConsumer(Com
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
Consumers.push_back(llvm::make_unique<PCHGenerator>(
CI.getPreprocessor(), OutputFile, nullptr, Sysroot, Buffer));
- Consumers.push_back(
- CI.getPCHContainerWriter().CreatePCHContainerGenerator(
- CI.getDiagnostics(), CI.getHeaderSearchOpts(),
- CI.getPreprocessorOpts(), CI.getTargetOpts(), CI.getLangOpts(),
- InFile, OutputFile, OS, Buffer));
+ Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
+ CI.getDiagnostics(), CI, InFile, OutputFile, OS, Buffer));
return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
@@ -140,11 +137,8 @@ GenerateModuleAction::CreateASTConsumer(
CI.getPreprocessor(), OutputFile, Module, Sysroot, Buffer,
/*AllowASTWithErrors*/false,
/*IncludeTimestamps*/+CI.getFrontendOpts().BuildingImplicitModule));
- Consumers.push_back(
- CI.getPCHContainerWriter().CreatePCHContainerGenerator(
- CI.getDiagnostics(), CI.getHeaderSearchOpts(),
- CI.getPreprocessorOpts(), CI.getTargetOpts(), CI.getLangOpts(),
- InFile, OutputFile, OS, Buffer));
+ Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
+ CI.getDiagnostics(), CI, InFile, OutputFile, OS, Buffer));
return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
Modified: cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHContainerOperations.cpp?rev=248053&r1=248052&r2=248053&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHContainerOperations.cpp Fri Sep 18 17:10:59 2015
@@ -27,13 +27,7 @@ class RawPCHContainerGenerator : public
raw_pwrite_stream *OS;
public:
- RawPCHContainerGenerator(DiagnosticsEngine &Diags,
- const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO,
- const TargetOptions &TO, const LangOptions &LO,
- const std::string &MainFileName,
- const std::string &OutputFileName,
- llvm::raw_pwrite_stream *OS,
+ RawPCHContainerGenerator(llvm::raw_pwrite_stream *OS,
std::shared_ptr<PCHBuffer> Buffer)
: Buffer(Buffer), OS(OS) {}
@@ -54,13 +48,10 @@ public:
} // anonymous namespace
std::unique_ptr<ASTConsumer> RawPCHContainerWriter::CreatePCHContainerGenerator(
- DiagnosticsEngine &Diags, const HeaderSearchOptions &HSO,
- const PreprocessorOptions &PPO, const TargetOptions &TO,
- const LangOptions &LO, const std::string &MainFileName,
- const std::string &OutputFileName, llvm::raw_pwrite_stream *OS,
- std::shared_ptr<PCHBuffer> Buffer) const {
- return llvm::make_unique<RawPCHContainerGenerator>(
- Diags, HSO, PPO, TO, LO, MainFileName, OutputFileName, OS, Buffer);
+ DiagnosticsEngine &Diags, const CompilerInstance &CI,
+ const std::string &MainFileName, const std::string &OutputFileName,
+ llvm::raw_pwrite_stream *OS, std::shared_ptr<PCHBuffer> Buffer) const {
+ return llvm::make_unique<RawPCHContainerGenerator>(OS, Buffer);
}
void RawPCHContainerReader::ExtractPCH(
More information about the cfe-commits
mailing list