/// \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
// 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
}
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
namespace serialization {
enum DeclUpdateKind {
- UPD_CXX_SET_DEFINITIONDATA
+ UPD_CXX_SET_DEFINITIONDATA,
+ UPD_CXX_ADDED_IMPLICIT_MEMBER
};
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx);
break;
}
+
+ case UPD_CXX_ADDED_IMPLICIT_MEMBER:
+ cast<CXXRecordDecl>(D)->addedMember(Reader.GetDecl(Record[Idx++]));
+ break;
}
}
}
}
}
}
+
+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);
+}