r200797 - Debug info: fix a crasher when when emitting debug info for

David Blaikie dblaikie at gmail.com
Tue Feb 4 13:48:14 PST 2014


On Tue, Feb 4, 2014 at 1:29 PM, Adrian Prantl <aprantl at apple.com> wrote:

> Author: adrian
> Date: Tue Feb  4 15:29:50 2014
> New Revision: 200797
>
> URL: http://llvm.org/viewvc/llvm-project?rev=200797&view=rev
> Log:
> Debug info: fix a crasher when when emitting debug info for
> not-yet-completed templated types. getTypeSize() needs a complete type.
>

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?

(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... )

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.


>
> rdar://problem/15931354
>
> Added:
>     cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp
> 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=200797&r1=200796&r2=200797&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  4 15:29:50 2014
> @@ -2251,9 +2251,10 @@ llvm::DICompositeType CGDebugInfo::Creat
>    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);
>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp?rev=200797&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-template-fwd.cpp Tue Feb  4
> 15:29:50 2014
> @@ -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();
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140204/30dbc10f/attachment.html>


More information about the cfe-commits mailing list