1 Pull in r200797 from upstream clang trunk (by Adrian Prantl):
3 Debug info: fix a crasher when when emitting debug info for
4 not-yet-completed templated types. getTypeSize() needs a complete type.
6 rdar://problem/15931354
8 Introduced here: http://svnweb.freebsd.org/changeset/base/271282
10 Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp
11 ===================================================================
12 --- tools/clang/lib/CodeGen/CGDebugInfo.cpp
13 +++ tools/clang/lib/CodeGen/CGDebugInfo.cpp
14 @@ -2251,9 +2251,10 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedTy
15 if (T && (!T.isForwardDecl() || !RD->getDefinition()))
18 - // If this is just a forward declaration, construct an appropriately
19 - // marked node and just return it.
20 - if (!RD->getDefinition())
21 + // If this is just a forward or incomplete declaration, construct an
22 + // appropriately marked node and just return it.
23 + const RecordDecl *D = RD->getDefinition();
24 + if (!D || !D->isCompleteDefinition())
25 return getOrCreateRecordFwdDecl(Ty, RDContext);
27 uint64_t Size = CGM.getContext().getTypeSize(Ty);
28 Index: tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp
29 ===================================================================
30 --- tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp
31 +++ tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp
33 +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s
34 +// This test is for a crash when emitting debug info for not-yet-completed types.
35 +// Test that we don't actually emit a forward decl for the offending class:
36 +// CHECK: [ DW_TAG_class_type ] [Derived<const __CFString, Foo>] {{.*}} [def]
37 +// rdar://problem/15931354
38 +typedef const struct __CFString * CFStringRef;
39 +template <class R> class Returner {};
40 +typedef const __CFString String;
42 +template <class A, class B> class Derived;
44 +template <class A, class B>
47 + static Derived<A, B>* create();
50 +template <class A, class B>
51 +class Derived : public Base<A, B> {
59 + static Returner<Base<String,Foo> > all();
64 +Returner<Base<String,Foo> > Foo::all()
66 + Derived<String,Foo>::foo();