[clang] [CodeGen] Added '*' to internal linkage types (PR #220864)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 7 04:36:26 PDT 2026
matthew-j-code wrote:
> How does this interact with libc++, and non-Linux targets?
The '' is emitted for both libc++ and libstdc++, but no comparison method for libc++ is affected by including ''. Libc++ has 3 implemented methods for comparison of typeinfo name, the default for internal-linkage types on ELF is pointer only comparison, which differs from libstdc++ strcmp (which is where the error stems from).
libcxx/include/typeinfo : (ELF default)
```
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
return __lhs == __rhs;
}
```
libcxx/include/typeinfo : (COFF default)
```
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;
}
```
libcxx/include/typeinfo : (Apple)
```
if (__lhs == __rhs)
return true;
if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
// Either both are unique and have a different address, or one of them
// is unique and the other one isn't. In both cases they are unequal.
return false;
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;
```
So operator== and dynamic_cast are unaffected everywhere.
name() changes, libstdc++ strips the prefix, libc++ returns it.
libstdc++ :
``` const char* name() const _GLIBCXX_NOEXCEPT
{ return __name[0] == '*' ? __name + 1 : __name; } ```
libc++ :
``` [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT {
return __impl::__type_name_to_string(__type_name);
} ```
Nothing currently tests this,
Every Itanium ABI target emits the * for internal linkage types, externally visible types are untouched everywhere. The MSVC ABI does not go through this code. z/OS additionally need it for both EBCDIC and ASCII encodings.
Happy to send a separate libc++ patch stripping the prefix in name() to match libstdc++, let me know what is preferred.
https://github.com/llvm/llvm-project/pull/220864
More information about the cfe-commits
mailing list