From: Richard Smith Date: Thu, 27 Aug 2015 21:38:25 +0000 (+0000) Subject: Don't call a member function on a null pointer. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15a333960ab4722fd769c109235c316f6e4eee14;p=clang Don't call a member function on a null pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246215 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 3f8ddf1292..d38e58766a 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -165,9 +165,12 @@ namespace clang { void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) { llvm::MapVector 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); }