[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 8 08:18:43 PDT 2022


probinson added a comment.

In D123319#3437250 <https://reviews.llvm.org/D123319#3437250>, @dblaikie wrote:

> (@probinson as someone I've disagreed with about this before)
>
> Personally I think there's limited value in expressing 'auto' in DWARF at all - we could omit function declarations if the return type is not known (undeduced auto) and wouldn't lose much - basically treating them the same as templates that aren't instantiated yet.

The problem there is that then the CU where the function is defined is the only one where the type description would include that function; and if we are doing e.g. ctor homing, and that CU doesn't happen to construct any instances, then the function will still exist but not be described anywhere.  If you're not doing ctor homing, then only one CU's description will mention the auto function; so, whether the debugger knows about the auto function will randomly depend on which CU's description the debugger decided to keep.

I do understand the analogy to templates.  The difference I see is that DWARF actually has a way to describe auto function declarations, where it does not have a way to describe template declarations.

> (& I believe Sony does this for all functions anyway - only including them when they're defined, not including an exhaustive list of member functions in class definitions)

We have a private feature that (if you're not doing something like ctor homing, or using type units) will suppress mention of _unused_ functions, which works for us because our debugger will merge type descriptions from different units.  Most debuggers don't do that, generally keeping just whichever one they found first, and assuming the rest are duplicates.  Including auto functions only when defined means the various descriptions aren't actually duplicates, and so the debugger will randomly know or not know about the function depending on which description it picks.

It's true that omitting auto function declarations wouldn't affect Sony because we know how to merge descriptions anyway, but OTOH we never upstreamed the suppress-unused-declarations feature because AFAIK no other debugger understands how to handle the situation.  Deliberately introducing omitted declarations seems kinda wrong.  With templates we don't have a choice, but with auto functions we do.

I mean, if you're willing to omit auto functions, why wouldn't you be willing to omit other unused functions?  The argument that "we don't know the whole type" seems a bit weak, given that DWARF gives you a way to describe what's missing.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123319/new/

https://reviews.llvm.org/D123319



More information about the cfe-commits mailing list