diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-20 19:49:14 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-20 19:49:14 +0000 |
commit | 6181e56a44ecc31dfca8baea2ae8738957003496 (patch) | |
tree | c427f72b4b25374592dd9af0f58ba3f38da80db4 /lib/CodeGen/CGDebugInfo.cpp | |
parent | fd4ce2c9d64032b42c037b2af3bf4ebeac5bbac8 (diff) |
Debug info: Tighten up uses of plain MDNode pointers which don't survive replaceOperandWith.
TrackingVH notices when it gets RAUW'd. Fixes PR12305 and PR12315.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153115 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 0595fdf06b..76ba2ec4b3 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1199,10 +1199,9 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) { if (FwdDecl.isForwardDecl()) return FwdDecl; - - llvm::MDNode *MN = FwdDecl; - llvm::TrackingVH<llvm::MDNode> FwdDeclNode = MN; - + + llvm::TrackingVH<llvm::MDNode> FwdDeclNode(FwdDecl); + // Push the struct on region stack. LexicalBlockStack.push_back(FwdDeclNode); RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl); @@ -1246,15 +1245,15 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) { // get some enums in llvm/Analysis/DebugInfo.h to refer to // them. if (RD->isUnion()) - MN->replaceOperandWith(10, Elements); + FwdDeclNode->replaceOperandWith(10, Elements); else if (CXXDecl) { - MN->replaceOperandWith(10, Elements); - MN->replaceOperandWith(13, TParamsArray); + FwdDeclNode->replaceOperandWith(10, Elements); + FwdDeclNode->replaceOperandWith(13, TParamsArray); } else - MN->replaceOperandWith(10, Elements); + FwdDeclNode->replaceOperandWith(10, Elements); - RegionMap[Ty->getDecl()] = llvm::WeakVH(MN); - return llvm::DIType(MN); + RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDeclNode); + return llvm::DIType(FwdDeclNode); } /// CreateType - get objective-c object type. @@ -1305,8 +1304,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, // will find it and we're emitting the complete type. CompletedTypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl; // Push the struct on region stack. - llvm::MDNode *MN = RealDecl; - llvm::TrackingVH<llvm::MDNode> FwdDeclNode = MN; + llvm::TrackingVH<llvm::MDNode> FwdDeclNode(RealDecl); LexicalBlockStack.push_back(FwdDeclNode); RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl); @@ -1401,10 +1399,10 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, } llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys); - RealDecl->replaceOperandWith(10, Elements); + FwdDeclNode->replaceOperandWith(10, Elements); LexicalBlockStack.pop_back(); - return RealDecl; + return llvm::DIType(FwdDeclNode); } llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) { @@ -1814,7 +1812,7 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { uint64_t Size = CGM.getContext().getTypeSize(Ty); uint64_t Align = CGM.getContext().getTypeAlign(Ty); const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD); - llvm::MDNode *RealDecl = NULL; + llvm::TrackingVH<llvm::MDNode> RealDecl; if (RD->isUnion()) RealDecl = DBuilder.createUnionType(RDContext, RDName, DefUnit, Line, |