[modules] Fix crash when writing an update record for a redeclaration of an empty namespace.

llvm-svn: 241732
This commit is contained in:
Richard Smith 2015-07-08 21:15:32 +00:00
parent 13e20f1bbf
commit 696e812bb3
4 changed files with 12 additions and 4 deletions

View File

@ -1016,10 +1016,12 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) {
StoredDeclsMap *Map = NS->buildLookup();
SmallVector<std::pair<DeclarationName, DeclContext::lookup_result>, 16>
LookupResults;
LookupResults.reserve(Map->size());
for (auto &Entry : *Map)
LookupResults.push_back(
std::make_pair(Entry.first, Entry.second.getLookupResult()));
if (Map) {
LookupResults.reserve(Map->size());
for (auto &Entry : *Map)
LookupResults.push_back(
std::make_pair(Entry.first, Entry.second.getLookupResult()));
}
std::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
for (auto &NameAndResult : LookupResults) {

View File

@ -71,3 +71,5 @@ namespace N12 {
}
Foo *getFoo();
}
namespace Empty {}

View File

@ -66,3 +66,5 @@ namespace N12 {
}
void consumeFoo(Foo*);
}
namespace Empty {}

View File

@ -21,3 +21,5 @@ namespace N13 {
namespace AddAndReexportBeforeImport {
int S;
}
namespace Empty {}