Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DebugInfo] DW_AT_object_pointer not emitted for explicit object parameter #120974

Open
Michael137 opened this issue Dec 23, 2024 · 2 comments
Open

Comments

@Michael137
Copy link
Member

Using C++23's deducing this:

struct Foo {
    void x(this Foo && self) {}
};

int main() { Foo{}.x(); }

Neither Clang nor GCC attach a DW_AT_object_pointer to the this parameter DIE:
https://godbolt.org/z/h4jeT54G5

We probably should be doing so (LLDB will need to rely on this attribute in the future to distinguish static vs. non-static methods..see #120973).
In the DWARFv5 spec chapter "5.7.8 Member Function Entries" we state:

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++ or self for Objective C and some other
languages). That parameter also has a DW_AT_artificial attribute whose value is
true.
Conversely, if the member function entry describes a static member function, the
entry does not have a DW_AT_object_pointer attribute.

<non-normative>
In C++, non-static member functions can have const-volatile qualifiers, which affect the
type of the first formal parameter (the “this”-pointer).
</non-normative>

Might be worth updating the non-normative text in this section. @dwblaikie @adrian-prantl

@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2024

@llvm/issue-subscribers-debuginfo

Author: Michael Buch (Michael137)

Using C++23's `deducing this`: ``` struct Foo { void x(this Foo && self) {} };

int main() { Foo{}.x(); }


Neither Clang nor GCC attach a `DW_AT_object_pointer` to the `this` parameter DIE: 
https://godbolt.org/z/h4jeT54G5

We probably should be doing so (LLDB will need to rely on this attribute in the future to distinguish static vs. non-static methods..see https://github.com/llvm/llvm-project/issues/120973).
In the DWARFv5 spec chapter "5.7.8 Member Function Entries" we state:

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++ or self for Objective C and some other
languages). That parameter also has a DW_AT_artificial attribute whose value is
true.
Conversely, if the member function entry describes a static member function, the
entry does not have a DW_AT_object_pointer attribute.

<non-normative>
In C++, non-static member functions can have const-volatile qualifiers, which affect the
type of the first formal parameter (the “this”-pointer).
</non-normative>


Might be worth updating the non-normative text in this section. @<!-- -->dwblaikie @<!-- -->adrian-prantl 
</details>

@Michael137
Copy link
Member Author

Came up in #120856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants