diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 35bd57a05315..c91b7a974430 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3341,7 +3341,8 @@ void CGDebugInfo::finalize() { // up the final type in the type cache. for (std::vector::const_iterator RI = RetainedTypes.begin(), RE = RetainedTypes.end(); RI != RE; ++RI) - DBuilder.retainType(llvm::DIType(cast(TypeCache[*RI]))); + if (llvm::Value *V = TypeCache[*RI]) + DBuilder.retainType(llvm::DIType(cast(V))); DBuilder.finalize(); }