]> granicus.if.org Git - clang/commitdiff
Don't call a member function on a null pointer.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 27 Aug 2015 21:38:25 +0000 (21:38 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 27 Aug 2015 21:38:25 +0000 (21:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246215 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTWriterDecl.cpp

index 3f8ddf1292e23ec9af38288e38f0c0e260c6ceb2..d38e58766a2898df7b30415e70d3de2851f0effb 100644 (file)
@@ -165,9 +165,12 @@ namespace clang {
     void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
       llvm::MapVector<ModuleFile*, const Decl*> Firsts;
       // FIXME: We can skip entries that we know are implied by others.
-      for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl())
-        if (IncludeLocal || R->isFromASTFile())
+      for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
+        if (R->isFromASTFile())
           Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
+        else if (IncludeLocal)
+          Firsts[nullptr] = R;
+      }
       for (const auto &F : Firsts)
         Writer.AddDeclRef(F.second, Record);
     }