r206430 - Debug info: When collecting the parameters of C++ partial template

Adrian Prantl aprantl at apple.com
Wed Apr 16 18:11:44 PDT 2014


On Apr 16, 2014, at 6:02 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Wed, Apr 16, 2014 at 5:30 PM, Adrian Prantl <aprantl at apple.com> wrote:
> Author: adrian
> Date: Wed Apr 16 19:30:48 2014
> New Revision: 206430
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=206430&view=rev
> Log:
> Debug info: When collecting the parameters of C++ partial template
> specializations collect all arguments and not just the ones from the
> class template partial specialization from which this class template
> specialization was instantiated. The debug info does not represent the
> partial specialization otherwise and so specialized parameters would
> go missing.
> 
> rdar://problem/16636569.
> 
> Added:
>     cfe/trunk/test/CodeGenCXX/debug-info-template-partial-specialization.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=206430&r1=206429&r2=206430&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Apr 16 19:30:48 2014
> @@ -1360,10 +1360,16 @@ CollectCXXTemplateParams(const ClassTemp
>                       ClassTemplatePartialSpecializationDecl *>
>      PU = TSpecial->getSpecializedTemplateOrPartial();
> 
> -  TemplateParameterList *TPList = PU.is<ClassTemplateDecl *>() ?
> -    PU.get<ClassTemplateDecl *>()->getTemplateParameters() :
> -    PU.get<ClassTemplatePartialSpecializationDecl *>()->getTemplateParameters();
> -  const TemplateArgumentList &TAList = TSpecial->getTemplateInstantiationArgs();
> +  TemplateParameterList *TPList;
> +  if (auto *CTD = PU.dyn_cast<ClassTemplateDecl *>())
> +    TPList = CTD->getTemplateParameters();
> +  else {
> +    // Always get the full list of parameters, not just the ones from
> +    // the specialization.
> +    auto *CTPSD = PU.get<ClassTemplatePartialSpecializationDecl *>();
> +    TPList = CTPSD->getSpecializedTemplate()->getTemplateParameters();
> +  }
> 
> This is over-complicated; it's equivalent to:
> 
> TPList = TSpecial->getSpecializedTemplate()->getTemplateParameters();
> 
> +  const TemplateArgumentList &TAList = TSpecial->getTemplateArgs();
>    return CollectTemplateParams(TPList, TAList.asArray(), Unit);
>  }
> 

Right.. Thanks!

r206434.

-- adrian


> Added: cfe/trunk/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-partial-specialization.cpp?rev=206430&view=auto
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-template-partial-specialization.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-template-partial-specialization.cpp Wed Apr 16 19:30:48 2014
> @@ -0,0 +1,31 @@
> +// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -g %s -o - -fstandalone-debug | FileCheck %s
> +namespace __pointer_type_imp
> +{
> +  template <class _Tp, class _Dp, bool > struct __pointer_type1 {};
> +
> +  // CHECK: metadata ![[PARAMS:[0-9]+]], metadata !"_ZTSN18__pointer_type_imp15__pointer_type1I1C14default_deleteIS1_ELb0EEE"} ; [ DW_TAG_structure_type ] [__pointer_type1<C, default_delete<C>, false>] [line [[@LINE+1]], size 8, align 8, offset 0] [def] [from ]
> +  template <class _Tp, class _Dp> struct __pointer_type1<_Tp, _Dp, false>
> +  {
> +    typedef _Tp* type;
> +  };
> +}
> +template <class _Tp, class _Dp>
> +struct __pointer_type2
> +{
> +  // Test that the bool template type parameter is emitted.
> +  //
> +  // CHECK: ![[PARAMS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata ![[FALSE:[0-9]+]]}
> +  // CHECK: ![[FALSE]] = {{.*}} i8 0, {{.*}}} ; [ DW_TAG_template_value_parameter ]
> +  typedef typename __pointer_type_imp::__pointer_type1<_Tp, _Dp, false>::type type;
> +};
> +template <class _Tp> struct default_delete {};
> +template <class _Tp, class _Dp = default_delete<_Tp> > class unique_ptr
> +{
> +  typedef typename __pointer_type2<_Tp, _Dp>::type pointer;
> +  unique_ptr(pointer __p, _Dp __d) {}
> +};
> +class C {
> +  unique_ptr<C> Ptr;
> +};
> +void foo(C &c) {
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 




More information about the cfe-commits mailing list