Skip to content

write_demangled_name supports libc++ + clang-cl#4560

Merged
vitaut merged 1 commit intofmtlib:masterfrom
FatihBAKIR:stdtest-fix
Oct 8, 2025
Merged

write_demangled_name supports libc++ + clang-cl#4560
vitaut merged 1 commit intofmtlib:masterfrom
FatihBAKIR:stdtest-fix

Conversation

@FatihBAKIR
Copy link
Copy Markdown
Contributor

The current implementation assumes whenever we're on an FMT_MSC_VERSION compiler, the standard library is MSVC's STL. However, with clang-cl we have the possibility of using LLVM libc++ instead of MSVC STL. In that scenario, the previous implementation produced the wrong demangled names for RTTI types.

This patch detects the different combinations, and combines the existing demangling implementations to produce the correct names and make all tests pass on libc++ + clang-cl.

Fixes #4542

@FatihBAKIR
Copy link
Copy Markdown
Contributor Author

@vitaut the lint/format_code task is failing but it also points out a file I did not touch. I also formatted the files locally with clang-format using the .clang-format file in the repo, but it still complains in CI. What's the procedure here? Should I manually apply what the CI wants including the unrelated file?

@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Oct 2, 2025

The formatting issue in chrono.h has been fixed in #4557. Please rebase and it should go away.

@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Oct 4, 2025

As for the formatting issue in std.h, it might be caused by a different version of clang-format. I suggest applying the change from CI manually:

-auto normalize_msvc_abi_name(string_view abi_name_view,
-                             OutputIt out) -> OutputIt {
+auto normalize_msvc_abi_name(string_view abi_name_view, OutputIt out)
+    -> OutputIt {

The current implementation assumes whenever we're on an FMT_MSC_VERSION
compiler, the standard library is MSVC's STL. However, with clang-cl we
have the possibility of using LLVM libc++ instead of MSVC STL. In that
scenario, the previous implementation produced the wrong demangled names
for RTTI types.

This patch detects the different combinations, and combines the existing
demangling implementations to produce the correct names and make all
tests pass on libc++ + clang-cl.
@vitaut vitaut merged commit 03c7e28 into fmtlib:master Oct 8, 2025
41 checks passed
@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Oct 8, 2025

Thank you for the fix!

Comment on lines +142 to +143
string_view normalize_libcxx_inline_namespaces(string_view demangled_name_view,
char* begin) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should have been inline because it is defined in the header.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, mb

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 2, 2025
# 12.1.0 - 2025-10-29

- Optimized `buffer::append`, resulting in up to ~16% improvement on spdlog
  benchmarks (fmtlib/fmt#4541). Thanks @fyrsta7.

- Worked around an ABI incompatibility in `std::locale_ref` between clang and
  gcc (fmtlib/fmt#4573).

- Made `std::variant` and `std::expected` formatters work with `format_as`
  (fmtlib/fmt#4574,
  fmtlib/fmt#4575). Thanks @phprus.

- Made `fmt::join<string_view>` work with C++ modules
  (fmtlib/fmt#4379,
  fmtlib/fmt#4577). Thanks @Arghnews.

- Exported `fmt::is_compiled_string` and `operator""_cf` from the module
  (fmtlib/fmt#4544). Thanks @CrackedMatter.

- Fixed a compatibility issue with C++ modules in clang
  (fmtlib/fmt#4548). Thanks @tsarn.

- Added support for cv-qualified types to the `std::optional` formatter
  (fmtlib/fmt#4561,
  fmtlib/fmt#4562). Thanks @OleksandrKvl.

- Added demangling support (used in exception and `std::type_info` formatters)
  for libc++ and clang-cl
  (fmtlib/fmt#4542,
  fmtlib/fmt#4560,
  fmtlib/fmt#4568,
  fmtlib/fmt#4571).
  Thanks @FatihBAKIR and @rohitsutreja.

- Switched to global `malloc`/`free` to enable allocator customization
  (fmtlib/fmt#4569,
  fmtlib/fmt#4570). Thanks @rohitsutreja.

- Made the `FMT_USE_CONSTEVAL` macro configurable by users
  (fmtlib/fmt#4546). Thanks @SnapperTT.

- Fixed compilation with locales disabled in the header-only mode
  (fmtlib/fmt#4550).

- Fixed compilation with clang 21 and `-std=c++20`
  (fmtlib/fmt#4552).

- Fixed a dynamic linking issue with clang-cl
  (fmtlib/fmt#4576,
  fmtlib/fmt#4584). Thanks @FatihBAKIR.

- Fixed a warning suppression leakage on gcc
  (fmtlib/fmt#4588). Thanks @ZedThree.

- Made more internal color APIs `constexpr`
  (fmtlib/fmt#4581). Thanks @ishani.

- Fixed compatibility with clang as a host compiler for NVCC
  (fmtlib/fmt#4564). Thanks @valgur.

- Fixed various warnings and lint issues
  (fmtlib/fmt#4565,
  fmtlib/fmt#4572,
  fmtlib/fmt#4557).
  Thanks @LiangHuDream and @teruyamato0731.

- Improved documentation
  (fmtlib/fmt#4549,
  fmtlib/fmt#4551,
  fmtlib/fmt#4566,
  fmtlib/fmt#4567,
  fmtlib/fmt#4578,).
  Thanks @teruyamato0731, @petersteneteg and @zimmerman-dev.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std-test fails on clang-cl + libc++

2 participants