diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-27 21:45:57 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-27 21:45:57 +0000 |
commit | a94a1544d8d0ae7b54b5a78300e46e81b267e2f9 (patch) | |
tree | ce1c7a88e144c32cd240074f8f0fb656ddca7ef6 /clang/lib/Serialization/ASTWriter.cpp | |
parent | 9c5b7ff80727e883e5edd8fb65a31f5c5eb4fea1 (diff) | |
download | bcm5719-llvm-a94a1544d8d0ae7b54b5a78300e46e81b267e2f9.tar.gz bcm5719-llvm-a94a1544d8d0ae7b54b5a78300e46e81b267e2f9.zip |
Switch Sema::UnusedFileScopedDecls over to a LazyVector.
- Added LazyVector::erase() to support this use case.
- Factored out the LazyDecl-of-Decls to RecordData translation in
the ASTWriter. There is still a pile of code duplication here to
eliminate.
llvm-svn: 136270
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 1acc140acdd..d604da9c885 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2777,6 +2777,15 @@ void ASTWriter::WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls, WriteASTCore(SemaRef, StatCalls, isysroot, OutputFile); } +template<typename Vector> +static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec, + ASTWriter::RecordData &Record) { + for (typename Vector::iterator I = Vec.begin(0, true), E = Vec.end(); + I != E; ++I) { + Writer.AddDeclRef(*I, Record); + } +} + void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, StringRef isysroot, const std::string &OutputFile) { @@ -2805,17 +2814,12 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, // TentativeDefinitions order. Generally, this record will be empty for // headers. RecordData TentativeDefinitions; - for (Sema::TentativeDefinitionsType::iterator - T = SemaRef.TentativeDefinitions.begin(0, true), - TEnd = SemaRef.TentativeDefinitions.end(); - T != TEnd; ++T) { - AddDeclRef(*T, TentativeDefinitions); - } + AddLazyVectorDecls(*this, SemaRef.TentativeDefinitions, TentativeDefinitions); // Build a record containing all of the file scoped decls in this file. RecordData UnusedFileScopedDecls; - for (unsigned i=0, e = SemaRef.UnusedFileScopedDecls.size(); i !=e; ++i) - AddDeclRef(SemaRef.UnusedFileScopedDecls[i], UnusedFileScopedDecls); + AddLazyVectorDecls(*this, SemaRef.UnusedFileScopedDecls, + UnusedFileScopedDecls); RecordData DelegatingCtorDecls; for (unsigned i=0, e = SemaRef.DelegatingCtorDecls.size(); i != e; ++i) @@ -3075,19 +3079,12 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, // Build a record containing all of the new tentative definitions in this // file, in TentativeDefinitions order. RecordData TentativeDefinitions; - for (Sema::TentativeDefinitionsType::iterator - T = SemaRef.TentativeDefinitions.begin(0, true), - TEnd = SemaRef.TentativeDefinitions.end(); - T != TEnd; ++T) { - AddDeclRef(*T, TentativeDefinitions); - } + AddLazyVectorDecls(*this, SemaRef.TentativeDefinitions, TentativeDefinitions); // Build a record containing all of the file scoped decls in this file. RecordData UnusedFileScopedDecls; - for (unsigned i=0, e = SemaRef.UnusedFileScopedDecls.size(); i !=e; ++i) { - if (SemaRef.UnusedFileScopedDecls[i]->getPCHLevel() == 0) - AddDeclRef(SemaRef.UnusedFileScopedDecls[i], UnusedFileScopedDecls); - } + AddLazyVectorDecls(*this, SemaRef.UnusedFileScopedDecls, + UnusedFileScopedDecls); // Build a record containing all of the delegating constructor decls in this // file. |