From 15a333960ab4722fd769c109235c316f6e4eee14 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 27 Aug 2015 21:38:25 +0000 Subject: [PATCH] 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 --- lib/Serialization/ASTWriterDecl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); } -- 2.40.0