History log of /llvm-project/clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp (Results 1 – 11 of 11)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7
# 3972ed57 08-Jan-2025 Younan Zhang <zyn7109@gmail.com>

Revert "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130)

Unfortunately that breaks some code on Windows when lambdas come into
play, as reported in
https://github

Revert "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130)

Unfortunately that breaks some code on Windows when lambdas come into
play, as reported in
https://github.com/llvm/llvm-project/pull/102857#issuecomment-2577861178

This reverts commit 96eced624e0f120155256033fdcb8342e7e58d6e.

show more ...


# 96eced62 05-Jan-2025 Younan Zhang <zyn7109@gmail.com>

[Clang] Implement CWG2369 "Ordering between constraints and substitution" (#102857)

This patch partially implements CWG2369 for non-lambda-constrained
functions.

Lambdas are left intact at this poi

[Clang] Implement CWG2369 "Ordering between constraints and substitution" (#102857)

This patch partially implements CWG2369 for non-lambda-constrained
functions.

Lambdas are left intact at this point because we need extra work to
correctly instantiate captures before the function instantiation.

As a premise of CWG2369, this patch also implements CWG2770 to ensure
the function parameters are instantiated on demand.

Closes https://github.com/llvm/llvm-project/issues/54440

show more ...


Revision tags: llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# 3b639d7d 02-Jul-2024 Younan Zhang <zyn7109@gmail.com>

[Clang] Clarify diagnostic notes for implicitly generated deduction guides (#96084)

Given the following invalid code,
```cpp
template <class T>
struct S {
T *a;
};
S s = {1};
```
we produc

[Clang] Clarify diagnostic notes for implicitly generated deduction guides (#96084)

Given the following invalid code,
```cpp
template <class T>
struct S {
T *a;
};
S s = {1};
```
we produce such diagnostics currently:
```
<source>:2:8: note: candidate template ignored: could not match 'S<T>' against 'int'
2 | struct S {
| ^
<source>:2:8: note: candidate template ignored: could not match 'T *' against 'int'
```
Which I think is confusing because there's no `S<T>` nor `T *` at the
location it points to. This is because we're deducing the initializer
against implicitly generated deduction guides, and their source
locations just point to the corresponding `RecordDecl`. Hence the
misleading notes.

This patch alleviates the issue by adding extra notes demonstrating
which implicit deduction guide we're deducing against. In other words,
in addition to the note of `could not match 'T *' against 'int'`, we
would also say the implicit deduction guide we're trying to use:
`template <class T> S(T *) -> S<T>`, which looks clearer IMO.

---------

Co-authored-by: Sirraide <aeternalmail@gmail.com>

show more ...


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7
# 9c4a716c 29-May-2024 Matheus Izvekov <mizvekov@gmail.com>

[clang] Preserve Qualifiers and type sugar in TemplateNames (#93433)

This patch improves the preservation of qualifiers and loss of type
sugar in TemplateNames.

This problem is analogous to https:/

[clang] Preserve Qualifiers and type sugar in TemplateNames (#93433)

This patch improves the preservation of qualifiers and loss of type
sugar in TemplateNames.

This problem is analogous to https://reviews.llvm.org/D112374 and this
patch takes a very similar approach to that patch, except the impact
here is much lesser.

When a TemplateName was written bare, without qualifications, we
wouldn't produce a QualifiedTemplate which could be used to disambiguate
it from a Canonical TemplateName. This had effects in the TemplateName
printer, which had workarounds to deal with this, and wouldn't print the
TemplateName as-written in most situations.

There are also some related fixes to help preserve this type sugar along
the way into diagnostics, so that this patch can be properly tested.

- Fix dropping the template keyword.
- Fix type deduction to preserve sugar in TST TemplateNames.

show more ...


Revision tags: llvmorg-18.1.6
# 8c852ab5 10-May-2024 Younan Zhang <zyn7109@gmail.com>

[Clang][Sema] Revise the transformation of CTAD parameters of nested class templates (#91628)

This fixes a regression introduced by bee78b88f.

When we form a deduction guide for a constructor, ba

[Clang][Sema] Revise the transformation of CTAD parameters of nested class templates (#91628)

This fixes a regression introduced by bee78b88f.

When we form a deduction guide for a constructor, basically, we do the
following work:
- Collect template parameters from the constructor's surrounding class
template, if present.
- Collect template parameters from the constructor.
- Splice these template parameters together into a new template
parameter list.
- Turn all the references (e.g. the function parameter list) to the
invented parameter list by applying a `TreeTransform` to the function
type.

In the previous fix, we handled cases of nested class templates by
substituting the "outer" template parameters (i.e. those not declared at
the surrounding class template or the constructor) with the
instantiating template arguments. The approach per se makes sense, but
there was a flaw in the following case:

```cpp
template <typename U, typename... Us> struct X {
template <typename V> struct Y {
template <typename T> Y(T) {}
};

template <typename T> Y(T) -> Y<T>;
};

X<int>::Y y(42);
```

While we're transforming the parameters for `Y(T)`, we first attempt to
transform all references to `V` and `T`; then, we handle the references
to outer parameters `U` and `Us` using the template arguments from
`X<int>` by transforming the same `ParamDecl`. However, the first step
results in the reference `T` being `<template-param-0-1>` because the
invented `T` is the last of the parameter list of the deduction guide,
and what we're substituting with is a corresponding parameter pack
(which is `Us`, though empty). Hence we're messing up the substitution.

I think we can resolve it by reversing the substitution order, which
means handling outer template parameters first and then the inner
parameters.

There's no release note because this is a regression in 18, and I hope
we can catch up with the last release.

Fixes https://github.com/llvm/llvm-project/issues/88142

show more ...


Revision tags: llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init
# b3ea9b39 20-Jan-2024 antangelo <contact@antangelo.com>

Reland "[clang] Fix CTAD for aggregates for nested template classes" (#78670)

Reland of #78387

Use the template pattern in determining whether to synthesize the
aggregate deduction guide, and up

Reland "[clang] Fix CTAD for aggregates for nested template classes" (#78670)

Reland of #78387

Use the template pattern in determining whether to synthesize the
aggregate deduction guide, and update
DeclareImplicitDeductionGuideFromInitList to substitute outer template
arguments.

The tests in the original patch made an assumption about the size of a
pointer type, and this led to them failing on targets with 32-bit
pointers. The tests have been updated to not depend on the size of any
type. This only requires updates to the test file, no functionality has
otherwise changed between this and the original patch.

show more ...


# 7f2408fb 18-Jan-2024 antangelo <contact@antangelo.com>

Revert "[clang] Fix CTAD for aggregates for nested template classes" (#78541)

Reverts llvm/llvm-project#78387

The added tests are failing on several build bots.


# 04a69a10 17-Jan-2024 antangelo <contact@antangelo.com>

[clang] Fix CTAD for aggregates for nested template classes (#78387)

Use the template pattern in determining whether to synthesize the
aggregate deduction guide, and update
DeclareImplicitDeductio

[clang] Fix CTAD for aggregates for nested template classes (#78387)

Use the template pattern in determining whether to synthesize the
aggregate deduction guide, and update
DeclareImplicitDeductionGuideFromInitList to substitute outer template
arguments.

Fixes #77599

show more ...


Revision tags: llvmorg-17.0.6
# bee78b88 25-Nov-2023 antangelo <contact@antangelo.com>

Reland "[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes" (#73087)

Reland of f418319730341e9d41ce8ead6fbfe5603c343985 with proper hand

Reland "[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes" (#73087)

Reland of f418319730341e9d41ce8ead6fbfe5603c343985 with proper handling
of template constructors

When a nested template is instantiated, the template pattern of the
inner class is not copied into the outer class
ClassTemplateSpecializationDecl. The specialization contains a
ClassTemplateDecl with an empty record that points to the original
template pattern instead.

As a result, when looking up the constructors of the inner class, no
results are returned. This patch finds the original template pattern and
uses that for the lookup instead.

Based on CWG2471 we must also substitute the known outer template
arguments when creating deduction guides for the inner class.

Changes from last iteration:

1. In template constructors, arguments are first rewritten to depth - 1
relative to the constructor as compared to depth 0 originally. These
arguments are needed for substitution into constraint expressions.
2. Outer arguments are then applied with the template instantiator to
produce a template argument at depth zero for use in the deduction
guide. This substitution does not evaluate constraints, which preserves
constraint arguments at the correct depth for later evaluation.
3. Tests are added that cover template constructors within nested
deduction guides for all special substitution cases.
4. Computation of the template pattern and outer instantiation arguments
are pulled into the constructor of
`ConvertConstructorToDeductionGuideTransform`.

show more ...


Revision tags: llvmorg-17.0.5, llvmorg-17.0.4
# f4183197 24-Oct-2023 antangelo <contact@antangelo.com>

Reland "[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes" (#69676)

Reland of dd0fba11690f9fef304d5f48cde646e5eca8d3c0

When a nested

Reland "[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes" (#69676)

Reland of dd0fba11690f9fef304d5f48cde646e5eca8d3c0

When a nested template is instantiated, the template pattern of the
inner class is not copied into the outer class
ClassTemplateSpecializationDecl. The specialization contains a
ClassTemplateDecl with an empty record that points to the original
template pattern instead.

As a result, when looking up the constructors of the inner class, no
results are returned. This patch finds the original template pattern and
uses that for the lookup instead.

Based on CWG2471 we must also substitute the known outer template
arguments when creating deduction guides for the inner class.

Changes from the last iteration:
1. The outer retained levels from the outer template are always added to
the `MultiLevelTemplateArgumentList` for rewriting
`FunctionTemplateDecl` arguments, even if there is no FTD and the
arguments are empty.
2. When building implicit deduction guides, the template pattern
underlying decl is pushed as the current context. This resolves the
issue where `FindInstantiatedDecl` is unable to find the inner template
class.
3. Tests are updated to cover the failing case, and to assert that the
type is correct after argument deduction in the implicit case.

show more ...


Revision tags: llvmorg-17.0.3
# dd0fba11 16-Oct-2023 antangelo <contact@antangelo.com>

[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes (#68379)

When a nested template is instantiated, the template pattern of the
inner c

[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes (#68379)

When a nested template is instantiated, the template pattern of the
inner class is not copied into the outer class
ClassTemplateSpecializationDecl. The specialization contains a
ClassTemplateDecl with an empty record that points to the original
template pattern instead.

As a result, when looking up the constructors of the inner class, no
results are returned. This patch finds the original template pattern and
uses that for the lookup instead.

Based on CWG2471 we must also substitute the known outer template
arguments when creating deduction guides for the inner class.

Fixes #46200
Fixes #57812

show more ...