@@ -3166,15 +3166,20 @@ class AbstractTypeParamDecl : public TypeDecl {
3166
3166
// / \code
3167
3167
// / func min<T : Comparable>(x : T, y : T) -> T { ... }
3168
3168
// / \endcode
3169
- class GenericTypeParamDecl final :
3170
- public AbstractTypeParamDecl,
3171
- private llvm::TrailingObjects<GenericTypeParamDecl, TypeRepr *>{
3169
+ class GenericTypeParamDecl final
3170
+ : public AbstractTypeParamDecl,
3171
+ private llvm::TrailingObjects<GenericTypeParamDecl, TypeRepr *,
3172
+ SourceLoc> {
3172
3173
friend TrailingObjects;
3173
3174
3174
- size_t numTrailingObjects (OverloadToken<OpaqueReturnTypeRepr *>) const {
3175
+ size_t numTrailingObjects (OverloadToken<TypeRepr *>) const {
3175
3176
return isOpaqueType () ? 1 : 0 ;
3176
3177
}
3177
3178
3179
+ size_t numTrailingObjects (OverloadToken<SourceLoc>) const {
3180
+ return isParameterPack () ? 1 : 0 ;
3181
+ }
3182
+
3178
3183
// / Construct a new generic type parameter.
3179
3184
// /
3180
3185
// / \param dc The DeclContext in which the generic type parameter's owner
@@ -3183,6 +3188,7 @@ class GenericTypeParamDecl final :
3183
3188
// /
3184
3189
// / \param name The name of the generic parameter.
3185
3190
// / \param nameLoc The location of the name.
3191
+ // / \param ellipsisLoc The location of the ellipsis for a type parameter pack.
3186
3192
// / \param depth The generic signature depth.
3187
3193
// / \param index The index of the parameter in the generic signature.
3188
3194
// / \param isParameterPack Whether the generic parameter is for a type
@@ -3192,8 +3198,9 @@ class GenericTypeParamDecl final :
3192
3198
// / \param opaqueTypeRepr The TypeRepr of an opaque generic parameter.
3193
3199
// /
3194
3200
GenericTypeParamDecl (DeclContext *dc, Identifier name, SourceLoc nameLoc,
3195
- unsigned depth, unsigned index, bool isParameterPack,
3196
- bool isOpaqueType, TypeRepr *opaqueTypeRepr);
3201
+ SourceLoc ellipsisLoc, unsigned depth, unsigned index,
3202
+ bool isParameterPack, bool isOpaqueType,
3203
+ TypeRepr *opaqueTypeRepr);
3197
3204
3198
3205
// / Construct a new generic type parameter.
3199
3206
// /
@@ -3203,6 +3210,7 @@ class GenericTypeParamDecl final :
3203
3210
// /
3204
3211
// / \param name The name of the generic parameter.
3205
3212
// / \param nameLoc The location of the name.
3213
+ // / \param ellipsisLoc The location of the ellipsis for a type parameter pack.
3206
3214
// / \param depth The generic signature depth.
3207
3215
// / \param index The index of the parameter in the generic signature.
3208
3216
// / \param isParameterPack Whether the generic parameter is for a type
@@ -3212,9 +3220,9 @@ class GenericTypeParamDecl final :
3212
3220
// / \param opaqueTypeRepr The TypeRepr of an opaque generic parameter.
3213
3221
// /
3214
3222
static GenericTypeParamDecl *create (DeclContext *dc, Identifier name,
3215
- SourceLoc nameLoc, unsigned depth ,
3216
- unsigned index, bool isParameterPack ,
3217
- bool isOpaqueType,
3223
+ SourceLoc nameLoc, SourceLoc ellipsisLoc ,
3224
+ unsigned depth, unsigned index ,
3225
+ bool isParameterPack, bool isOpaqueType,
3218
3226
TypeRepr *opaqueTypeRepr);
3219
3227
3220
3228
public:
@@ -3223,9 +3231,11 @@ class GenericTypeParamDecl final :
3223
3231
// / Construct a new generic type parameter. This should only be used by the
3224
3232
// / ClangImporter, use \c GenericTypeParamDecl::create[...] instead.
3225
3233
GenericTypeParamDecl (DeclContext *dc, Identifier name, SourceLoc nameLoc,
3226
- unsigned depth, unsigned index, bool isParameterPack)
3227
- : GenericTypeParamDecl(dc, name, nameLoc, depth, index, isParameterPack,
3228
- /* isOpaqueType*/ false , nullptr ) {}
3234
+ SourceLoc ellipsisLoc, unsigned depth, unsigned index,
3235
+ bool isParameterPack)
3236
+ : GenericTypeParamDecl(dc, name, nameLoc, ellipsisLoc, depth, index,
3237
+ isParameterPack, /* isOpaqueType*/ false , nullptr ) {
3238
+ }
3229
3239
3230
3240
// / Construct a deserialized generic type parameter.
3231
3241
// /
@@ -3253,13 +3263,14 @@ class GenericTypeParamDecl final :
3253
3263
// /
3254
3264
// / \param name The name of the generic parameter.
3255
3265
// / \param nameLoc The location of the name.
3266
+ // / \param ellipsisLoc The location of the ellipsis for a type parameter pack.
3256
3267
// / \param index The index of the parameter in the generic signature.
3257
3268
// / \param isParameterPack Whether the generic parameter is for a type
3258
3269
// / parameter pack, denoted by \c <T...>.
3259
3270
// /
3260
3271
static GenericTypeParamDecl *
3261
3272
createParsed (DeclContext *dc, Identifier name, SourceLoc nameLoc,
3262
- unsigned index, bool isParameterPack);
3273
+ SourceLoc ellipsisLoc, unsigned index, bool isParameterPack);
3263
3274
3264
3275
// / Construct a new implicit generic type parameter.
3265
3276
// /
@@ -3276,12 +3287,14 @@ class GenericTypeParamDecl final :
3276
3287
// / parameter e.g 'some Collection'.
3277
3288
// / \param opaqueTypeRepr The TypeRepr of an opaque generic parameter.
3278
3289
// / \param nameLoc The location of the name.
3290
+ // / \param ellipsisLoc The location of the ellipsis for a type parameter pack.
3279
3291
// /
3280
3292
static GenericTypeParamDecl *
3281
3293
createImplicit (DeclContext *dc, Identifier name, unsigned depth,
3282
3294
unsigned index, bool isParameterPack = false ,
3283
3295
bool isOpaqueType = false , TypeRepr *opaqueTypeRepr = nullptr ,
3284
- SourceLoc nameLoc = SourceLoc());
3296
+ SourceLoc nameLoc = SourceLoc(),
3297
+ SourceLoc ellipsisLoc = SourceLoc());
3285
3298
3286
3299
// / The depth of this generic type parameter, i.e., the number of outer
3287
3300
// / levels of generic parameter lists that enclose this type parameter.
@@ -3348,6 +3361,14 @@ class GenericTypeParamDecl final :
3348
3361
// / Here 'T' and 'U' have indexes 0 and 1, respectively. 'V' has index 0.
3349
3362
unsigned getIndex () const { return Bits.GenericTypeParamDecl .Index ; }
3350
3363
3364
+ // / Retrieve the ellipsis location for a type parameter pack \c T...
3365
+ SourceLoc getEllipsisLoc () const {
3366
+ if (!isParameterPack ())
3367
+ return SourceLoc ();
3368
+
3369
+ return *getTrailingObjects<SourceLoc>();
3370
+ }
3371
+
3351
3372
SourceLoc getStartLoc () const { return getNameLoc (); }
3352
3373
SourceRange getSourceRange () const ;
3353
3374
0 commit comments