diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-24 17:26:50 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-24 17:26:50 +0000 |
commit | 565bf30bf5607b9740d288d8d9c45cf38ea75298 (patch) | |
tree | cb635a792a071ec4f0ef432d8d87e0a1dc56bbf2 /lib/Serialization/ASTWriter.cpp | |
parent | ba901b507fc36408fe6f8478e8ac90b554f1d230 (diff) |
Start fleshing out ASTMutationListener; notify when a tag definition is completed.
In that case a chained PCH will record the updates to the DefinitionData pointer of forward references.
If a forward reference mutated into a definition re-write it into the chained PCH, this is too big of a change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index c6df2dd95d..436525f199 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3297,3 +3297,32 @@ void ASTWriter::MacroDefinitionRead(serialization::MacroID ID, MacroDefinition *MD) { MacroDefinitions[MD] = ID; } + +void ASTWriter::CompletedTagDefinition(const TagDecl *D) { + assert(D->isDefinition()); + if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) { + // We are interested when a PCH decl is modified. + if (RD->getPCHLevel() > 0) { + // A forward reference was mutated into a definition. Rewrite it. + // FIXME: This happens during template instantiation, should we + // have created a new definition decl instead ? + DeclsToRewrite.insert(RD); + } + + for (CXXRecordDecl::redecl_iterator + I = RD->redecls_begin(), E = RD->redecls_end(); I != E; ++I) { + CXXRecordDecl *Redecl = cast<CXXRecordDecl>(*I); + if (Redecl == RD) + continue; + + // We are interested when a PCH decl is modified. + if (Redecl->getPCHLevel() > 0) { + UpdateRecord &Record = DeclUpdates[Redecl]; + Record.push_back(UPD_CXX_SET_DEFINITIONDATA); + assert(Redecl->DefinitionData); + assert(Redecl->DefinitionData->Definition == D); + AddDeclRef(D, Record); // the DefinitionDecl + } + } + } +} |