[all-commits] [llvm/llvm-project] facc57: [Clang][RFC] Bypass TAD during overload resolution...

cor3ntin via All-commits all-commits at lists.llvm.org
Wed Apr 16 10:10:06 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: facc57fc25d0f05f5834fed421662dbad3ec5b50
      https://github.com/llvm/llvm-project/commit/facc57fc25d0f05f5834fed421662dbad3ec5b50
  Author: cor3ntin <corentinjabot at gmail.com>
  Date:   2025-04-16 (Wed, 16 Apr 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Sema/Overload.h
    M clang/lib/Sema/SemaCodeComplete.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/test/CXX/temp/temp.constr/temp.constr.atomic/constrant-satisfaction-conversions.cpp
    M clang/test/SemaCUDA/function-overload.cu
    M clang/test/SemaCXX/implicit-member-functions.cpp
    A clang/test/SemaCXX/overload-resolution-deferred-templates.cpp
    M clang/test/SemaTemplate/instantiate-function-params.cpp
    M clang/test/Templight/templight-empty-entries-fix.cpp

  Log Message:
  -----------
  [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (#133426)

This implements the same overload resolution behavior as GCC, 
as described in https://wg21.link/p3606 (sections 1-2, not 3)

If, during overload resolution, a non-template candidate is always
picked because each argument is a perfect match (i.e., the source and
target types are the same), we do not perform deduction for any template
candidate that might exist.

The goal is to be able to merge #122423 without being too disruptive.

This change means that the selection of the best viable candidate and
template argument deduction become interleaved.

To avoid rewriting half of Clang, we store in `OverloadCandidateSet`
enough information to deduce template candidates from
`OverloadCandidateSet::BestViableFunction`. This means the lifetime of
any object used by the template argument must outlive a call to
`Add*Template*Candidate`.

This two-phase resolution is not performed for some initialization as
there are cases where template candidates are a better match per the
standard. It's also bypassed for code completion.

The change has a nice impact on compile times

https://llvm-compile-time-tracker.com/compare.php?from=edc22c64e527171041876f26a491bb1d03d905d5&to=8170b860bd4b70917005796c05a9be013a95abb2&stat=instructions%3Au

Fixes #62096
Fixes #74581
Fixes #53454



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