[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 10:47:28 PDT 2017


I'm roughly where I was before, I think:

"In any case, it seems like it might make sense for you to upstream your
template naming change and put it under the PS4 debugger tuning option, and
put this change there too, once the motivation for it is in-tree. At that
point, while I'd be curious about the size tradeoff, it'd be essentially
academic."

Basically without the naming change in-tree, there seems to be a lack of
motivation for this change. I'd prefer/recommend/suggest keeping this
change wherever that change is. (so if the naming change is upstreamed
(conditional/behind the PS4 debugger tuning flag) then I agree this
could/should go in similarly)

- Dave

On Tue, Jul 11, 2017 at 10:34 AM Paul Robinson via Phabricator <
reviews at reviews.llvm.org> wrote:

> probinson updated this revision to Diff 106063.
> probinson added a comment.
>
> Refresh to current TOT, and ping.  Funny what you can find in a year-old
> to-do list....
>
>
> https://reviews.llvm.org/D14358
>
> Files:
>   lib/CodeGen/CGDebugInfo.cpp
>   test/CodeGenCXX/debug-info-template-fwd-param.cpp
>   test/Modules/ExtDebugInfo.cpp
>
>
> Index: test/Modules/ExtDebugInfo.cpp
> ===================================================================
> --- test/Modules/ExtDebugInfo.cpp
> +++ test/Modules/ExtDebugInfo.cpp
> @@ -93,9 +93,13 @@
>  // CHECK-SAME:             flags: DIFlagFwdDecl,
>  // CHECK-SAME:             identifier:
> "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
>
> -// This type isn't, however, even with standalone non-module debug info
> this
> -// type is a forward declaration.
> -// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name:
> "traits<int>",
> +// This type isn't, however, it is a template parameter type and so gets a
> +// forward declaration.
> +// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
> +// CHECK-SAME:             name: "traits<int>",
> +// CHECK-SAME:             scope: ![[NS]],
> +// CHECK-SAME:             flags: DIFlagFwdDecl,
> +// CHECK-SAME:             identifier: "_ZTSN8DebugCXX6traitsIiEE")
>
>  // This one isn't.
>  // CHECK: !DICompositeType(tag: DW_TAG_class_type,
> Index: test/CodeGenCXX/debug-info-template-fwd-param.cpp
> ===================================================================
> --- test/CodeGenCXX/debug-info-template-fwd-param.cpp
> +++ test/CodeGenCXX/debug-info-template-fwd-param.cpp
> @@ -0,0 +1,25 @@
> +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin
> -debug-info-kind=limited -emit-llvm -o - | FileCheck %s
> +// A forward declaration of a template should still have template
> parameters.
> +
> +template<typename T> class A {
> +public:
> +  A(T val);
> +private:
> +  T x;
> +};
> +
> +struct B {
> +  A<const int> *p;
> +};
> +
> +B b;
> +
> +// CHECK:      !DICompositeType(tag: DW_TAG_class_type, name: "A<const
> int>"
> +// CHECK-SAME:     flags: DIFlagFwdDecl
> +// CHECK-SAME:     templateParams: [[PARAM_LIST:![0-9]*]]
> +// CHECK:      [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]}
> +// CHECK:      [[PARAM]] = !DITemplateTypeParameter(name: "T",
> +// CHECK-SAME:     type: [[CTYPE:![0-9]*]]
> +// CHECK:      [[CTYPE]] = !DIDerivedType(tag: DW_TAG_const_type
> +// CHECK-SAME:     baseType: [[BTYPE:![0-9]*]]
> +// CHECK:      [[BTYPE]] = !DIBasicType(name: "int"
> Index: lib/CodeGen/CGDebugInfo.cpp
> ===================================================================
> --- lib/CodeGen/CGDebugInfo.cpp
> +++ lib/CodeGen/CGDebugInfo.cpp
> @@ -805,6 +805,10 @@
>    llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
>        getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
>        llvm::DINode::FlagFwdDecl, FullName);
> +  if (const ClassTemplateSpecializationDecl *TSpecial =
> +          dyn_cast<ClassTemplateSpecializationDecl>(RD))
> +    DBuilder.replaceArrays(RetTy, llvm::DINodeArray(),
> +                           CollectCXXTemplateParams(TSpecial, DefUnit));
>    ReplaceMap.emplace_back(
>        std::piecewise_construct, std::make_tuple(Ty),
>        std::make_tuple(static_cast<llvm::Metadata *>(RetTy)));
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170711/6c10f3ee/attachment-0001.html>


More information about the cfe-commits mailing list