Commit f418319
authored
Reland "[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes" (#69676)
Reland of dd0fba1
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.1 parent 4950467 commit f418319
4 files changed
Lines changed: 50 additions & 1 deletion
File tree
- clang
- docs
- lib/Sema
- test/SemaTemplate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
620 | 625 | | |
621 | 626 | | |
622 | 627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2253 | 2253 | | |
2254 | 2254 | | |
2255 | 2255 | | |
| 2256 | + | |
2256 | 2257 | | |
2257 | 2258 | | |
2258 | 2259 | | |
| |||
2332 | 2333 | | |
2333 | 2334 | | |
2334 | 2335 | | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
2335 | 2339 | | |
2336 | 2340 | | |
2337 | 2341 | | |
| |||
2441 | 2445 | | |
2442 | 2446 | | |
2443 | 2447 | | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2444 | 2452 | | |
2445 | 2453 | | |
2446 | 2454 | | |
2447 | 2455 | | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
2448 | 2459 | | |
2449 | 2460 | | |
2450 | 2461 | | |
| |||
2650 | 2661 | | |
2651 | 2662 | | |
2652 | 2663 | | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
2653 | 2674 | | |
2654 | 2675 | | |
2655 | 2676 | | |
2656 | 2677 | | |
| 2678 | + | |
2657 | 2679 | | |
2658 | 2680 | | |
2659 | | - | |
| 2681 | + | |
2660 | 2682 | | |
2661 | 2683 | | |
2662 | 2684 | | |
| |||
2702 | 2724 | | |
2703 | 2725 | | |
2704 | 2726 | | |
| 2727 | + | |
| 2728 | + | |
2705 | 2729 | | |
2706 | 2730 | | |
2707 | 2731 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments