[clang] [clang] Correct Microsoft mangling of lifetime extended temporary objects. (PR #85529)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 16 08:21:06 PDT 2024


================
@@ -54,6 +54,12 @@ ABI Changes in This Version
   inline member function that contains a static local variable with a dynamic
   initializer is declared with ``__declspec(dllimport)``. (#GH83616).
 
+- Fixed Microsoft name mangling of lifetime extended temporary objects. This
+  change corrects missing back reference registrations that could result in
+  incorrect back reference indexes and suprising demangled name results. Since
+  MSVC uses a different mangling for these objects, compatibility is not affected.
+  (#GH85423).
----------------
tahonermann wrote:

Commit https://github.com/llvm/llvm-project/commit/e77de75d7e009daaadb03e9b1091c3a9a9c9d311 claims that Microsoft doesn't have a mangling for these objects and that the `$RT` mangling is a Clang invention. The claim that MSVC doesn't implement a mangling for these doesn't seem right though. Consider https://godbolt.org/z/n715zPbc6. It appears that MSVC (back to at least v19.14) uses a `$S<discriminator>` mangling for these; like that used for other unnamed objects like for structured bindings, anonymous unions, and (non-thread-safe) guards for static local variables. Further, I think https://godbolt.org/z/x1Kh57818 demonstrates a Clang/MSVC compatibility issue. The code Clang emits for `h()` for the inlining of `g()` attempts to import `__imp_?$RT1 at singleton@?1??g@@YAHXZ at 4ABUS@@B` while MSVC's code attempts to import `__imp_?$S1@?1??g@@YAHXZ at 4US@@B`.

Assuming agreement with the analysis above, I'll file a new issue for the divergent mangling.

https://github.com/llvm/llvm-project/pull/85529


More information about the cfe-commits mailing list