diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-02-24 04:25:59 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-02-24 04:25:59 +0000 |
commit | b114a1de0ae06cc586b94b6359924c8632f069f9 (patch) | |
tree | 029a086c68bab60a277405e45fbf72e375a494ba /lib/Frontend/ChainedIncludesSource.cpp | |
parent | bf25ca0250067c7692af95be112f00b874914e6c (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230305 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ChainedIncludesSource.cpp')
-rw-r--r-- | lib/Frontend/ChainedIncludesSource.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Frontend/ChainedIncludesSource.cpp b/lib/Frontend/ChainedIncludesSource.cpp index cb260b4f4c..1ecc0bfc6b 100644 --- a/lib/Frontend/ChainedIncludesSource.cpp +++ b/lib/Frontend/ChainedIncludesSource.cpp @@ -156,11 +156,13 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource( &Clang->getPreprocessor()); Clang->createASTContext(); - SmallVector<char, 256> serialAST; - llvm::raw_svector_ostream OS(serialAST); - auto consumer = - llvm::make_unique<PCHGenerator>(Clang->getPreprocessor(), "-", nullptr, - /*isysroot=*/"", &OS); + auto consumer = llvm::make_unique<PCHGenerator>(Clang->getPreprocessor(), + "-", nullptr, /*isysroot=*/""); + SmallVectorImpl<char> *serialAST; + consumer->RegisterSerializationFinishedCallback( + [&](SmallVectorImpl<char> *Buf){ + serialAST = Buf; + }); Clang->getASTContext().setASTMutationListener( consumer->GetASTMutationListener()); Clang->setASTConsumer(std::move(consumer)); @@ -197,7 +199,9 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource( ParseAST(Clang->getSema()); Clang->getDiagnosticClient().EndSourceFile(); - SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(OS.str())); + SerialBufs.push_back(llvm::MemoryBuffer:: + getMemBufferCopy(StringRef(serialAST->data(), serialAST->size()))); + serialAST->clear(); source->CIs.push_back(Clang.release()); } |