[llvm-commits] [llvm-gcc-4.2] r61207 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Devang Patel dpatel at apple.com
Thu Dec 18 11:18:21 PST 2008


Author: dpatel
Date: Thu Dec 18 13:18:20 2008
New Revision: 61207

URL: http://llvm.org/viewvc/llvm-project?rev=61207&view=rev
Log:

Reuse DIType slot used for foward declaration for real definition.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=61207&r1=61206&r2=61207&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Dec 18 13:18:20 2008
@@ -325,8 +325,14 @@
   
   // Check to see if the compile unit already has created this type.
   DIType &Slot = TypeCache[type];
-  if (!Slot.isNull())
-    return Slot;
+  bool SlotIsFwdDecl = false;
+  if (!Slot.isNull()) {
+    if (Slot.getFlags() == DW_AT_declaration
+        && TYPE_SIZE(type) != 0)
+      SlotIsFwdDecl = true;
+    if (!SlotIsFwdDecl)
+      return Slot;
+  }
   
   DIType MainTy;
   if (type != TYPE_MAIN_VARIANT(type))
@@ -528,15 +534,17 @@
       unsigned Tag = TREE_CODE(type) == RECORD_TYPE ? DW_TAG_structure_type :
                                                       DW_TAG_union_type;
 
-      // Records and classes and unions can all be recursive.  To handle them, we
-      // first generate a debug descriptor for the struct as a forward declaration.
-      // Then (if it is a definition) we go through and get debug info for all of
-      // its members.  Finally, we create a descriptor for the complete type (which
-      // may refer to the forward decl if the struct is recursive) and replace all
-      // uses of the forward declaration with the final definition.
+      // Records and classes and unions can all be recursive.  To handle them,
+      // we first generate a debug descriptor for the struct as a forward 
+      // declaration. Then (if it is a definition) we go through and get debug 
+      // info for all of its members.  Finally, we create a descriptor for the
+      // complete type (which may refer to the forward decl if the struct is 
+      // recursive) and replace all  uses of the forward declaration with the 
+      // final definition. 
       expanded_location Loc = GetNodeLocation(type, false);
-      llvm::DIType FwdDecl =
-        DebugFactory.CreateCompositeType(Tag, Unit, TypeName, Unit, Loc.line, 0, 0, 0, 0,
+      llvm::DIType FwdDecl = SlotIsFwdDecl ? Slot :
+        DebugFactory.CreateCompositeType(Tag, Unit, TypeName, Unit, Loc.line, 
+                                         0, 0, 0, DW_AT_declaration,
                                          llvm::DIType(), llvm::DIArray());
   
 





More information about the llvm-commits mailing list