aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/GeneratePCH.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-02-24 04:25:59 +0000
committerAdrian Prantl <aprantl@apple.com>2015-02-24 04:25:59 +0000
commitfc360dc30be41b7ea941ae39fd8a847b6e0263c5 (patch)
treea1ff1d6476ea33713c9ed4d5e18575690322f9d5 /clang/lib/Serialization/GeneratePCH.cpp
parentc109102ecb80c06375688d374fdc17c04cd7d562 (diff)
downloadllvm-fc360dc30be41b7ea941ae39fd8a847b6e0263c5.zip
llvm-fc360dc30be41b7ea941ae39fd8a847b6e0263c5.tar.gz
llvm-fc360dc30be41b7ea941ae39fd8a847b6e0263c5.tar.bz2
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
Diffstat (limited to 'clang/lib/Serialization/GeneratePCH.cpp')
-rw-r--r--clang/lib/Serialization/GeneratePCH.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index b5031fd..0cd01dc 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -19,7 +19,6 @@
#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;
@@ -28,10 +27,11 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP,
StringRef OutputFile,
clang::Module *Module,
StringRef isysroot,
- raw_ostream *OS, bool AllowASTWithErrors)
+ bool AllowASTWithErrors)
: PP(PP), OutputFile(OutputFile), Module(Module),
- isysroot(isysroot.str()), Out(OS),
- SemaPtr(nullptr), Stream(Buffer), Writer(Stream),
+ isysroot(isysroot.str()),
+ SemaPtr(nullptr), Stream(Buffer),
+ Writer(Stream),
AllowASTWithErrors(AllowASTWithErrors),
HasEmittedPCH(false) {
}
@@ -52,14 +52,8 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
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();
+ if (SerializationFinishedCallback)
+ SerializationFinishedCallback(&Buffer);
HasEmittedPCH = true;
}