[all-commits] [llvm/llvm-project] 4b163e: Implement mangling rules for C++20 concepts and re...

Richard Smith via All-commits all-commits at lists.llvm.org
Wed Sep 20 12:38:45 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4b163e343cfa54c8d55c9da73c70d58f55ea9df2
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2023-09-20 (Wed, 20 Sep 2023)

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

  Log Message:
  Implement mangling rules for C++20 concepts and requires-expressions.

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=17` can be used to restore the old manglings for cases
which we could successfully but incorrectly mangle before.

Fixes #48216, #49884, #61273

Reviewed By: erichkeane, #libc_abi

Differential Revision: https://reviews.llvm.org/D147655

More information about the All-commits mailing list