<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 5, 2014, at 3:49 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" class="">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><br class=""><div class="gmail_quote">On Fri, Sep 5, 2014 at 3:43 PM, Duncan P. N. Exon Smith <span dir="ltr" class=""><<a href="mailto:dexonsmith@apple.com" target="_blank" class="">dexonsmith@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br class="">
> On 2014 Sep 5, at 16:01, Frédéric Riss <<a href="mailto:friss@apple.com" class="">friss@apple.com</a>> wrote:<br class="">
><br class="">
> I couldn’t even find a subject expressing exactly what this patch is about… First of all, it’s meant to start a discussion, and I’m not proposing it for inclusion right now.<br class="">
><br class="">
> The issue I’m trying to address is that template types are always canonicalized when emitted in the debug information (this is the desugar() call in UnwrapTypeForDebugInformation).<br class="">
><br class="">
> This means that if the developer writes:<br class="">
><br class="">
> typedef int A;<br class="">
> template <typename T><br class="">
> struct S {};<br class="">
><br class="">
> S<A> var;<br class="">
><br class="">
> The variable var will have type S<int> and not S<A>. In this simple example, it’s not that much of an issue, but for heavily templated code, the full expansion might be really different from the original declaration.<br class="">
><br class="">
> The attached patch makes us emit an intermediate typedef for the variable’s type:<br class="">
><br class="">
> 0x0000002a:   DW_TAG_variable [2]<br class="">
>                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000032] = “var")<br class="">
>                DW_AT_type [DW_FORM_ref4]       (cu + 0x0040 => {0x00000040})<br class="">
>                DW_AT_external [DW_FORM_flag]   (0x01)<br class="">
>                DW_AT_decl_file [DW_FORM_data1] (0x01)<br class="">
>                DW_AT_decl_line [DW_FORM_data1] (8)<br class="">
>                DW_AT_location [DW_FORM_block1] (<0x09> 03 70 6c 00 00 00 00 00 00 )<br class="">
><br class="">
> 0x00000040:   DW_TAG_typedef [3]<br class="">
>                DW_AT_type [DW_FORM_ref4]       (cu + 0x004b => {0x0000004b})<br class="">
>                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000035] = “S<A>")<br class="">
>                DW_AT_decl_file [DW_FORM_data1] (0x01)<br class="">
>                DW_AT_decl_line [DW_FORM_data1] (6)<br class="">
><br class="">
> 0x0000004b:   DW_TAG_structure_type [4] *<br class="">
>                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x0000003e] = “S<int>")<br class="">
>                DW_AT_byte_size [DW_FORM_data1] (0x01)<br class="">
>                DW_AT_decl_file [DW_FORM_data1] (0x01)<br class="">
>                DW_AT_decl_line [DW_FORM_data1] (6)<br class="">
><br class="">
><br class="">
> Which basically is what I want, although I don’t like that it introduces a typedef where there is none in the code. I’d prefer that to be:<br class="">
><br class="">
> DW_TAG_variable<br class="">
>  DW_AT_type: -> DW_TAG_structure_type<br class="">
>                   DW_AT_name: S<A><br class="">
>                   DW_AT_specification: -> DW_TAG_structure_type<br class="">
>                                             DW_AT_name: S<int><br class="">
>                                             …<br class="">
><br class="">
> The patch also has the nice property of omitting the defaulted template arguments in the first level typedef. For example you get vector<A> instead of vector<int, std::__1::allocator<int> >.<br class="">
<br class="">
</div></div>If you specify `vector<int>` in C++ do you get that instead of<br class="">
`vector<int, std::__1::allocator<int>>`?<br class=""></blockquote><div class=""><br class=""></div><div class="">Yeah, I mentioned this as possibly causing problems with debuggers or other consumers, but I don't have any proof past "ooooo scary!”.</div></div></div></div></div></blockquote><div><br class=""></div>Well, [+lldb-dev], could this confuse debuggers? :-)</div><div><br class=""></div><div>-- adrian<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">That said, I like the idea personally :)</div><div class=""><br class=""></div><div class="">-eric</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br class="">
> Now there is one thing I really don’t like about the patch. In order not to emit typedefs for types that don’t need it, I use string comparison between the desugared and the original type. I haven’t quantified anything, but doing the construction of the type name for every template type and then comparing it to decide to use it or not seems like a big waste.<br class="">
<br class="">
</span>Maybe someone on cfe-dev knows a better way.<br class="">
<br class="">
><br class="">
> Thoughts?<br class="">
><br class="">
> <template-arg-typedefs.diff><br class="">
><br class="">
> Fred<br class="">
><br class="">
><br class="">
><br class="">
><br class="">
><br class="">
> _______________________________________________<br class="">
> llvm-commits mailing list<br class="">
> <a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class="">
<br class="">
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>