| 219 | |
| 220 | template <typename OutputIt> |
| 221 | auto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt { |
| 222 | # ifdef FMT_HAS_ABI_CXA_DEMANGLE |
| 223 | int status = 0; |
| 224 | size_t size = 0; |
| 225 | std::unique_ptr<char, void (*)(void*)> demangled_name_ptr( |
| 226 | abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &free); |
| 227 | |
| 228 | string_view demangled_name_view; |
| 229 | if (demangled_name_ptr) { |
| 230 | demangled_name_view = normalize_libcxx_inline_namespaces( |
| 231 | demangled_name_ptr.get(), demangled_name_ptr.get()); |
| 232 | } else { |
| 233 | demangled_name_view = string_view(ti.name()); |
| 234 | } |
| 235 | return detail::write_bytes<char>(out, demangled_name_view); |
| 236 | # elif FMT_MSC_VERSION && defined(_MSVC_STL_UPDATE) |
| 237 | return normalize_msvc_abi_name(ti.name(), out); |
| 238 | # elif FMT_MSC_VERSION && defined(_LIBCPP_VERSION) |
| 239 | const string_view demangled_name = ti.name(); |
| 240 | std::string name_copy(demangled_name.size(), '\0'); |
| 241 | // normalize_msvc_abi_name removes class, struct, union etc that MSVC has in |
| 242 | // front of types |
| 243 | name_copy.erase(normalize_msvc_abi_name(demangled_name, name_copy.begin()), |
| 244 | name_copy.end()); |
| 245 | // normalize_libcxx_inline_namespaces removes the inline __1, __2, etc |
| 246 | // namespaces libc++ uses for ABI versioning On MSVC ABI + libc++ |
| 247 | // environments, we need to eliminate both of them. |
| 248 | const string_view normalized_name = |
| 249 | normalize_libcxx_inline_namespaces(name_copy, name_copy.data()); |
| 250 | return detail::write_bytes<char>(out, normalized_name); |
| 251 | # else |
| 252 | return detail::write_bytes<char>(out, string_view(ti.name())); |
| 253 | # endif |
| 254 | } |
| 255 | |
| 256 | #endif // FMT_USE_RTTI |
| 257 |
no test coverage detected