[all-commits] [llvm/llvm-project] 28ad89: Reland: [clang] unified CWG2398 and P0522 changes; ...

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Thu Jan 23 15:37:55 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 28ad8978ee2054298d4198bf10c8cb68730af037
      https://github.com/llvm/llvm-project/commit/28ad8978ee2054298d4198bf10c8cb68730af037
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2025-01-23 (Thu, 23 Jan 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Overload.h
    M clang/include/clang/Sema/Sema.h
    M clang/include/clang/Sema/TemplateDeduction.h
    M clang/lib/Frontend/FrontendActions.cpp
    M clang/lib/Sema/SemaLookup.cpp
    M clang/lib/Sema/SemaOverload.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:
  -----------
  Reland: [clang] unified CWG2398 and P0522 changes; finishes implementation of P3310 (#124137)

This patch relands the following PRs:
* #111711
* #107350
* #111457

All of these patches were reverted due to an issue reported in
https://github.com/llvm/llvm-project/pull/111711#issuecomment-2406491485,
due to interdependencies.

---
[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.

---
[clang] CWG2398: improve overload resolution backwards compat

With this change, we discriminate if the primary template and which partial
specializations would have participated in overload resolution prior to
P0522 changes.

We collect those in an initial set. If this set is not empty, or the
primary template would have matched, we proceed with this set as the
candidates for overload resolution.

Otherwise, we build a new overload set with everything else, and proceed
as usual.

---
[clang] Implement TTP 'reversed' pack matching for deduced function template calls.

Clang previously missed implementing P0522 pack matching
for deduced function template calls.



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