[libcxx-commits] [PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

Douglas Yung via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 21 18:36:41 PDT 2023


dyung added a comment.

Hi @rsmith, we have an internal test where your change seems to have changed the mangling in C++17 mode and wanted to check if that was intentional.

Consider the following code:

  // Literals in templates
  #include <cstddef>
  template <typename T, T I> T returnit() {return I;};
  enum colour { RED = -3, GREEN, BLUE};
  // use long type for enumeration
  enum bigcolour { YELLOW = (1l << 32), CYAN, MAGENTA};
  void callreturnit() {
      auto a = returnit<int, 4>();
      auto b = returnit<unsigned int, 4>();
      auto c = returnit<long, 4>();
      auto d = returnit<unsigned long, 4>();
      auto e = returnit<long long, -456789>();
      auto f = returnit<bool, true>();
      auto g = returnit<bool, false>();
      auto n = returnit<std::nullptr_t, nullptr>();
      auto cg = returnit<colour, GREEN>();
      auto cy = returnit<bigcolour, YELLOW>();
  }

The compiler in C++17 mode now seems to differently mangle each instance:

| function                             | before                                    | after                                          |
| returnit<int, 4>();                  | _Z8returnitIiLi4EET_v                     | _Z8returnitIiTnT_Li4EES0_v                     |
| returnit<unsigned int, 4>();         | _Z8returnitIjLj4EET_v                     | _Z8returnitIjTnT_Lj4EES0_v                     |
| returnit<long, 4>();                 | _Z8returnitIlLl4EET_v                     | _Z8returnitIlTnT_Ll4EES0_v                     |
| returnit<unsigned long, 4>();        | _Z8returnitImLm4EET_v                     | _Z8returnitImTnT_Lm4EES0_v                     |
| returnit<long long, -456789>();      | _Z8returnitIxLxn456789EET_v               | _Z8returnitIxTnT_Lxn456789EES0_v               |
| returnit<bool, true>();              | _Z8returnitIbLb1EET_v                     | _Z8returnitIbTnT_Lb1EES0_v                     |
| returnit<bool, false>();             | _Z8returnitIbLb0EET_v                     | _Z8returnitIbTnT_Lb0EES0_v                     |
| returnit<std::nullptr_t, nullptr>(); | _Z8returnitIDnLDn0EET_v                   | _Z8returnitIDnTnT_LDn0EES0_v                   |
| returnit<colour, GREEN>();           | _Z8returnitI6colourLS0_n2EET_v            | _Z8returnitI6colourTnT_LS0_n2EES1_v            |
| returnit<bigcolour, YELLOW>();       | _Z8returnitI9bigcolourLS0_4294967296EET_v | _Z8returnitI9bigcolourTnT_LS0_4294967296EES1_v |
|

Are these changes in non-C++20 mode intentional?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147655/new/

https://reviews.llvm.org/D147655



More information about the libcxx-commits mailing list