From b59bc1a528d5b3f4b65a52be79cef6c25db9d5f8 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 20 Feb 2015 21:53:12 +0000 Subject: 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. llvm-svn: 230067 --- clang/lib/Frontend/ChainedIncludesSource.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'clang/lib/Frontend/ChainedIncludesSource.cpp') 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 clang::createChainedIncludesSource( &Clang->getPreprocessor()); Clang->createASTContext(); - SmallVector serialAST; - llvm::raw_svector_ostream OS(serialAST); - auto consumer = - llvm::make_unique(Clang->getPreprocessor(), "-", nullptr, - /*isysroot=*/"", &OS); + auto consumer = llvm::make_unique(Clang->getPreprocessor(), + "-", nullptr, /*isysroot=*/""); + SmallVectorImpl *serialAST; + consumer->RegisterSerializationFinishedCallback( + [&](SmallVectorImpl *Buf){ + serialAST = Buf; + }); Clang->getASTContext().setASTMutationListener( consumer->GetASTMutationListener()); Clang->setASTConsumer(std::move(consumer)); @@ -197,7 +199,9 @@ IntrusiveRefCntPtr 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()); } -- cgit v1.2.3