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

[Clang][ItaniumMangle] Lambda mangling does not preserve field-name closure-prefix

Open eiytoq opened this issue 8 months ago • 1 comments

Compare the following in clang vs. gcc:

struct E {
  template<typename T>
  E(T t);
};

template<typename T>
E::E(T t) {
  struct{
    int anotherValue = [x = 1] { return x; }();
  } obj;
}

E e(1);

Reproducer: https://godbolt.org/z/eWGWjoeM1

Mangled symbols: clang: _ZZN1EC1IiEET_ENKUt_UlvE_clEv gcc: _ZZN1EC4IiEET_ENKUt_12anotherValueMUlvE_clEv

Clang appears to drop the field-name closure-prefix (12anotherValueM) in the lambda mangling.

clang version 22.1.2 gcc version 15.2.1 20260209 (GCC)

Originally posted by @efriedma-quic in https://github.com/llvm/llvm-project/pull/181068#discussion_r3037281491

eiytoq avatar Apr 05 '26 22:04 eiytoq

@llvm/issue-subscribers-clang-frontend

Author: eiytoq (eiytoq)

Compare the following in clang vs. gcc:
struct E {
  template&lt;typename T&gt;
  E(T t);
};

template&lt;typename T&gt;
E::E(T t) {
  struct{
    int anotherValue = [x = 1] { return x; }();
  } obj;
}

E e(1);

Compile commands:

clang++ -std=c++20 -c test.cpp -o test.clang.o g++ -std=c++20 -fkeep-inline-functions -c test.cpp -o test.gcc.o

Mangled symbols:

clang: _ZZN1EC1IiEET_ENKUt_UlvE_clEv gcc: _ZZN1EC4IiEET_ENKUt_12anotherValueMUlvE_clEv

Clang appears to drop the field-name closure-prefix (12anotherValueM) in the lambda mangling.

clang version 22.1.2 gcc version 15.2.1 20260209 (GCC)

Originally posted by @efriedma-quic in https://github.com/llvm/llvm-project/pull/181068#discussion_r3037281491

llvmbot avatar Apr 05 '26 22:04 llvmbot