[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.
David Blaikie via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 17 14:56:41 PST 2019
dblaikie added a comment.
In D70524#1787566 <https://reviews.llvm.org/D70524#1787566>, @SouraVX wrote:
> > It looks like this implementation is a bit buggy in one way and incomplete in another:
> >
> > 1. even if the auto-returning function is defined, that function definition doesn't describe the concrete return type. Compare GCC and Clang's output for your example and note that... oh.
>
> I think that's correct behavior, consider this for a moment --
>
> struct foo {
> auto foo_func();
> };
> int foo::foo_func(){return 0;}
> clang error: ->
> error: return type of out-of-line definition of 'foo::foo_func' differs from that in the declaration
>
>
> So this seems fair to me, regardless of the concrete return type{assuming this is what this patch is doing}. We should be emitting `auto` in declaration. AKA in unspecified_type. GCC(trunk) also seems fair here.
Sorry, the example I had in mind was this:
struct type {
auto func();
};
auto type::func() {
return 3;
}
Which GCC produces:
DW_TAG_structure_type
DW_AT_name ("type")
DW_TAG_subprogram
DW_AT_name ("func")
DW_AT_type (DW_TAG_unspecified_type "auto")
...
DW_TAG_subprogram
DW_AT_specification (... ^)
DW_AT_type (DW_TAG_base_type "int")
...
(this should be the same debug info even if the function is defined inline in the class, rather than defined out of line (assuming the function's called - which produces a definition))
>> Hmm, maybe this feature/suggestion is broken or at least not exactly awesome when it comes to auto-returning functions that are eventually void-returning functions? Now the function definition has no DW_AT_type to override the unspecified_type in the declaration... :/ that's unfortunate (@probinson - thoughts?)
>
> I'm a bit confused here, regardless of the concrete return type{void/int/float} GCC(trunk) is emitting
> `DW_TAG_unspecified_type`
> `DW_AT_name "auto"`
> Are you trying to say we should be emitting `DW_AT_type void/int/float` ?? That's what functionality of clang is right now, and if we entertain that, then their is no point of emitting `DW_TAG_unspecifed_type auto` at first place.
As @probinson said - for the definition DIE/DISubprogram the type should be the concrete, deduced type. For the declaration DIE/DISubprogram, the return type should be "auto".
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70524/new/
https://reviews.llvm.org/D70524
More information about the cfe-commits
mailing list