[all-commits] [llvm/llvm-project] 4fb1c5: [clang] Finish implementation of P0522

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Tue Jul 30 17:05:41 PDT 2024


  Branch: refs/heads/users/mizvekov/clang-p0522-complete-implementation
  Home:   https://github.com/llvm/llvm-project
  Commit: 4fb1c50098372d6b2f1bc50948ffdf56e1a9efff
      https://github.com/llvm/llvm-project/commit/4fb1c50098372d6b2f1bc50948ffdf56e1a9efff
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2024-07-30 (Tue, 30 Jul 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Frontend/FrontendActions.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
    M clang/test/CXX/temp/temp.param/p12.cpp
    M clang/test/Modules/cxx-templates.cpp
    M clang/test/SemaCXX/make_integer_seq.cpp
    M clang/test/SemaTemplate/cwg2398.cpp
    M clang/test/SemaTemplate/temp_arg_nontype.cpp
    M clang/test/SemaTemplate/temp_arg_template.cpp
    M clang/test/SemaTemplate/temp_arg_template_p0522.cpp
    M clang/test/Templight/templight-empty-entries-fix.cpp
    M clang/test/Templight/templight-prior-template-arg.cpp
    M libcxx/test/libcxx/type_traits/is_specialization.verify.cpp

  Log Message:
  -----------
  [clang] Finish implementation of P0522

This finishes the clang implementation of P0522, getting rid
of the fallback to the old, pre-P0522 rules.

Before this patch, when partial ordering template template parameters,
we would perform, in order:
* If the old rules would match, we would accept it. Otherwise, don't
  generate diagnostics yet.
* If the new rules would match, just accept it. Otherwise, don't
  generate any diagnostics yet again.
* Apply the old rules again, this time with diagnostics.

This situation was far from ideal, as we would sometimes:
* Accept some things we shouldn't.
* Reject some things we shouldn't.
* Only diagnose rejection in terms of the old rules.

With this patch, we apply the P0522 rules throughout.

This needed to extend template argument deduction in order
to accept the historial rule for TTP matching pack parameter to non-pack
arguments.
This change also makes us accept some combinations of historical and P0522
allowances we wouldn't before.

It also fixes a bunch of bugs that were documented in the test suite,
which I am not sure there are issues already created for them.

This causes a lot of changes to the way these failures are diagnosed,
with related test suite churn.

The problem here is that the old rules were very simple and
non-recursive, making it easy to provide customized diagnostics,
and to keep them consistent with each other.

The new rules are a lot more complex and rely on template argument
deduction, substitutions, and they are recursive.

The approach taken here is to mostly rely on existing diagnostics,
and create a new instantiation context that keeps track of this context.

So for example when a substitution failure occurs, we use the error
produced there unmodified, and just attach notes to it explaining
that it occurred in the context of partial ordering this template
argument against that template parameter.

This diverges from the old diagnostics, which would lead with an
error pointing to the template argument, explain the problem
in subsequent notes, and produce a final note pointing to the parameter.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list