aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/GeneratePCH.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-02-24 05:14:17 +0000
committerAdrian Prantl <aprantl@apple.com>2015-02-24 05:14:17 +0000
commita39924a1f8b97a2b65765f31d7e87884541d52ec (patch)
tree33aa61a31fb088dbf006aa7f2ca7e471ae257033 /clang/lib/Serialization/GeneratePCH.cpp
parent1f6a32b3e7aa095263a5a0bbb1cc0576dce441a6 (diff)
downloadllvm-a39924a1f8b97a2b65765f31d7e87884541d52ec.zip
llvm-a39924a1f8b97a2b65765f31d7e87884541d52ec.tar.gz
llvm-a39924a1f8b97a2b65765f31d7e87884541d52ec.tar.bz2
Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230305. Off to fix another round of missing dependencies on various platforms. llvm-svn: 230309
Diffstat (limited to 'clang/lib/Serialization/GeneratePCH.cpp')
-rw-r--r--clang/lib/Serialization/GeneratePCH.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 0cd01dc..b5031fd 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -19,6 +19,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/SemaConsumer.h"
#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Support/raw_ostream.h"
#include <string>
using namespace clang;
@@ -27,11 +28,10 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP,
StringRef OutputFile,
clang::Module *Module,
StringRef isysroot,
- bool AllowASTWithErrors)
+ raw_ostream *OS, bool AllowASTWithErrors)
: PP(PP), OutputFile(OutputFile), Module(Module),
- isysroot(isysroot.str()),
- SemaPtr(nullptr), Stream(Buffer),
- Writer(Stream),
+ isysroot(isysroot.str()), Out(OS),
+ SemaPtr(nullptr), Stream(Buffer), Writer(Stream),
AllowASTWithErrors(AllowASTWithErrors),
HasEmittedPCH(false) {
}
@@ -52,8 +52,14 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
assert(SemaPtr && "No Sema?");
Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot, hasErrors);
- if (SerializationFinishedCallback)
- SerializationFinishedCallback(&Buffer);
+ // 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;
}