diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-19 19:00:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-19 19:00:47 +0000 |
commit | e80b31f7f9be6a34fa8db3f3ca19f586b04b5a82 (patch) | |
tree | 7921ce6e2f582a4547362e46b641c98381554a1d /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | 9ae4fc035b98e3b989db0e98d2fbd0208958dcc6 (diff) | |
download | bcm5719-llvm-e80b31f7f9be6a34fa8db3f3ca19f586b04b5a82.tar.gz bcm5719-llvm-e80b31f7f9be6a34fa8db3f3ca19f586b04b5a82.zip |
Once we have fully deserialized a redeclaration chain for something
with a definition pointer (e.g., C++ and Objective-C classes), zip
through the redeclaration chain to make sure that all of the
declarations point to the definition data.
As part of this, realized again why the first redeclaration of an
entity in a file is important, and brought back that idea.
llvm-svn: 146886
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 35cd8478d5b..bd6a5a5e06d 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -630,6 +630,9 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { // pending references were linked. Reader.PendingForwardRefs.erase(ID); #endif + + // Note that we have deserialized a definition. + Reader.PendingDefinitions.insert(ID); } } else if (Def) { if (Def->Data) { @@ -1030,6 +1033,9 @@ void ASTDeclReader::InitializeCXXDefinitionData(CXXRecordDecl *D, Reader.PendingForwardRefs.erase(D); #endif } + + // Note that we have deserialized a definition. + Reader.PendingDefinitions.insert(D); } else if (DefinitionDecl) { if (DefinitionDecl->DefinitionData) { D->DefinitionData = DefinitionDecl->DefinitionData; @@ -1162,7 +1168,7 @@ void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { // Initialize CommonOrPrev before VisitTemplateDecl so that getCommonPtr() // can be used while this is still initializing. - enum RedeclKind { FirstDeclaration, PointsToPrevious }; + enum RedeclKind { FirstDeclaration, FirstInFile, PointsToPrevious }; RedeclKind Kind = (RedeclKind)Record[Idx++]; // Determine the first declaration ID. @@ -1190,7 +1196,8 @@ void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { } break; } - + + case FirstInFile: case PointsToPrevious: { FirstDeclID = ReadDeclID(Record, Idx); DeclID PrevDeclID = ReadDeclID(Record, Idx); @@ -1204,9 +1211,13 @@ void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { // loaded and attached later on. D->CommonOrPrev = FirstDecl; - // Make a note that we need to wire up this declaration to its - // previous declaration, later. - Reader.PendingPreviousDecls.push_back(std::make_pair(D, PrevDeclID)); + if (Kind == PointsToPrevious) { + // Make a note that we need to wire up this declaration to its + // previous declaration, later. We don't need to do this for the first + // declaration in any given module file, because those will be wired + // together later. + Reader.PendingPreviousDecls.push_back(std::make_pair(D, PrevDeclID)); + } break; } } @@ -1412,7 +1423,7 @@ ASTDeclReader::VisitDeclContext(DeclContext *DC) { template <typename T> void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { - enum RedeclKind { FirstDeclaration = 0, PointsToPrevious }; + enum RedeclKind { FirstDeclaration = 0, FirstInFile, PointsToPrevious }; RedeclKind Kind = (RedeclKind)Record[Idx++]; DeclID FirstDeclID; @@ -1420,7 +1431,8 @@ void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { case FirstDeclaration: FirstDeclID = ThisDeclID; break; - + + case FirstInFile: case PointsToPrevious: { FirstDeclID = ReadDeclID(Record, Idx); DeclID PrevDeclID = ReadDeclID(Record, Idx); @@ -1433,10 +1445,14 @@ void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { // loaded & attached later on. D->RedeclLink = typename Redeclarable<T>::PreviousDeclLink(FirstDecl); - // Make a note that we need to wire up this declaration to its - // previous declaration, later. - Reader.PendingPreviousDecls.push_back(std::make_pair(static_cast<T*>(D), - PrevDeclID)); + if (Kind == PointsToPrevious) { + // Make a note that we need to wire up this declaration to its + // previous declaration, later. We don't need to do this for the first + // declaration in any given module file, because those will be wired + // together later. + Reader.PendingPreviousDecls.push_back(std::make_pair(static_cast<T*>(D), + PrevDeclID)); + } break; } } |