]> granicus.if.org Git - clang/commitdiff
Keep track in chained PCH of implicit members that were added after the definition...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 24 Oct 2010 17:26:54 +0000 (17:26 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 24 Oct 2010 17:26:54 +0000 (17:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117240 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTMutationListener.h
include/clang/Serialization/ASTWriter.h
lib/AST/DeclCXX.cpp
lib/Serialization/ASTCommon.h
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriter.cpp

index 72e4571cc8164dc6ab4b3872eaaa4a1ed4495df6..de8cef5f52d2ab377913c356425873eb08e8a9c5 100644 (file)
@@ -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
index 7b6b00155d66caf84d9956356b3afa2fb9f69afe..da47e159ec16e38e00f1211e894dfb15f3f7676c 100644 (file)
@@ -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
index f37151439f9fe9a3ed50bcc3b0bf79dad8249d27..0e7005386605d661c06cfda4d38e9ee7021c5963 100644 (file)
@@ -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
index 36958c75009826b2b088996210e27f9b5aee27ad..5ed607a86e413f168d7a8c76cd0bb8c6feb1d16f 100644 (file)
@@ -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);
index f4568a7e70e531b9343d448c4d869e94217e5412..7192195501eff89c3628f54caee96c0e66ce7c7d 100644 (file)
@@ -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;
     }
   }
 }
index 436525f1999ea4333222fe6ceca1bf31895d1b80..340f0cc55937d1749d4209231ce7f487d7e4ae6e 100644 (file)
@@ -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);
+}