[all-commits] [llvm/llvm-project] e0d173: [Clang] [AST] Fix placeholder return type name man...
Max Winkler via All-commits
all-commits at lists.llvm.org
Wed Aug 14 21:52:19 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e0d173d44161bf9b68243845666d58999e74f759
https://github.com/llvm/llvm-project/commit/e0d173d44161bf9b68243845666d58999e74f759
Author: Max Winkler <max.enrico.winkler at gmail.com>
Date: 2024-08-14 (Wed, 14 Aug 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/AST/MicrosoftMangle.cpp
A clang/test/CodeGenCXX/mangle-ms-auto-return.cpp
M clang/test/CodeGenCXX/mangle-ms-auto-templates-memptrs.cpp
M clang/test/CodeGenCXX/mangle-ms-auto-templates-nullptr.cpp
M clang/test/CodeGenCXX/mangle-ms-auto-templates.cpp
Log Message:
-----------
[Clang] [AST] Fix placeholder return type name mangling for MSVC 1920+ / VS2019+ (#102848)
Partial fix for https://github.com/llvm/llvm-project/issues/92204.
This PR just fixes VS2019+ since that is the suite of compilers that I
require link compatibility with at the moment.
I still intend to fix VS2017 and to update llvm-undname in future PRs.
Once those are also finished and merged I'll close out
https://github.com/llvm/llvm-project/issues/92204.
I am hoping to get the llvm-undname PR up in a couple of weeks to be
able to demangle the VS2019+ name mangling.
MSVC 1920+ mangles placeholder return types for non-templated functions
with "@".
For example `auto foo() { return 0; }` is mangled as `?foo@@YA at XZ`.
MSVC 1920+ mangles placeholder return types for templated functions as
the qualifiers of the AutoType followed by "_P" for `auto` and "_T" for
`decltype(auto)`.
For example `template<class T> auto foo() { return 0; }` is mangled as
`??$foo at H@@YA?A_PXZ` when `foo` is instantiated as follows `foo<int>()`.
Lambdas with placeholder return types are still mangled with clang's
custom mangling since MSVC lambda mangling hasn't been deciphered yet.
Similarly any pointers in the return type with an address space are
mangled with clang's custom mangling since that is a clang extension.
We cannot augment `mangleType` to support this mangling scheme as the
mangling schemes for variables and functions differ.
auto variables are encoded with the fully deduced type where auto return
types are not.
The following two functions with a static variable are mangled the same
```
template<class T>
int test()
{
static int i = 0; // "?i@?1???$test at H@@YAHXZ at 4HA"
return i;
}
template<class T>
int test()
{
static auto i = 0; // "?i@?1???$test at H@@YAHXZ at 4HA"
return i;
}
```
Inside `mangleType` once we get to mangling the `AutoType` we have no
context if we are from a variable encoding or some other encoding.
Therefore it was easier to handle any special casing for `AutoType`
return types with a separate function instead of using the `mangleType`
infrastructure.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list