diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-24 17:26:36 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-24 17:26:36 +0000 |
commit | 65ad5691fd48b2ad6982adb5f416ccc2a41fc8da (patch) | |
tree | 44234e8b6b6b87c006d9f23587074aad6c05905e /clang/lib/Serialization/ASTWriter.cpp | |
parent | ad5f95cc4bcaf97debcd1cfd85d1110bfe3af4d3 (diff) | |
download | bcm5719-llvm-65ad5691fd48b2ad6982adb5f416ccc2a41fc8da.tar.gz bcm5719-llvm-65ad5691fd48b2ad6982adb5f416ccc2a41fc8da.zip |
Put the mechanism in place to track modifications in an AST entity that were committed after
its initial creation/deserialization and store the changes in a chained PCH.
The idea is that the AST entities call methods on the ASTMutationListener to give notifications
of changes; the PCHWriter implements the ASTMutationListener interface and stores the incremental changes
of the updated entity. WIP
llvm-svn: 117235
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 4d0ec990749..e258fcc2a29 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2474,17 +2474,6 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, const char *isysroot) { using namespace llvm; - FirstDeclID += Chain->getTotalNumDecls(); - FirstTypeID += Chain->getTotalNumTypes(); - FirstIdentID += Chain->getTotalNumIdentifiers(); - FirstSelectorID += Chain->getTotalNumSelectors(); - FirstMacroID += Chain->getTotalNumMacroDefinitions(); - NextDeclID = FirstDeclID; - NextTypeID = FirstTypeID; - NextIdentID = FirstIdentID; - NextSelectorID = FirstSelectorID; - NextMacroID = FirstMacroID; - ASTContext &Context = SemaRef.Context; Preprocessor &PP = SemaRef.PP; @@ -2707,6 +2696,8 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, if (!AdditionalTemplateSpecializations.empty()) WriteAdditionalTemplateSpecializations(); + WriteDeclChangeSetBlocks(); + Record.clear(); Record.push_back(NumStatements); Record.push_back(NumMacros); @@ -2717,6 +2708,27 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, Stream.ExitBlock(); } +void ASTWriter::WriteDeclChangeSetBlocks() { + if (DeclUpdates.empty()) + return; + + RecordData OffsetsRecord; + Stream.EnterSubblock(DECL_UPDATES_BLOCK_ID, 3); + for (DeclUpdateMap::iterator + I = DeclUpdates.begin(), E = DeclUpdates.end(); I != E; ++I) { + const Decl *D = I->first; + UpdateRecord &URec = I->second; + + uint64_t Offset = Stream.GetCurrentBitNo(); + Stream.EmitRecord(DECL_UPDATES, URec); + + OffsetsRecord.push_back(GetDeclRef(D)); + OffsetsRecord.push_back(Offset); + } + Stream.ExitBlock(); + Stream.EmitRecord(DECL_UPDATE_OFFSETS, OffsetsRecord); +} + void ASTWriter::WriteDeclUpdateBlock() { if (ReplacedDecls.empty()) return; @@ -2891,7 +2903,7 @@ TypeIdx ASTWriter::getTypeIdx(QualType T) const { return I->second; } -void ASTWriter::AddDeclRef(const Decl *D, RecordData &Record) { +void ASTWriter::AddDeclRef(const Decl *D, RecordDataImpl &Record) { Record.push_back(GetDeclRef(D)); } @@ -3190,8 +3202,9 @@ void ASTWriter::AddCXXBaseOrMemberInitializers( } } -void ASTWriter::SetReader(ASTReader *Reader) { +void ASTWriter::ReaderInitialized(ASTReader *Reader) { assert(Reader && "Cannot remove chain"); + assert(!Chain && "Cannot replace chain"); assert(FirstDeclID == NextDeclID && FirstTypeID == NextTypeID && FirstIdentID == NextIdentID && @@ -3199,6 +3212,17 @@ void ASTWriter::SetReader(ASTReader *Reader) { FirstMacroID == NextMacroID && "Setting chain after writing has started."); Chain = Reader; + + FirstDeclID += Chain->getTotalNumDecls(); + FirstTypeID += Chain->getTotalNumTypes(); + FirstIdentID += Chain->getTotalNumIdentifiers(); + FirstSelectorID += Chain->getTotalNumSelectors(); + FirstMacroID += Chain->getTotalNumMacroDefinitions(); + NextDeclID = FirstDeclID; + NextTypeID = FirstTypeID; + NextIdentID = FirstIdentID; + NextSelectorID = FirstSelectorID; + NextMacroID = FirstMacroID; } void ASTWriter::IdentifierRead(IdentID ID, IdentifierInfo *II) { |