Prepare for the DIBuilder populating DISubprogram's Variables with null.

This is a followup to r222373. A better solution to the problem solved
there is to not create the leaked nodes at all (we know that they will
never be used for forward declared functions anyway). To avoid bot
breakage in the interval between the cfe and llvm commits, add a check
that the nMDNode is not null before deleting it. This code can completely
go away after the LLVM part is in.

llvm-svn: 222433
This commit is contained in:
Frederic Riss 2014-11-20 15:46:59 +00:00
parent 2c15e8ccce
commit c3a9d7dfbf
1 changed files with 2 additions and 1 deletions

View File

@ -3417,7 +3417,8 @@ void CGDebugInfo::finalize() {
// to get RAUWed upon DIBuilder finalization. Do not leak these
// nodes for the temporary functions we are about to delete.
if (FwdDecl.isSubprogram())
llvm::MDNode::deleteTemporary(llvm::DISubprogram(FwdDecl).getVariablesNodes());
if (llvm::MDNode *Vars = llvm::DISubprogram(FwdDecl).getVariablesNodes())
llvm::MDNode::deleteTemporary(Vars);
FwdDecl.replaceAllUsesWith(CGM.getLLVMContext(),
llvm::DIDescriptor(cast<llvm::MDNode>(VH)));