summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ChainedIncludesSource.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-02-20 19:44:52 +0000
committerAdrian Prantl <aprantl@apple.com>2015-02-20 19:44:52 +0000
commitc4091aa74e030ca5a447b7d119a4d46d6be17de2 (patch)
tree84c43c5614a3f0f5747b7cc8f80cbd7341e1e9c5 /clang/lib/Frontend/ChainedIncludesSource.cpp
parent7035178aebc91d0ed99759919865d6745ac052e2 (diff)
downloadbcm5719-llvm-c4091aa74e030ca5a447b7d119a4d46d6be17de2.tar.gz
bcm5719-llvm-c4091aa74e030ca5a447b7d119a4d46d6be17de2.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. rdar://problem/19104245 llvm-svn: 230044
Diffstat (limited to 'clang/lib/Frontend/ChainedIncludesSource.cpp')
-rw-r--r--clang/lib/Frontend/ChainedIncludesSource.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp
index cb260b4f4c6..1ecc0bfc6b4 100644
--- a/clang/lib/Frontend/ChainedIncludesSource.cpp
+++ b/clang/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());
}
OpenPOWER on IntegriCloud