r246215 - Don't call a member function on a null pointer.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 14:38:25 PDT 2015


Author: rsmith
Date: Thu Aug 27 16:38:25 2015
New Revision: 246215

URL: http://llvm.org/viewvc/llvm-project?rev=246215&view=rev
Log:
Don't call a member function on a null pointer.

Modified:
    cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=246215&r1=246214&r2=246215&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Aug 27 16:38:25 2015
@@ -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);
     }




More information about the cfe-commits mailing list