Skip to content

Commit 801c78d

Browse files
committed
Revert "Reland "[clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes" (#69676)"
This reverts commit f418319. Failing test case: #69676 (comment)
1 parent 05ebc70 commit 801c78d

File tree

4 files changed

+1
-50
lines changed

4 files changed

+1
-50
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,6 @@ Bug Fixes to C++ Support
665665
declaration definition. Fixes:
666666
(`#61763 <https://github.com/llvm/llvm-project/issues/61763>`_)
667667

668-
- Fix a bug where implicit deduction guides are not correctly generated for nested template
669-
classes. Fixes:
670-
(`#46200 <https://github.com/llvm/llvm-project/issues/46200>`_)
671-
(`#57812 <https://github.com/llvm/llvm-project/issues/57812>`_)
672-
673668
- Diagnose use of a variable-length array in a coroutine. The design of
674669
coroutines is such that it is not possible to support VLA use. Fixes:
675670
(`#65858 <https://github.com/llvm/llvm-project/issues/65858>`_)

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,6 @@ struct ConvertConstructorToDeductionGuideTransform {
22532253

22542254
Sema &SemaRef;
22552255
ClassTemplateDecl *Template;
2256-
ClassTemplateDecl *NestedPattern = nullptr;
22572256

22582257
DeclContext *DC = Template->getDeclContext();
22592258
CXXRecordDecl *Primary = Template->getTemplatedDecl();
@@ -2333,9 +2332,6 @@ struct ConvertConstructorToDeductionGuideTransform {
23332332
Args.addOuterRetainedLevel();
23342333
}
23352334

2336-
if (NestedPattern)
2337-
Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
2338-
23392335
FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()->getTypeLoc()
23402336
.getAsAdjusted<FunctionProtoTypeLoc>();
23412337
assert(FPTL && "no prototype for constructor declaration");
@@ -2445,17 +2441,10 @@ struct ConvertConstructorToDeductionGuideTransform {
24452441
SmallVector<QualType, 4> ParamTypes;
24462442
const FunctionProtoType *T = TL.getTypePtr();
24472443

2448-
MultiLevelTemplateArgumentList OuterInstantiationArgs;
2449-
if (NestedPattern)
2450-
OuterInstantiationArgs = SemaRef.getTemplateInstantiationArgs(Template);
2451-
24522444
// -- The types of the function parameters are those of the constructor.
24532445
for (auto *OldParam : TL.getParams()) {
24542446
ParmVarDecl *NewParam =
24552447
transformFunctionTypeParam(OldParam, Args, MaterializedTypedefs);
2456-
if (NestedPattern && NewParam)
2457-
NewParam = transformFunctionTypeParam(NewParam, OuterInstantiationArgs,
2458-
MaterializedTypedefs);
24592448
if (!NewParam)
24602449
return QualType();
24612450
ParamTypes.push_back(NewParam->getType());
@@ -2661,24 +2650,13 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
26612650
if (BuildingDeductionGuides.isInvalid())
26622651
return;
26632652

2664-
// If the template is nested, then we need to use the original
2665-
// pattern to iterate over the constructors.
2666-
ClassTemplateDecl *Pattern = Transform.Template;
2667-
while (Pattern->getInstantiatedFromMemberTemplate()) {
2668-
if (Pattern->isMemberSpecialization())
2669-
break;
2670-
Pattern = Pattern->getInstantiatedFromMemberTemplate();
2671-
Transform.NestedPattern = Pattern;
2672-
}
2673-
26742653
// Convert declared constructors into deduction guide templates.
26752654
// FIXME: Skip constructors for which deduction must necessarily fail (those
26762655
// for which some class template parameter without a default argument never
26772656
// appears in a deduced context).
2678-
ContextRAII SavedContext(*this, Pattern->getTemplatedDecl());
26792657
llvm::SmallPtrSet<NamedDecl *, 8> ProcessedCtors;
26802658
bool AddedAny = false;
2681-
for (NamedDecl *D : LookupConstructors(Pattern->getTemplatedDecl())) {
2659+
for (NamedDecl *D : LookupConstructors(Transform.Primary)) {
26822660
D = D->getUnderlyingDecl();
26832661
if (D->isInvalidDecl() || D->isImplicit())
26842662
continue;
@@ -2724,8 +2702,6 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
27242702
Transform.buildSimpleDeductionGuide(Transform.DeducedType))
27252703
->getTemplatedDecl())
27262704
->setDeductionCandidateKind(DeductionCandidate::Copy);
2727-
2728-
SavedContext.pop();
27292705
}
27302706

27312707
/// Diagnose the presence of a default template argument on a

clang/test/SemaTemplate/nested-deduction-guides.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
template<typename T> struct A {
55
template<typename U> struct B {
66
B(...);
7-
B(const B &) = default;
87
};
98
template<typename U> B(U) -> B<U>;
109
};
1110
A<void>::B b = 123;
12-
A<void>::B copy = b;
1311

1412
using T = decltype(b);
1513
using T = A<void>::B<int>;
16-
17-
using Copy = decltype(copy);
18-
using Copy = A<void>::B<int>;

clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)