Author: dpatel
Date: Thu Jul  8 14:56:29 2010
New Revision: 107900

URL: http://llvm.org/viewvc/llvm-project?rev=107900&view=rev
Log:
Handle forward declarations properly in debug info.
Patch by Alexander Kabaev.
PR 7595.

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=107900&r1=107899&r2=107900&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jul  8 14:56:29 2010
@@ -758,22 +758,30 @@
   // 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.
+  llvm::DIDescriptor FDContext =
+    getContextDescriptor(dyn_cast<Decl>(RD->getDeclContext()), Unit);
+
+  // If this is just a forward declaration, construct an appropriately
+  // marked node and just return it.
+  if (!RD->getDefinition()) {
+    llvm::DICompositeType FwdDecl =
+      DebugFactory.CreateCompositeType(Tag, FDContext, RD->getName(),
+                                       DefUnit, Line, 0, 0, 0,
+                                       llvm::DIType::FlagFwdDecl,
+                                       llvm::DIType(), llvm::DIArray());
+
+      return FwdDecl;
+  }
 
   // A RD->getName() is not unique. However, the debug info descriptors 
   // are uniqued so use type name to ensure uniquness.
   llvm::SmallString<128> FwdDeclName;
   llvm::raw_svector_ostream(FwdDeclName) << "fwd.type." << FwdDeclCount++;
-  llvm::DIDescriptor FDContext = 
-    getContextDescriptor(dyn_cast<Decl>(RD->getDeclContext()), Unit);
   llvm::DICompositeType FwdDecl =
     DebugFactory.CreateCompositeType(Tag, FDContext, FwdDeclName,
                                      DefUnit, Line, 0, 0, 0, 0,
                                      llvm::DIType(), llvm::DIArray());
 
-  // If this is just a forward declaration, return it.
-  if (!RD->getDefinition())
-    return FwdDecl;
-
   llvm::MDNode *MN = FwdDecl;
   llvm::TrackingVH<llvm::MDNode> FwdDeclNode = MN;
   // Otherwise, insert it into the TypeCache so that recursive uses will find


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to