llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

llvm-cxxfilt build configurations can show formatting differences for floating point literals

Open bd1976bris opened this issue 2 years ago • 1 comments

namespace cxx20 {
  template<auto> struct A {};
  void f(A<1.0>) {}
};

Is mangled as _ZN5cxx201fENS_1AILd3ff0000000000000EEE.

For a Visual Studio 2019 build llvm-cxxfilt demangles as cxx20::f(cxx20::A<0x1.0000000000000p+0>) however for a Linux build with glibc it is demanged as: cxx20::f(cxx20::A<0x1p+0>). This occurs as the implementation calls snprintf and the differing implementations have minor output variations. See: https://github.com/llvm/llvm-project/blob/023cdfcc1a5bdef7f12bb6da9328f93b477c38b8/llvm/include/llvm/Demangle/ItaniumDemangle.h#L2575

Ideally, the output of llvm-cxxfilt should be consistent.

One solution might be just to dump the hexadecimal string from the mangled name. This would match what GNU appears to do. For example GNU cxxfilt demangles to: cxx20::f(cxx20::A<(double)[3ff0000000000000]>). See: https://github.com/llvm/llvm-project/issues/92081 for, possibly, more motivation for just dumping the hexadecimal string.

bd1976bris avatar May 14 '24 08:05 bd1976bris

@llvm/issue-subscribers-tools-llvm-cxxfilt

Author: bd1976bris (bd1976bris)

``` namespace cxx20 { template<auto> struct A {}; void f(A<1.0>) {} }; ``` Is mangled as `_ZN5cxx201fENS_1AILd3ff0000000000000EEE`.

For a Visual Studio 2019 build llvm-cxxfilt demangles as cxx20::f(cxx20::A&lt;0x1.0000000000000p+0&gt;) however for a Linux build with glibc it is demanged as: cxx20::f(cxx20::A&lt;0x1p+0&gt;). This occurs as the implementation calls snprintf and the differing implementations have minor output variations. See: https://github.com/llvm/llvm-project/blob/023cdfcc1a5bdef7f12bb6da9328f93b477c38b8/llvm/include/llvm/Demangle/ItaniumDemangle.h#L2575

Ideally, the output of the llvm-cxxfilt should be consistent.

One solution might be just to dump the hexadecimal string from the mangled name. This would match what GNU appears to do. For example GNU cxxfilt demangles to: cxx20::f(cxx20::A&lt;(double)[3ff0000000000000]&gt;). See: https://github.com/llvm/llvm-project/issues/92081 for, possibly, more motivation for just dumping the hexadecimal string.

llvmbot avatar May 14 '24 09:05 llvmbot