summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-08-24 00:50:16 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-08-24 00:50:16 +0000
commit9617e7e8c7530f04c4be3a296890fa44902aa1ef (patch)
tree1925ad1645b680bf3fc2754601bca16940fac9bf /clang/lib/Serialization
parenta4071b4fac77e679cff6585a3c819f702a357ac8 (diff)
downloadbcm5719-llvm-9617e7e8c7530f04c4be3a296890fa44902aa1ef.tar.gz
bcm5719-llvm-9617e7e8c7530f04c4be3a296890fa44902aa1ef.zip
Add testcase for C++ chained PCH and fix the bugs it uncovered in name lookup.
llvm-svn: 111882
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp6
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp16
2 files changed, 7 insertions, 15 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 8167a0f5faf..38b343ffe83 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3192,9 +3192,10 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC,
llvm::SmallVector<NamedDecl *, 64> Decls;
// There might be visible decls in multiple parts of the chain, for the TU
- // and namespaces.
+ // and namespaces. For any given name, the last available results replace
+ // all earlier ones. For this reason, we walk in reverse.
DeclContextInfos &Infos = DeclContextOffsets[DC];
- for (DeclContextInfos::iterator I = Infos.begin(), E = Infos.end();
+ for (DeclContextInfos::reverse_iterator I = Infos.rbegin(), E = Infos.rend();
I != E; ++I) {
if (!I->NameLookupTableData)
continue;
@@ -3208,6 +3209,7 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC,
ASTDeclContextNameLookupTrait::data_type Data = *Pos;
for (; Data.first != Data.second; ++Data.first)
Decls.push_back(cast<NamedDecl>(GetDecl(*Data.first)));
+ break;
}
++NumVisibleDeclContextsRead;
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index dc9f4d409af..43bb7ad4c7a 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2101,23 +2101,13 @@ void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) {
ASTDeclContextNameLookupTrait Trait(*this);
// Create the hash table.
- llvm::SmallVector<NamedDecl *, 16> Decls;
for (StoredDeclsMap::iterator D = Map->begin(), DEnd = Map->end();
D != DEnd; ++D) {
DeclarationName Name = D->first;
DeclContext::lookup_result Result = D->second.getLookupResult();
- // Need to filter these results to only include decls that are not from
- // an existing PCH.
- Decls.clear();
- for (; Result.first != Result.second; ++Result.first) {
- if ((*Result.first)->getPCHLevel() == 0)
- Decls.push_back(*Result.first);
- }
- if (!Decls.empty()) {
- Result.first = Decls.data();
- Result.second = Result.first + Decls.size();
- Generator.insert(Name, Result, Trait);
- }
+ // For any name that appears in this table, the results are complete, i.e.
+ // they overwrite results from previous PCHs. Merging is always a mess.
+ Generator.insert(Name, Result, Trait);
}
// Create the on-disk hash table in a buffer.
OpenPOWER on IntegriCloud