aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/GeneratePCH.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-06-20 18:53:08 +0000
committerAdrian Prantl <aprantl@apple.com>2015-06-20 18:53:08 +0000
commitbb165fb04db511d0f6927133662b74943f76cc39 (patch)
tree5c8150e9096c41f7a426c704aa4762e6420cd28e /clang/lib/Serialization/GeneratePCH.cpp
parent6ed81cbcdb6e5f07f6ac71a446d970c2db8945a5 (diff)
downloadllvm-bb165fb04db511d0f6927133662b74943f76cc39.zip
llvm-bb165fb04db511d0f6927133662b74943f76cc39.tar.gz
llvm-bb165fb04db511d0f6927133662b74943f76cc39.tar.bz2
Introduce a PCHContainerOperations interface (NFC).
A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
Diffstat (limited to 'clang/lib/Serialization/GeneratePCH.cpp')
-rw-r--r--clang/lib/Serialization/GeneratePCH.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index b5031fd..c50b3f9 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -24,16 +24,14 @@
using namespace clang;
-PCHGenerator::PCHGenerator(const Preprocessor &PP,
- StringRef OutputFile,
- clang::Module *Module,
- StringRef isysroot,
- raw_ostream *OS, bool AllowASTWithErrors)
- : PP(PP), OutputFile(OutputFile), Module(Module),
- isysroot(isysroot.str()), Out(OS),
- SemaPtr(nullptr), Stream(Buffer), Writer(Stream),
- AllowASTWithErrors(AllowASTWithErrors),
- HasEmittedPCH(false) {
+PCHGenerator::PCHGenerator(const Preprocessor &PP, StringRef OutputFile,
+ clang::Module *Module, StringRef isysroot,
+ std::shared_ptr<PCHBuffer> Buffer,
+ bool AllowASTWithErrors)
+ : PP(PP), OutputFile(OutputFile), Module(Module), isysroot(isysroot.str()),
+ SemaPtr(nullptr), Buffer(Buffer), Stream(Buffer->Data), Writer(Stream),
+ AllowASTWithErrors(AllowASTWithErrors) {
+ Buffer->IsComplete = false;
}
PCHGenerator::~PCHGenerator() {
@@ -47,21 +45,12 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
bool hasErrors = PP.getDiagnostics().hasErrorOccurred();
if (hasErrors && !AllowASTWithErrors)
return;
-
- // Emit the PCH file
+
+ // Emit the PCH file to the Buffer.
assert(SemaPtr && "No Sema?");
Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot, hasErrors);
- // Write the generated bitstream to "Out".
- Out->write((char *)&Buffer.front(), Buffer.size());
-
- // Make sure it hits disk now.
- Out->flush();
-
- // Free up some memory, in case the process is kept alive.
- Buffer.clear();
-
- HasEmittedPCH = true;
+ Buffer->IsComplete = true;
}
ASTMutationListener *PCHGenerator::GetASTMutationListener() {