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 | d170d844c4b2ba3c1890113dbf61b6056ce4a577 (patch) | |
tree | f96d257fd664cdb459ec9c02005654e2b56699dd /clang/lib/Serialization/ASTWriter.cpp | |
parent | 3ba70b89cf94c5090aae9962bf633de871c7d32d (diff) | |
download | bcm5719-llvm-d170d844c4b2ba3c1890113dbf61b6056ce4a577.tar.gz bcm5719-llvm-d170d844c4b2ba3c1890113dbf61b6056ce4a577.zip |
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.
llvm-svn: 117239
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index c6df2dd95d3..436525f1999 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/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 + } + } + } +} |