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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user