From 7973a6be3831b7cc85a095a2266d4f85fef06565 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 18 Dec 2015 19:44:31 +0000 Subject: [PATCH] Add a defensive check for a nullptr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256012 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c2ec03f34e..581f2f9fa0 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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(ID.getDeclContext())), - getOrCreateModuleRef(Info, DebugTypeExtRefs), - getLineNumber(ID.getLocation())); + if (Module *M = ID.getImportedModule()) { + auto Info = ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule()); + DBuilder.createImportedDeclaration( + getCurrentContextDescriptor(cast(ID.getDeclContext())), + getOrCreateModuleRef(Info, DebugTypeExtRefs), + getLineNumber(ID.getLocation())); + } } llvm::DIImportedEntity * -- 2.40.0