diff options
author | Devang Patel <dpatel@apple.com> | 2010-03-11 20:01:48 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-03-11 20:01:48 +0000 |
commit | e4c1ea0c23ce994e5d8084c6a9d41b18c803fcf3 (patch) | |
tree | 84170107000428cd0d231b7b647e680173e1d106 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 7d2aa11c5c3b85a9d727ff868de666ba3bff5b59 (diff) |
Keep track of Record context to ensure that record elements are properly nested in debug info.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c469e9c3b9..0ed2dcf3fb 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -792,6 +792,9 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, // Otherwise, insert it into the TypeCache so that recursive uses will find // it. TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = FwdDecl.getNode(); + // Push the struct on region stack. + RegionStack.push_back(FwdDecl.getNode()); + RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl.getNode()); // Convert all the elements. llvm::SmallVector<llvm::DIDescriptor, 16> EltTys; @@ -822,6 +825,12 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, uint64_t Size = CGM.getContext().getTypeSize(Ty); uint64_t Align = CGM.getContext().getTypeAlign(Ty); + RegionStack.pop_back(); + llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator RI = + RegionMap.find(Ty->getDecl()); + if (RI != RegionMap.end()) + RegionMap.erase(RI); + llvm::DIDescriptor RDContext = getContextDescriptor(dyn_cast<Decl>(RD->getDeclContext()), Unit); llvm::DICompositeType RealDecl = @@ -834,7 +843,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, // 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. llvm::DIDerivedType(FwdDeclNode).replaceAllUsesWith(RealDecl); - + RegionMap[RD] = llvm::WeakVH(RealDecl.getNode()); return RealDecl; } @@ -874,6 +883,9 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, // Otherwise, insert it into the TypeCache so that recursive uses will find // it. TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = FwdDecl.getNode(); + // Push the struct on region stack. + RegionStack.push_back(FwdDecl.getNode()); + RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl.getNode()); // Convert all the elements. llvm::SmallVector<llvm::DIDescriptor, 16> EltTys; @@ -946,6 +958,12 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, llvm::DIArray Elements = DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size()); + RegionStack.pop_back(); + llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator RI = + RegionMap.find(Ty->getDecl()); + if (RI != RegionMap.end()) + RegionMap.erase(RI); + // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(Ty); uint64_t Align = CGM.getContext().getTypeAlign(Ty); @@ -958,6 +976,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, // 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. llvm::DIDerivedType(FwdDeclNode).replaceAllUsesWith(RealDecl); + RegionMap[ID] = llvm::WeakVH(RealDecl.getNode()); return RealDecl; } |