diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-24 17:26:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-24 17:26:54 +0000 |
commit | e16a5300baf930a0c74c81955444a63d45ac4bef (patch) | |
tree | 16156283bcf452f25fedbaf6bd440c6d74d776d8 /clang | |
parent | d170d844c4b2ba3c1890113dbf61b6056ce4a577 (diff) | |
download | bcm5719-llvm-e16a5300baf930a0c74c81955444a63d45ac4bef.tar.gz bcm5719-llvm-e16a5300baf930a0c74c81955444a63d45ac4bef.zip |
Keep track in chained PCH of implicit members that were added after the definition was completed.
llvm-svn: 117240
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/AST/ASTMutationListener.h | 3 | ||||
-rw-r--r-- | clang/include/clang/Serialization/ASTWriter.h | 1 | ||||
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTCommon.h | 3 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 14 |
6 files changed, 29 insertions, 7 deletions
diff --git a/clang/include/clang/AST/ASTMutationListener.h b/clang/include/clang/AST/ASTMutationListener.h index 72e4571cc81..de8cef5f52d 100644 --- a/clang/include/clang/AST/ASTMutationListener.h +++ b/clang/include/clang/AST/ASTMutationListener.h @@ -27,6 +27,9 @@ public: /// \brief A new TagDecl definition was completed. virtual void CompletedTagDefinition(const TagDecl *D) { } + + /// \brief An implicit member was added after the definition was completed. + virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {} }; } // end namespace clang diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 7b6b00155d6..da47e159ec1 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -514,6 +514,7 @@ public: // ASTMutationListener implementation. virtual void CompletedTagDefinition(const TagDecl *D); + virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D); }; /// \brief AST and semantic-analysis consumer that generates a diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index f37151439f9..0e700538660 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -364,12 +364,11 @@ void CXXRecordDecl::addedMember(Decl *D) { } if (D->isImplicit()) { - // Notify the serializer that an implicit member changed the definition. - // A chained PCH will write the whole definition again. - // FIXME: Make a notification about the specific change (through a listener - // interface) so the changes that the serializer records are more - // fine grained. - data().Definition->setChangedSinceDeserialization(true); + // Notify that an implicit member was added after the definition + // was completed. + if (!isBeingDefined()) + if (ASTMutationListener *L = getASTMutationListener()) + L->AddedCXXImplicitMember(data().Definition, D); if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) { // If this is the implicit default constructor, note that we have now diff --git a/clang/lib/Serialization/ASTCommon.h b/clang/lib/Serialization/ASTCommon.h index 36958c75009..5ed607a86e4 100644 --- a/clang/lib/Serialization/ASTCommon.h +++ b/clang/lib/Serialization/ASTCommon.h @@ -21,7 +21,8 @@ namespace clang { namespace serialization { enum DeclUpdateKind { - UPD_CXX_SET_DEFINITIONDATA + UPD_CXX_SET_DEFINITIONDATA, + UPD_CXX_ADDED_IMPLICIT_MEMBER }; TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT); diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index f4568a7e70e..7192195501e 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1599,6 +1599,10 @@ void ASTDeclReader::UpdateDecl(Decl *D, const RecordData &Record) { InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx); break; } + + case UPD_CXX_ADDED_IMPLICIT_MEMBER: + cast<CXXRecordDecl>(D)->addedMember(Reader.GetDecl(Record[Idx++])); + break; } } } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 436525f1999..340f0cc5593 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -3326,3 +3326,17 @@ void ASTWriter::CompletedTagDefinition(const TagDecl *D) { } } } + +void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) { + assert(D->isImplicit()); + if (!(D->getPCHLevel() == 0 && RD->getPCHLevel() > 0)) + return; // Not a source member added to a class from PCH. + if (!isa<CXXMethodDecl>(D)) + return; // We are interested in lazily declared implicit methods. + + // A decl coming from PCH was modified. + assert(RD->isDefinition()); + UpdateRecord &Record = DeclUpdates[RD]; + Record.push_back(UPD_CXX_ADDED_IMPLICIT_MEMBER); + AddDeclRef(D, Record); +} |