@@ -2253,7 +2253,6 @@ struct ConvertConstructorToDeductionGuideTransform {
2253
2253
2254
2254
Sema &SemaRef;
2255
2255
ClassTemplateDecl *Template;
2256
- ClassTemplateDecl *NestedPattern = nullptr;
2257
2256
2258
2257
DeclContext *DC = Template->getDeclContext();
2259
2258
CXXRecordDecl *Primary = Template->getTemplatedDecl();
@@ -2333,9 +2332,6 @@ struct ConvertConstructorToDeductionGuideTransform {
2333
2332
Args.addOuterRetainedLevel();
2334
2333
}
2335
2334
2336
- if (NestedPattern)
2337
- Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
2338
-
2339
2335
FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()->getTypeLoc()
2340
2336
.getAsAdjusted<FunctionProtoTypeLoc>();
2341
2337
assert(FPTL && "no prototype for constructor declaration");
@@ -2445,17 +2441,10 @@ struct ConvertConstructorToDeductionGuideTransform {
2445
2441
SmallVector<QualType, 4> ParamTypes;
2446
2442
const FunctionProtoType *T = TL.getTypePtr();
2447
2443
2448
- MultiLevelTemplateArgumentList OuterInstantiationArgs;
2449
- if (NestedPattern)
2450
- OuterInstantiationArgs = SemaRef.getTemplateInstantiationArgs(Template);
2451
-
2452
2444
// -- The types of the function parameters are those of the constructor.
2453
2445
for (auto *OldParam : TL.getParams()) {
2454
2446
ParmVarDecl *NewParam =
2455
2447
transformFunctionTypeParam(OldParam, Args, MaterializedTypedefs);
2456
- if (NestedPattern && NewParam)
2457
- NewParam = transformFunctionTypeParam(NewParam, OuterInstantiationArgs,
2458
- MaterializedTypedefs);
2459
2448
if (!NewParam)
2460
2449
return QualType();
2461
2450
ParamTypes.push_back(NewParam->getType());
@@ -2661,24 +2650,13 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
2661
2650
if (BuildingDeductionGuides.isInvalid())
2662
2651
return;
2663
2652
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
-
2674
2653
// Convert declared constructors into deduction guide templates.
2675
2654
// FIXME: Skip constructors for which deduction must necessarily fail (those
2676
2655
// for which some class template parameter without a default argument never
2677
2656
// appears in a deduced context).
2678
- ContextRAII SavedContext(*this, Pattern->getTemplatedDecl());
2679
2657
llvm::SmallPtrSet<NamedDecl *, 8> ProcessedCtors;
2680
2658
bool AddedAny = false;
2681
- for (NamedDecl *D : LookupConstructors(Pattern->getTemplatedDecl() )) {
2659
+ for (NamedDecl *D : LookupConstructors(Transform.Primary )) {
2682
2660
D = D->getUnderlyingDecl();
2683
2661
if (D->isInvalidDecl() || D->isImplicit())
2684
2662
continue;
@@ -2724,8 +2702,6 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
2724
2702
Transform.buildSimpleDeductionGuide(Transform.DeducedType))
2725
2703
->getTemplatedDecl())
2726
2704
->setDeductionCandidateKind(DeductionCandidate::Copy);
2727
-
2728
- SavedContext.pop();
2729
2705
}
2730
2706
2731
2707
/// Diagnose the presence of a default template argument on a
0 commit comments