@@ -1717,21 +1717,6 @@ namespace {
1717
1717
SubstTemplateTypeParmPackTypeLoc TL,
1718
1718
bool SuppressObjCLifetime);
1719
1719
1720
- QualType
1721
- TransformSubstTemplateTypeParmType (TypeLocBuilder &TLB,
1722
- SubstTemplateTypeParmTypeLoc TL) {
1723
- if (SemaRef.CodeSynthesisContexts .back ().Kind !=
1724
- Sema::CodeSynthesisContext::ConstraintSubstitution)
1725
- return inherited::TransformSubstTemplateTypeParmType (TLB, TL);
1726
-
1727
- auto PackIndex = TL.getTypePtr ()->getPackIndex ();
1728
- std::optional<Sema::ArgumentPackSubstitutionIndexRAII> SubstIndex;
1729
- if (SemaRef.ArgumentPackSubstitutionIndex == -1 && PackIndex)
1730
- SubstIndex.emplace (SemaRef, *PackIndex);
1731
-
1732
- return inherited::TransformSubstTemplateTypeParmType (TLB, TL);
1733
- }
1734
-
1735
1720
CXXRecordDecl::LambdaDependencyKind
1736
1721
ComputeLambdaDependency (LambdaScopeInfo *LSI) {
1737
1722
if (auto TypeAlias =
@@ -3166,58 +3151,6 @@ namespace {
3166
3151
3167
3152
} // namespace
3168
3153
3169
- namespace {
3170
-
3171
- struct ExpandPackedTypeConstraints
3172
- : TreeTransform<ExpandPackedTypeConstraints> {
3173
-
3174
- using inherited = TreeTransform<ExpandPackedTypeConstraints>;
3175
-
3176
- ExpandPackedTypeConstraints (Sema &SemaRef) : inherited(SemaRef) {}
3177
-
3178
- using inherited::TransformTemplateTypeParmType;
3179
-
3180
- QualType TransformTemplateTypeParmType (TypeLocBuilder &TLB,
3181
- TemplateTypeParmTypeLoc TL, bool ) {
3182
- const TemplateTypeParmType *T = TL.getTypePtr ();
3183
- if (!T->isParameterPack ()) {
3184
- TemplateTypeParmTypeLoc NewTL =
3185
- TLB.push <TemplateTypeParmTypeLoc>(TL.getType ());
3186
- NewTL.setNameLoc (TL.getNameLoc ());
3187
- return TL.getType ();
3188
- }
3189
-
3190
- assert (SemaRef.ArgumentPackSubstitutionIndex != -1 );
3191
-
3192
- QualType Result = SemaRef.Context .getSubstTemplateTypeParmType (
3193
- TL.getType (), T->getDecl (), T->getIndex (),
3194
- SemaRef.ArgumentPackSubstitutionIndex );
3195
- SubstTemplateTypeParmTypeLoc NewTL =
3196
- TLB.push <SubstTemplateTypeParmTypeLoc>(Result);
3197
- NewTL.setNameLoc (TL.getNameLoc ());
3198
- return Result;
3199
- }
3200
-
3201
- QualType TransformSubstTemplateTypeParmType (TypeLocBuilder &TLB,
3202
- SubstTemplateTypeParmTypeLoc TL) {
3203
- const SubstTemplateTypeParmType *T = TL.getTypePtr ();
3204
- if (T->getPackIndex ()) {
3205
- SubstTemplateTypeParmTypeLoc TypeLoc =
3206
- TLB.push <SubstTemplateTypeParmTypeLoc>(TL.getType ());
3207
- TypeLoc.setNameLoc (TL.getNameLoc ());
3208
- return TypeLoc.getType ();
3209
- }
3210
- return inherited::TransformSubstTemplateTypeParmType (TLB, TL);
3211
- }
3212
-
3213
- bool SubstTemplateArguments (ArrayRef<TemplateArgumentLoc> Args,
3214
- TemplateArgumentListInfo &Out) {
3215
- return inherited::TransformTemplateArguments (Args.begin (), Args.end (), Out);
3216
- }
3217
- };
3218
-
3219
- } // namespace
3220
-
3221
3154
bool Sema::SubstTypeConstraint (
3222
3155
TemplateTypeParmDecl *Inst, const TypeConstraint *TC,
3223
3156
const MultiLevelTemplateArgumentList &TemplateArgs,
@@ -3226,62 +3159,9 @@ bool Sema::SubstTypeConstraint(
3226
3159
TC->getTemplateArgsAsWritten ();
3227
3160
3228
3161
if (!EvaluateConstraints) {
3229
- bool ShouldExpandExplicitTemplateArgs =
3230
- TemplArgInfo && ArgumentPackSubstitutionIndex != -1 &&
3231
- llvm::any_of (TemplArgInfo->arguments (), [](auto &Arg) {
3232
- return Arg.getArgument ().containsUnexpandedParameterPack ();
3233
- });
3234
-
3235
- // We want to transform the packs into Subst* nodes for type constraints
3236
- // inside a pack expansion. For example,
3237
- //
3238
- // template <class... Ts> void foo() {
3239
- // bar([](C<Ts> auto value) {}...);
3240
- // }
3241
- //
3242
- // As we expand Ts in the process of instantiating foo(), and retain
3243
- // the original template depths of Ts until the constraint evaluation, we
3244
- // would otherwise have no chance to expand Ts by the time of evaluating
3245
- // C<auto, Ts>.
3246
- //
3247
- // So we form a Subst* node for Ts along with a proper substitution index
3248
- // here, and substitute the node with a complete MLTAL later in evaluation.
3249
- if (ShouldExpandExplicitTemplateArgs) {
3250
- TemplateArgumentListInfo InstArgs;
3251
- InstArgs.setLAngleLoc (TemplArgInfo->LAngleLoc );
3252
- InstArgs.setRAngleLoc (TemplArgInfo->RAngleLoc );
3253
- if (ExpandPackedTypeConstraints (*this ).SubstTemplateArguments (
3254
- TemplArgInfo->arguments (), InstArgs))
3255
- return true ;
3256
-
3257
- // The type of the original parameter.
3258
- auto *ConstraintExpr = TC->getImmediatelyDeclaredConstraint ();
3259
- QualType ConstrainedType;
3260
-
3261
- if (auto *FE = dyn_cast<CXXFoldExpr>(ConstraintExpr)) {
3262
- assert (FE->getLHS ());
3263
- ConstraintExpr = FE->getLHS ();
3264
- }
3265
- auto *CSE = cast<ConceptSpecializationExpr>(ConstraintExpr);
3266
- assert (!CSE->getTemplateArguments ().empty () &&
3267
- " Empty template arguments?" );
3268
- ConstrainedType = CSE->getTemplateArguments ()[0 ].getAsType ();
3269
- assert (!ConstrainedType.isNull () &&
3270
- " Failed to extract the original ConstrainedType?" );
3271
-
3272
- return AttachTypeConstraint (
3273
- TC->getNestedNameSpecifierLoc (), TC->getConceptNameInfo (),
3274
- TC->getNamedConcept (),
3275
- /* FoundDecl=*/ TC->getConceptReference ()->getFoundDecl (), &InstArgs,
3276
- Inst, ConstrainedType,
3277
- Inst->isParameterPack ()
3278
- ? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint ())
3279
- ->getEllipsisLoc ()
3280
- : SourceLocation ());
3281
- }
3282
- Inst->setTypeConstraint (TC->getConceptReference (),
3283
- TC->getImmediatelyDeclaredConstraint ());
3284
- return false ;
3162
+ Inst->setTypeConstraint (TC->getConceptReference (),
3163
+ TC->getImmediatelyDeclaredConstraint ());
3164
+ return false ;
3285
3165
}
3286
3166
3287
3167
TemplateArgumentListInfo InstArgs;
@@ -3297,7 +3177,6 @@ bool Sema::SubstTypeConstraint(
3297
3177
TC->getNestedNameSpecifierLoc (), TC->getConceptNameInfo (),
3298
3178
TC->getNamedConcept (),
3299
3179
/* FoundDecl=*/ TC->getConceptReference ()->getFoundDecl (), &InstArgs, Inst,
3300
- Context.getTypeDeclType (Inst),
3301
3180
Inst->isParameterPack ()
3302
3181
? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint ())
3303
3182
->getEllipsisLoc ()
0 commit comments