diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-14 23:45:08 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-14 23:45:08 +0000 |
commit | 85b2a6a43056395f83a567e45591e797b98e4b88 (patch) | |
tree | 85a6670d5860c9b38d7728645451fe2ed591628f /clang/lib/Frontend/PCHWriter.cpp | |
parent | 6f4f3612cc5df8bfd71ebc715d344006b4853ba6 (diff) | |
download | bcm5719-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/PCHWriter.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index e86399886c0..093c1e334a3 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/lib/Frontend/PCHWriter.cpp @@ -743,8 +743,7 @@ adjustFilenameForRelocatablePCH(const char *Filename, const char *isysroot) { } /// \brief Write the PCH metadata (e.g., i686-apple-darwin9). -void PCHWriter::WriteMetadata(ASTContext &Context, const PCHReader *Chain, - const char *isysroot) { +void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) { using namespace llvm; // Metadata @@ -2074,13 +2073,16 @@ void PCHWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) { SelectorOffsets[ID - 1] = Offset; } -PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream) - : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS), +PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream, PCHReader *Chain) + : Stream(Stream), Chain(Chain), NextTypeID(pch::NUM_PREDEF_TYPE_IDS), CollectedStmts(&StmtsToEmit), NumStatements(0), NumMacros(0), - NumLexicalDeclContexts(0), NumVisibleDeclContexts(0) { } + NumLexicalDeclContexts(0), NumVisibleDeclContexts(0) { + if (Chain) + Chain->setDeserializationListener(this); +} void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls, - const PCHReader *Chain, const char *isysroot) { + const char *isysroot) { // Emit the file header. Stream.Emit((unsigned)'C', 8); Stream.Emit((unsigned)'P', 8); @@ -2090,7 +2092,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls, WriteBlockInfoBlock(); if (Chain) - WritePCHChain(SemaRef, StatCalls, Chain, isysroot); + WritePCHChain(SemaRef, StatCalls, isysroot); else WritePCHCore(SemaRef, StatCalls, isysroot); } @@ -2164,7 +2166,7 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, // Write the remaining PCH contents. RecordData Record; Stream.EnterSubblock(pch::PCH_BLOCK_ID, 5); - WriteMetadata(Context, 0, isysroot); + WriteMetadata(Context, isysroot); WriteLanguageOptions(Context.getLangOptions()); if (StatCalls && !isysroot) WriteStatCache(*StatCalls); @@ -2275,7 +2277,7 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, } void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, - const PCHReader *Chain, const char *isysroot) { + const char *isysroot) { using namespace llvm; ASTContext &Context = SemaRef.Context; @@ -2284,7 +2286,7 @@ void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, RecordData Record; Stream.EnterSubblock(pch::PCH_BLOCK_ID, 5); - WriteMetadata(Context, Chain, isysroot); + WriteMetadata(Context, isysroot); // FIXME: StatCache // FIXME: Source manager block @@ -2737,3 +2739,10 @@ void PCHWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, AddTypeRef(Base.getType(), Record); AddSourceRange(Base.getSourceRange(), Record); } + +void PCHWriter::TypeRead(pch::TypeID ID, QualType T) { +} + +void PCHWriter::DeclRead(pch::DeclID ID, const Decl *D) { +} + |