Issue 250122.1: DW_AT_object_pointer: clarify wording around implicit versus explicit object parameters
Author: | Michael Buch |
---|---|
Champion: | Adrian Prantl |
Date submitted: | 2025-01-22 |
Date revised: | |
Date closed: | 2025-02-03 |
Type: | Clarification |
Status: | Accepted with modifications |
DWARF version: | 6 |
Background
With C++23 we got the ability to explicitly spell out in source the
object parameter of a class method [1]. The object parameter for such
methods is not compiler-generated and is explicitly named by the user.
The wording of the current DWARF spec assumes object parameters are
implicit and specifies that those parameters be marked
DW_AT_artificial
, despite them not falling into the category for
"artificial" parameters.
Other examples of languages with explicit object parameters are Python and Rust.
Recently Clang started emitting DW_AT_object_pointer
for explicit
object parameters but decided not to mark them artificial [2, 3].
Overview
This proposal adjusts the wording in the DWARF spec to clarify that
explicit DW_AT_object_pointer
might not be marked
DW_AT_artificial
.
Proposed Changes
In chapter "5.7.8 Member Function Entries", change the mention of
DW_AT_artificial
in the last sentence as follows:
[ORIGINAL TEXT]
If the member function entry describes a non-static member function, then that entry has a
DW_AT_object_pointer
attribute whose value is a reference to the formal parameter entry that corresponds to the object for which the function is called. The name attribute of that formal parameter is defined by the current language (for example,this
for C++ orself
for Objective C and some other languages). That parameter also has aDW_AT_artificial
attribute whose value istrue
.
[NEW TEXT]
If the member function entry describes a non-static member function, then that entry has a
DW_AT_object_pointer
attribute whose value is a reference to the formal parameter entry that corresponds to the object for which the function is called. The name attribute of that formal parameter is defined by the current language (for example,this
for C++ orself
for Objective C and some other languages). Many languages make the object pointer an implicit parameter with no syntax. In that case the parameter should have aDW_AT_artificial
attribute whose value istrue
.
Alternatively we could just omit any mention of DW_AT_artificial
. And
we might want to add some informative text about C++23's explicit
object parameters.
2025-02-03: Accepted; will remove the sentence from Section 5.7.8.
Section 2.11 Artificial Entries is clear that using DW_AT_artificial
for this case is expected.