freebsd-dev/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff
Dimitry Andric 819c857f10 Add a few missing llvm/clang patches, update the other ones to be able
to apply with the same patch options onto a fresh upstream llvm/clang
3.4.1 checkout, and use approximately the same header tempate for them.

MFC after:	3 days
2014-09-21 15:37:39 +00:00

69 lines
2.2 KiB
Diff

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