]> granicus.if.org Git - clang/commitdiff
Add a defensive check for a nullptr.
authorAdrian Prantl <aprantl@apple.com>
Fri, 18 Dec 2015 19:44:31 +0000 (19:44 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 18 Dec 2015 19:44:31 +0000 (19:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256012 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index c2ec03f34e4ae358aae4023e3c9a6d4c8a61b053..581f2f9fa086ffb2f755057007c5927d92995ab8 100644 (file)
@@ -3443,11 +3443,13 @@ void CGDebugInfo::EmitUsingDecl(const UsingDecl &UD) {
 }
 
 void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {
-  auto Info = ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());
-  DBuilder.createImportedDeclaration(
-      getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
-      getOrCreateModuleRef(Info, DebugTypeExtRefs),
-      getLineNumber(ID.getLocation()));
+  if (Module *M = ID.getImportedModule()) {
+    auto Info = ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());
+    DBuilder.createImportedDeclaration(
+        getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
+        getOrCreateModuleRef(Info, DebugTypeExtRefs),
+        getLineNumber(ID.getLocation()));
+  }
 }
 
 llvm::DIImportedEntity *