From eb08bd48e6c5d26f445213a2756ded9b99197d57 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 27 Jul 2011 20:58:46 +0000 Subject: Introduce a new data structure, LazyVector, which is a vector whose contents are lazily loaded on demand from an external source (e.g., an ExternalASTSource or ExternalSemaSource). The "loaded" entities are kept separate from the "local" entities, so that the two can grow independently. Switch Sema::TentativeDefinitions from a normal vector that is eagerly populated by the ASTReader into one of these LazyVectors, making the ASTReader a bit more like me (i.e., lazy). llvm-svn: 136262 --- clang/lib/Serialization/ASTReader.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'clang/lib/Serialization/ASTReader.cpp') diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index b377be6267e..9f8514f1874 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4328,13 +4328,6 @@ void ASTReader::InitializeSema(Sema &S) { } PreloadedDecls.clear(); - // If there were any tentative definitions, deserialize them and add - // them to Sema's list of tentative definitions. - for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) { - VarDecl *Var = cast(GetDecl(TentativeDefinitions[I])); - SemaObj->TentativeDefinitions.push_back(Var); - } - // If there were any unused file scoped decls, deserialize them and add to // Sema's list of unused file scoped decls. for (unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) { @@ -4571,6 +4564,16 @@ void ASTReader::ReadKnownNamespaces( } } +void ASTReader::ReadTentativeDefinitions( + SmallVectorImpl &TentativeDefs) { + for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) { + VarDecl *Var = dyn_cast_or_null(GetDecl(TentativeDefinitions[I])); + if (Var) + TentativeDefs.push_back(Var); + } + TentativeDefinitions.clear(); +} + void ASTReader::LoadSelector(Selector Sel) { // It would be complicated to avoid reading the methods anyway. So don't. ReadMethodPool(Sel); -- cgit v1.2.3