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

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 5 12:33:54 PDT 2023


rsmith created this revision.
rsmith added reviewers: rjmccall, aaron.ballman, erichkeane.
Herald added a project: All.
rsmith requested review of this revision.
Herald added projects: clang, libc++abi, LLVM.
Herald added subscribers: llvm-commits, libcxx-commits, cfe-commits.
Herald added a reviewer: libc++abi.

This implements proposals from:

- https://github.com/itanium-cxx-abi/cxx-abi/issues/24: mangling for constraints, requires-clauses, requires-expressions.
- https://github.com/itanium-cxx-abi/cxx-abi/issues/31: requires-clauses and template parameters in a lambda expression are mangled into the <lambda-sig>.
- https://github.com/itanium-cxx-abi/cxx-abi/issues/47 (STEP 3): mangling for template argument is prefixed by mangling of template parameter declaration if it's not "obvious", for example because the template parameter is constrained (we already implemented STEP 1 and STEP 2).

This changes the manglings for a few cases:

- Functions and function templates with constraints.
- Function templates with template parameters with deduced types: `typename<auto N> void f();`
- Function templates with template template parameters where the argument has a different template-head: `template<template<typename...T>> void f(); f<std::vector>();`

In each case where a mangling changed, the change fixes a mangling collision.

Note that only function templates are affected, not class templates or variable
templates, and only new constructs (template parameters with deduced types,
constrained templates) and esoteric constructs (templates with template
template parameters with non-matching template template arguments, most of
which Clang still does not accept by default due to
`-frelaxed-template-template-args` not being enabled by default), so the risk
to ABI stability from this change is relatively low. Nonetheless,
`-fclang-abi-compat=16` can be used to restore the old manglings for cases
which we could successfully but incorrectly mangle before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147655

Files:
  clang/include/clang/AST/ExprConcepts.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConcepts.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CodeGenCXX/mangle-concept.cpp
  clang/test/CodeGenCXX/mangle-exprs.cpp
  clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp
  clang/test/CodeGenCXX/mangle-requires.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/matrix-type.cpp
  clang/test/OpenMP/tile_codegen.cpp
  libcxxabi/src/demangle/ItaniumDemangle.h
  libcxxabi/src/demangle/ItaniumNodes.def
  libcxxabi/test/test_demangle.pass.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h
  llvm/include/llvm/Demangle/ItaniumNodes.def
  llvm/include/llvm/Demangle/StringView.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147655.511185.patch
Type: text/x-patch
Size: 129428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230405/3c96cbaa/attachment-0001.bin>


More information about the cfe-commits mailing list