[cfe-commits] r98283 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Devang Patel dpatel at apple.com
Thu Mar 11 12:01:48 PST 2010


Author: dpatel
Date: Thu Mar 11 14:01:48 2010
New Revision: 98283

URL: http://llvm.org/viewvc/llvm-project?rev=98283&view=rev
Log:
Keep track of Record context to ensure that record elements are properly nested in debug info.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=98283&r1=98282&r2=98283&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Mar 11 14:01:48 2010
@@ -792,6 +792,9 @@
   // 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 @@
   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 @@
   // 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 @@
   // 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::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 @@
   // 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;
 }





More information about the cfe-commits mailing list