summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/GeneratePCH.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-14 23:45:08 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-14 23:45:08 +0000
commit85b2a6a43056395f83a567e45591e797b98e4b88 (patch)
tree85a6670d5860c9b38d7728645451fe2ed591628f /clang/lib/Frontend/GeneratePCH.cpp
parent6f4f3612cc5df8bfd71ebc715d344006b4853ba6 (diff)
downloadbcm5719-llvm-85b2a6a43056395f83a567e45591e797b98e4b88.tar.gz
bcm5719-llvm-85b2a6a43056395f83a567e45591e797b98e4b88.zip
Add a callback interface that allows interested parties to get notified whenever PCHReader deserializes a type or decl (and possibly other things in the future). Have PCHWriter implement these callbacks as noops and register to receive them if we're chaining PCHs. This will allow PCHWriter to track the IDs of these things, which it needs to write the dependent files. WIP
llvm-svn: 108383
Diffstat (limited to 'clang/lib/Frontend/GeneratePCH.cpp')
-rw-r--r--clang/lib/Frontend/GeneratePCH.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/clang/lib/Frontend/GeneratePCH.cpp b/clang/lib/Frontend/GeneratePCH.cpp
index 9be103e06eb..2f3df9479d9 100644
--- a/clang/lib/Frontend/GeneratePCH.cpp
+++ b/clang/lib/Frontend/GeneratePCH.cpp
@@ -28,28 +28,28 @@ using namespace clang;
namespace {
class PCHGenerator : public SemaConsumer {
const Preprocessor &PP;
- const PCHReader *Chain;
const char *isysroot;
llvm::raw_ostream *Out;
Sema *SemaPtr;
MemorizeStatCalls *StatCalls; // owned by the FileManager
+ std::vector<unsigned char> Buffer;
+ llvm::BitstreamWriter Stream;
+ PCHWriter Writer;
public:
- explicit PCHGenerator(const Preprocessor &PP,
- const PCHReader *Chain,
- const char *isysroot,
- llvm::raw_ostream *Out);
+ PCHGenerator(const Preprocessor &PP, PCHReader *Chain,
+ const char *isysroot, llvm::raw_ostream *Out);
virtual void InitializeSema(Sema &S) { SemaPtr = &S; }
virtual void HandleTranslationUnit(ASTContext &Ctx);
};
}
PCHGenerator::PCHGenerator(const Preprocessor &PP,
- const PCHReader *Chain,
+ PCHReader *Chain,
const char *isysroot,
llvm::raw_ostream *OS)
- : PP(PP), Chain(Chain), isysroot(isysroot), Out(OS), SemaPtr(0),
- StatCalls(0) {
+ : PP(PP), isysroot(isysroot), Out(OS), SemaPtr(0), StatCalls(0),
+ Stream(Buffer), Writer(Stream, Chain) {
// Install a stat() listener to keep track of all of the stat()
// calls.
@@ -61,25 +61,23 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
if (PP.getDiagnostics().hasErrorOccurred())
return;
- // Write the PCH contents into a buffer
- std::vector<unsigned char> Buffer;
- llvm::BitstreamWriter Stream(Buffer);
- PCHWriter Writer(Stream);
-
// Emit the PCH file
assert(SemaPtr && "No Sema?");
- Writer.WritePCH(*SemaPtr, StatCalls, Chain, isysroot);
+ Writer.WritePCH(*SemaPtr, StatCalls, isysroot);
// Write the generated bitstream to "Out".
Out->write((char *)&Buffer.front(), Buffer.size());
// Make sure it hits disk now.
Out->flush();
+
+ // Free up some memory, in case the process is kept alive.
+ Buffer.clear();
}
ASTConsumer *clang::CreatePCHGenerator(const Preprocessor &PP,
llvm::raw_ostream *OS,
- const PCHReader *Chain,
+ PCHReader *Chain,
const char *isysroot) {
return new PCHGenerator(PP, Chain, isysroot, OS);
}
OpenPOWER on IntegriCloud