<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 4, 2014 at 1:29 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Tue Feb  4 15:29:50 2014<br>
New Revision: 200797<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=200797&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=200797&view=rev</a><br>
Log:<br>
Debug info: fix a crasher when when emitting debug info for<br>
not-yet-completed templated types. getTypeSize() needs a complete type.<br></blockquote><div><br></div><div>I assume this test case could be simplified further - is that not the case? Could you explain the sequence of steps that lead to the incomplete type being used here and why the test case tests for a definition when the code causes more cases to be handled as declarations?</div>
<div><br></div><div>(things in the test case that seem overly complicated - two template parameters in Derived/Base, rather than one. A ctor (and out of line at that) in Foo, a recursive call in 'all', etc... )<br>
<br>That said, I have encountered some fairly convoluted test cases - I'm not ruling it out, just want to better understand the potentially necessary complexity here.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
rdar://problem/15931354<br>
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=200797&r1=200796&r2=200797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=200797&r1=200796&r2=200797&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  4 15:29:50 2014<br>
@@ -2251,9 +2251,10 @@ llvm::DICompositeType CGDebugInfo::Creat<br>
   if (T && (!T.isForwardDecl() || !RD->getDefinition()))<br>
       return T;<br>
<br>
-  // If this is just a forward declaration, construct an appropriately<br>
-  // marked node and just return it.<br>
-  if (!RD->getDefinition())<br>
+  // If this is just a forward or incomplete declaration, construct an<br>
+  // appropriately marked node and just return it.<br>
+  const RecordDecl *D = RD->getDefinition();<br>
+  if (!D || !D->isCompleteDefinition())<br>
     return getOrCreateRecordFwdDecl(Ty, RDContext);<br>
<br>
   uint64_t Size = CGM.getContext().getTypeSize(Ty);<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp?rev=200797&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp?rev=200797&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp Tue Feb  4 15:29:50 2014<br>
@@ -0,0 +1,36 @@<br>
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s<br>
+// This test is for a crash when emitting debug info for not-yet-completed types.<br>
+// Test that we don't actually emit a forward decl for the offending class:<br>
+// CHECK:  [ DW_TAG_class_type ] [Derived<const __CFString, Foo>] {{.*}} [def]<br>
+// rdar://problem/15931354<br>
+typedef const struct __CFString * CFStringRef;<br>
+template <class R> class Returner {};<br>
+typedef const __CFString String;<br>
+<br>
+template <class A, class B> class Derived;<br>
+<br>
+template <class A, class B><br>
+class Base<br>
+{<br>
+  static Derived<A, B>* create();<br>
+};<br>
+<br>
+template <class A, class B><br>
+class Derived : public Base<A, B> {<br>
+public:<br>
+  static void foo();<br>
+};<br>
+<br>
+class Foo<br>
+{<br>
+  Foo();<br>
+  static Returner<Base<String,Foo> > all();<br>
+};<br>
+<br>
+Foo::Foo(){}<br>
+<br>
+Returner<Base<String,Foo> > Foo::all()<br>
+{<br>
+  Derived<String,Foo>::foo();<br>
+  return Foo::all();<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>