Fix unconditional dereference of a WeakVH in CGDebugInfo TypeCache

This fails an "isa<> used with null pointer" assert during a clang-cl
self-host on Windows.  This was caused by r202769, and I'm currently
reducing a test case.

Reviewers: dblaikie

Differential Revision: http://llvm-reviews.chandlerc.com/D2944

llvm-svn: 202888
This commit is contained in:
Reid Kleckner 2014-03-04 20:51:58 +00:00
parent 1251053e04
commit e0b9201f5a
1 changed files with 2 additions and 1 deletions

View File

@ -3341,7 +3341,8 @@ void CGDebugInfo::finalize() {
// up the final type in the type cache.
for (std::vector<void *>::const_iterator RI = RetainedTypes.begin(),
RE = RetainedTypes.end(); RI != RE; ++RI)
DBuilder.retainType(llvm::DIType(cast<llvm::MDNode>(TypeCache[*RI])));
if (llvm::Value *V = TypeCache[*RI])
DBuilder.retainType(llvm::DIType(cast<llvm::MDNode>(V)));
DBuilder.finalize();
}