[cfe-commits] r70825 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/debug-info.c

Eli Friedman eli.friedman at gmail.com
Sun May 3 21:39:56 PDT 2009


Author: efriedma
Date: Sun May  3 23:39:55 2009
New Revision: 70825

URL: http://llvm.org/viewvc/llvm-project?rev=70825&view=rev
Log:
PR4143: don't crash generating debug info for incomplete enum types.


Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGen/debug-info.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=70825&r1=70824&r2=70825&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sun May  3 23:39:55 2009
@@ -520,8 +520,12 @@
 
   
   // Size and align of the type.
-  uint64_t Size = M->getContext().getTypeSize(Ty);
-  unsigned Align = M->getContext().getTypeAlign(Ty);
+  uint64_t Size = 0;
+  unsigned Align = 0;
+  if (!Ty->isIncompleteType()) {
+    Size = M->getContext().getTypeSize(Ty);
+    Align = M->getContext().getTypeAlign(Ty);
+  }
   
   return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
                                           Unit, EnumName, DefUnit, Line,

Modified: cfe/trunk/test/CodeGen/debug-info.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info.c?rev=70825&r1=70824&r2=70825&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/debug-info.c (original)
+++ cfe/trunk/test/CodeGen/debug-info.c Sun May  3 23:39:55 2009
@@ -28,3 +28,10 @@
 	void *ptrs[];
 };
 struct foo bar;
+
+// PR4143
+struct foo2 {
+        enum bar *bar;
+};
+
+struct foo2 foo2;





More information about the cfe-commits mailing list