[cfe-commits] r117240 - in /cfe/trunk: 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

Argyrios Kyrtzidis akyrtzi at gmail.com
Sun Oct 24 10:26:54 PDT 2010


Author: akirtzidis
Date: Sun Oct 24 12:26:54 2010
New Revision: 117240

URL: http://llvm.org/viewvc/llvm-project?rev=117240&view=rev
Log:
Keep track in chained PCH of implicit members that were added after the definition was completed.

Modified:
    cfe/trunk/include/clang/AST/ASTMutationListener.h
    cfe/trunk/include/clang/Serialization/ASTWriter.h
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/Serialization/ASTCommon.h
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTMutationListener.h?rev=117240&r1=117239&r2=117240&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
+++ cfe/trunk/include/clang/AST/ASTMutationListener.h Sun Oct 24 12:26:54 2010
@@ -27,6 +27,9 @@
 
   /// \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

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=117240&r1=117239&r2=117240&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Sun Oct 24 12:26:54 2010
@@ -514,6 +514,7 @@
 
   // 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

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=117240&r1=117239&r2=117240&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sun Oct 24 12:26:54 2010
@@ -364,12 +364,11 @@
   }
   
   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

Modified: cfe/trunk/lib/Serialization/ASTCommon.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.h?rev=117240&r1=117239&r2=117240&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTCommon.h (original)
+++ cfe/trunk/lib/Serialization/ASTCommon.h Sun Oct 24 12:26:54 2010
@@ -21,7 +21,8 @@
 namespace serialization {
 
 enum DeclUpdateKind {
-  UPD_CXX_SET_DEFINITIONDATA
+  UPD_CXX_SET_DEFINITIONDATA,
+  UPD_CXX_ADDED_IMPLICIT_MEMBER
 };
 
 TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=117240&r1=117239&r2=117240&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sun Oct 24 12:26:54 2010
@@ -1599,6 +1599,10 @@
       InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx);
       break;
     }
+
+    case UPD_CXX_ADDED_IMPLICIT_MEMBER:
+      cast<CXXRecordDecl>(D)->addedMember(Reader.GetDecl(Record[Idx++]));
+      break;
     }
   }
 }

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=117240&r1=117239&r2=117240&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Sun Oct 24 12:26:54 2010
@@ -3326,3 +3326,17 @@
     }
   }
 }
+
+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);
+}





More information about the cfe-commits mailing list