Use TrackingVH to hold forward decl.
llvm-svn: 88951
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 64748dc..0cd8f1b 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -600,6 +600,7 @@
if (Decl->isForwardDecl())
return FwdDecl;
+ llvm::TrackingVH<llvm::MDNode> FwdDeclNode = FwdDecl.getNode();
// Otherwise, insert it into the TypeCache so that recursive uses will find
// it.
TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = FwdDecl.getNode();
@@ -686,7 +687,7 @@
// Now that we have a real decl for the struct, replace anything using the
// old decl with the new one. This will recursively update the debug info.
- FwdDecl.replaceAllUsesWith(RealDecl);
+ llvm::DIDerivedType(FwdDeclNode).replaceAllUsesWith(RealDecl);
return RealDecl;
}