[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
Thu Dec 5 19:30:11 PST 2019


dblaikie added a comment.

In D70524#1771709 <https://reviews.llvm.org/D70524#1771709>, @probinson wrote:

> In D70524#1771522 <https://reviews.llvm.org/D70524#1771522>, @shafik wrote:
>
> > @probinson I was reading the C++ "auto" return type <http://dwarfstd.org/ShowIssue.php?issue=131217.1> issue and I can't come up with a case where we don't have class descriptions across compilation units that are not consistent wrt to auto return type. Do you have a specific example?
>
>
> The actual return type is known in a compile_unit where the method is defined, and not known in other compile_units.  If the non-defining compile_units omit the return type, that means "void" not "auto".  That is, one compile unit says it returns "void" and another compile unit says it returns something else.  That is the inconsistency I meant.
>
> If we use unspecified_type instead of omitting the return type, then a consumer knows that the method returns *something*, but it will have to look elsewhere to determine what that is.


Yeah, my argument was to omit the declarations of auto-returning functions entirely except in cases where their definition is available (either only when the definition is emitted, or whenever the definition's available so the deduced return type can be provided), same as a template instantiation.

So the class would be missing the declaration of the function in cases where the definition isn't available - same as templates and implicit special members.

(yeah, you could take this to its logical extreme and say we should treat all member functions this way - never produce a whole class definition enumerating all members - Eric and I have bandied that idea about as "classes as namespaces" more or less (the members in a class definition in one CU aren't necessarily the same as those in another, and a consumer would have to consider all of them together like it would have to for namespaces))

& honestly it's going to be pretty uncommon that any of this comes up - people aren't likely to separate their auto-returning function declaration from its definition. It'd be awkward to read code like that.


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

https://reviews.llvm.org/D70524





More information about the cfe-commits mailing list