diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-02-25 01:31:45 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-02-25 01:31:45 +0000 |
commit | 8bf7af3de80fe746cb39fe03b19e6e736183c1d8 (patch) | |
tree | 3631796942b357f01d486a34631e918d05db7b86 /clang/lib/Frontend/ASTUnit.cpp | |
parent | b6396eaef90c9f3dee42d8af918b93b6628b9f4a (diff) | |
download | bcm5719-llvm-8bf7af3de80fe746cb39fe03b19e6e736183c1d8.tar.gz bcm5719-llvm-8bf7af3de80fe746cb39fe03b19e6e736183c1d8.zip |
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.
This reapplies r230044 with a fixed configure+make build and updated
dependencies and testcase requirements. Over the last iteration this
version adds
- missing target requirements for testcases that specify an x86 triple,
- a missing clangCodeGen.a dependency to libClang.a in the make build.
rdar://problem/19104245
llvm-svn: 230423
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index bfb1efe3522..58a5f980085 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -914,13 +914,20 @@ class PrecompilePreambleConsumer : public PCHGenerator { unsigned &Hash; std::vector<Decl *> TopLevelDecls; PrecompilePreambleAction *Action; + raw_ostream *Out; + SmallVectorImpl<char> *SerializedASTBuffer; public: PrecompilePreambleConsumer(ASTUnit &Unit, PrecompilePreambleAction *Action, const Preprocessor &PP, StringRef isysroot, raw_ostream *Out) - : PCHGenerator(PP, "", nullptr, isysroot, Out, /*AllowASTWithErrors=*/true), - Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action) { + : PCHGenerator(PP, "", nullptr, isysroot, /*AllowASTWithErrors=*/true), + Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action), + Out(Out) { + RegisterSerializationFinishedCallback( + [&](SmallVectorImpl<char> *Buf){ + SerializedASTBuffer = Buf; + }); Hash = 0; } @@ -941,6 +948,13 @@ public: void HandleTranslationUnit(ASTContext &Ctx) override { PCHGenerator::HandleTranslationUnit(Ctx); if (hasEmittedPCH()) { + // Write the generated bitstream to "Out". + Out->write((char *)&SerializedASTBuffer->front(), + SerializedASTBuffer->size()); + // Make sure it hits disk now. + Out->flush(); + SerializedASTBuffer->clear(); + // Translate the top-level declarations we captured during // parsing into declaration IDs in the precompiled // preamble. This will allow us to deserialize those top-level |