]> granicus.if.org Git - clang/commitdiff
[modules] Fix crash when writing an update record for a redeclaration of an empty...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Jul 2015 21:15:32 +0000 (21:15 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Jul 2015 21:15:32 +0000 (21:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241732 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTWriterDecl.cpp
test/Modules/Inputs/namespaces-left.h
test/Modules/Inputs/namespaces-right.h
test/Modules/Inputs/namespaces-top.h

index 371aea8088a0e480dd3f937ef2a69a77d4716134..cdd8487c555e5250e0fabc839797c33de042b890 100644 (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) {
index 787fe753fba975431c682eba70bdb71c09095ae6..5badf62764b6b10cf86bdd2f567e6db2ab40cbb9 100644 (file)
@@ -71,3 +71,5 @@ namespace N12 {
   }
   Foo *getFoo();
 }
+
+namespace Empty {}
index 77f54ead65ab3425097399380d887343afd71dd4..dd2ac33f9108e9ed9bbd6056a63ee80f64c22bca 100644 (file)
@@ -66,3 +66,5 @@ namespace N12 {
   }
   void consumeFoo(Foo*);
 }
+
+namespace Empty {}
index 7bf5394f55beedd3f4e3b4f985e545bb1c7a22af..006b53c8fd289154252d713673a59f7a27ea75d9 100644 (file)
@@ -21,3 +21,5 @@ namespace N13 {
 namespace AddAndReexportBeforeImport {
   int S;
 }
+
+namespace Empty {}