[all-commits] [llvm/llvm-project] 50e541: [Clang][Sema] Retain the expanding index for uneva...

Younan Zhang via All-commits all-commits at lists.llvm.org
Mon Sep 30 17:19:56 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 50e5411e4247421fd606f0a206682fcdf0303ae3
      https://github.com/llvm/llvm-project/commit/50e5411e4247421fd606f0a206682fcdf0303ae3
  Author: Younan Zhang <zyn7109 at gmail.com>
  Date:   2024-10-01 (Tue, 01 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/SemaCXX/fold_lambda_with_variadics.cpp

  Log Message:
  -----------
  [Clang][Sema] Retain the expanding index for unevaluated type constraints (#109518)

(This continues the effort of #86265, fixing another piece of issue in
constraint evaluation on variadic lambdas.)

We need the depth of the primary template parameters for constraint
substitution. To that end, we avoided substituting type constraints by
copying the constraint expression when instantiating a template. This,
however, has left an issue in that for lambda's parameters, they can
reference outer template packs that would be expanded in the process of
an instantiation, where these parameters would make their way into the
constraint evaluation, wherein we have no other way to expand them later
in evaluation. For example,

    template <class... Ts> void foo() {
      bar([](C<Ts> auto value) {}...);
    }

The lambda references a pack `Ts` that should be expanded when
instantiating `foo()`. The `Ts` along with the constraint expression
would not be transformed until constraint evaluation, and at that point,
we would have no chance to expand `Ts` anyhow.

This patch takes an approach that transforms `Ts` from an unexpanded
TemplateTypeParmType into a SubstTemplateTypeParmType with the current
pack substitution index, such that we could use that to expand the type
during evaluation.

Fixes #101754



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