[clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

Amy Huang via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 7 10:11:37 PDT 2025


amykhuang wrote:

> We have internal reports of incorrect mangling substitutions after updating to [537b654](https://github.com/llvm/llvm-project/commit/537b6541e8067d7ef7aa38791989fca6303b7fdf) from [799e905](https://github.com/llvm/llvm-project/commit/799e9053641a6478d3144866a97737b37b87c260), and this change seems like the likely culprit because it's touching the Itanium mangling code. We'll see if that can be confirmed.

Confirmed it is due to this change; the bug report is that some instances of `absl::container_internal::AbslHashValue` have an incorrect mangled name. 

The internal repro builds a test with a dependency on a file like
```
$ cat hash_mangling.cc
#include "[...]/hash_mangling.h"
#include <string>
#include "third_party/absl/container/flat_hash_set.h"

void f(absl::flat_hash_set<absl::flat_hash_set<std::string>>& s,
       const absl::flat_hash_set<std::string>& k) {
  s.insert(k);
}

$ llvm-readelf-19 -s -W hash_mangling.pic.o | grep XsrNT_S6_11is_hashable
    26: 0000000000000000   336 FUNC    WEAK   DEFAULT    39 _ZN4absl18container_internal13AbslHashValueINS_13hash_internal15MixingHashStateEEENSt3__u9enable_ifIXsrNT_S6_11is_hashableINS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEE5valueES6_E4typeES6_RKNS0_12raw_hash_setINS0_17FlatHashSetPolicyISD_EENS0_10StringHashENS0_8StringEqENSB_ISD_EEEE
```

>From the internal bug report, 
> The error here is the substitution S6_ in ...XsrNT_S6_11is_hashable.... The grammar for <unresolved-name> in https://itanium-cxx-abi.github.io/cxx-abi/abi.html#expressions does not permit a substitution here. S6_ would refer to T_, the immediately preceding use of the template parameter. It is as if the H:: in H::template is_hashable<value_type>::value at `absl/container/internal/raw_hash_set.h;l=3020` is being accidentally encoded twice.

I'm still trying to come up with a reduced repro though.

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


More information about the cfe-commits mailing list