-
Notifications
You must be signed in to change notification settings - Fork 97
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
Proposal: Include an optional specification for mangling names that reference anonymous symbols #158
Comments
I previously worked on a product that required stable names for anonymous and unnamed types such as those listed in the prior comment as well as for template definitions (not for specializations, but rather for primary template definitions and partial specialization definitions). I would therefore support an effort to specify a mangling for such types (and for templates) for use in tools like static analyzers and profilers; tools that have a need for names that remain (reasonably) stable as the source code evolves over time. |
Having a documented scheme that supports demangling of such names seems useful, even if it's not an ABI requirement. I think it would be preferable to use However, I think our starting point should be documenting the existing |
Thanks for the feedback @zygoloid. Using
I assume that isn't documented anywhere, I don't know how I would learn about it. I am a bit worried about having a different mangling for a symbol based on whether it is internal or external linkage though. What is the motivation for that? |
The motivation was to support the case where an internal-linkage symbol and an external-linkage symbol would otherwise have the same mangling and both be visible in the same translation unit / object file. I think all the cases where that could happen are no longer valid, but it used to be possible to do things like:
... where |
In some instances (see link below for some examples), it is very convenient to have stable names for symbols even when they have internal linkage. This is the case for anonymous types in C++. Discussion about extending the clang mangler suggested that I open an issue here to see about the feasibility of extending the specification with an optional specification for the mangling of names that reference anonymous types.
Here is a draft of some proposed changes to solicit feedback. This does not cover all possible issues, but it does cover many common issues. I can look into what it would require to make a formal PR if there is interest. Note that these should all be backwards compatible because they should be treated as opaque names.
Global Unnamed Structs
Prefix the name of the first declaration,
.y
.Anonymous enums
Use the name of the first enum value,
.X
.Unnamed Structs inside aggregates
Prefix the name of the first field with a
.
, e.g..x
. I think it is reasonable to repeat the.
for each nested aggregate, but we could also length encode it.The text was updated successfully, but these errors were encountered: