@@ -196,10 +196,12 @@ class alignas(1 << TypeReprAlignInBits) TypeRepr
196
196
// / \c Type::getCanonicalType() or \c Type::getWithoutParens().
197
197
TypeRepr *getWithoutParens () const ;
198
198
199
- // / Whether this is a `SimpleIdentTypeRepr` matching the given identifier.
199
+ // / Whether this is a `UnqualifiedIdentTypeRepr` with no generic arguments,
200
+ // / matching the given identifier.
200
201
bool isSimpleUnqualifiedIdentifier (Identifier identifier) const ;
201
202
202
- // / Whether this is a `SimpleIdentTypeRepr` matching the given string.
203
+ // / Whether this is a `UnqualifiedIdentTypeRepr` with no generic arguments,
204
+ // / matching the given string.
203
205
bool isSimpleUnqualifiedIdentifier (StringRef str) const ;
204
206
205
207
// *** Allocation Routines ************************************************/
@@ -324,7 +326,7 @@ class AttributedTypeRepr final
324
326
friend class TypeRepr ;
325
327
};
326
328
327
- class IdentTypeRepr ;
329
+ class UnqualifiedIdentTypeRepr ;
328
330
329
331
// / This is the abstract base class for types that directly reference a
330
332
// / type declaration. In written syntax, this type representation consists of
@@ -361,15 +363,15 @@ class DeclRefTypeRepr : public TypeRepr {
361
363
SourceRange AngleBrackets);
362
364
363
365
// / Returns the qualifier or base type representation. For example, `A.B`
364
- // / for `A.B.C`. The base of a `IdentTypeRepr ` is null.
366
+ // / for `A.B.C`. The base of a `UnqualifiedIdentTypeRepr ` is null.
365
367
TypeRepr *getBase () const ;
366
368
367
369
// / Returns the root qualifier. For example, `A` for `A.B.C`. The root
368
- // / qualifier of a `IdentTypeRepr ` is itself.
370
+ // / qualifier of a `UnqualifiedIdentTypeRepr ` is itself.
369
371
TypeRepr *getRoot ();
370
372
371
373
// / Returns the root qualifier. For example, `A` for `A.B.C`. The root
372
- // / qualifier of a `IdentTypeRepr ` is itself.
374
+ // / qualifier of a `UnqualifiedIdentTypeRepr ` is itself.
373
375
const TypeRepr *getRoot () const ;
374
376
375
377
DeclNameLoc getNameLoc () const ;
@@ -407,101 +409,62 @@ class DeclRefTypeRepr : public TypeRepr {
407
409
SourceRange getAngleBrackets () const ;
408
410
409
411
static bool classof (const TypeRepr *T) {
410
- return T->getKind () == TypeReprKind::SimpleIdent ||
411
- T->getKind () == TypeReprKind::GenericIdent ||
412
- T->getKind () == TypeReprKind::Member;
412
+ return T->getKind () == TypeReprKind::UnqualifiedIdent ||
413
+ T->getKind () == TypeReprKind::QualifiedIdent;
413
414
}
414
415
static bool classof (const DeclRefTypeRepr *T) { return true ; }
415
416
416
417
protected:
417
418
SourceLoc getLocImpl () const ;
419
+ SourceLoc getEndLocImpl () const ;
418
420
419
421
void printImpl (ASTPrinter &Printer, const PrintOptions &Opts) const ;
420
422
421
423
friend class TypeRepr ;
422
424
};
423
425
424
- // / An identifier type with an optional set of generic arguments.
426
+ // / An unqualified identifier type an optional set of generic arguments.
425
427
// / \code
426
428
// / Foo
427
429
// / Bar<Gen>
428
430
// / \endcode
429
- class IdentTypeRepr : public DeclRefTypeRepr {
430
- protected:
431
- IdentTypeRepr (TypeReprKind K, DeclNameLoc Loc, DeclNameRef Id ,
432
- unsigned NumGenericArgs, bool hasGenericArgList)
433
- : DeclRefTypeRepr(K, Id, Loc, NumGenericArgs, hasGenericArgList) {}
431
+ class UnqualifiedIdentTypeRepr final
432
+ : public DeclRefTypeRepr,
433
+ private llvm::TrailingObjects<UnqualifiedIdentTypeRepr, TypeRepr * ,
434
+ SourceRange> {
435
+ friend TrailingObjects;
434
436
435
- public:
436
- static bool classof (const TypeRepr *T) {
437
- return T->getKind () == TypeReprKind::SimpleIdent ||
438
- T->getKind () == TypeReprKind::GenericIdent;
437
+ size_t numTrailingObjects (OverloadToken<TypeRepr *>) const {
438
+ return getNumGenericArgs ();
439
439
}
440
- static bool classof (const IdentTypeRepr *T) { return true ; }
441
440
442
- protected:
443
- SourceLoc getStartLocImpl () const { return getNameLoc ().getStartLoc (); }
441
+ UnqualifiedIdentTypeRepr (DeclNameRef Name, DeclNameLoc NameLoc);
444
442
445
- friend class TypeRepr ;
446
- };
443
+ UnqualifiedIdentTypeRepr (DeclNameRef Name, DeclNameLoc NameLoc,
444
+ ArrayRef<TypeRepr *> GenericArgs,
445
+ SourceRange AngleBrackets);
447
446
448
- // / A simple identifier type like "Int".
449
- class SimpleIdentTypeRepr : public IdentTypeRepr {
450
447
public:
451
- SimpleIdentTypeRepr (DeclNameLoc Loc, DeclNameRef Id)
452
- : IdentTypeRepr(TypeReprKind::SimpleIdent, Loc, Id, /* NumGenericArgs=*/ 0 ,
453
- /* HasAngleBrackets=*/ false ) {}
454
-
455
- // SmallVector::emplace_back will never need to call this because
456
- // we reserve the right size, but it does try statically.
457
- SimpleIdentTypeRepr (const SimpleIdentTypeRepr &repr)
458
- : SimpleIdentTypeRepr(repr.getNameLoc(), repr.getNameRef()) {
459
- llvm_unreachable (" should not be called dynamically" );
460
- }
461
-
462
- static bool classof (const TypeRepr *T) {
463
- return T->getKind () == TypeReprKind::SimpleIdent;
464
- }
465
- static bool classof (const SimpleIdentTypeRepr *T) { return true ; }
466
-
467
- private:
468
- SourceLoc getEndLocImpl () const { return getNameLoc ().getEndLoc (); }
469
- friend class TypeRepr ;
470
- };
471
-
472
- // / An identifier type with generic arguments.
473
- // / \code
474
- // / Bar<Gen>
475
- // / \endcode
476
- class GenericIdentTypeRepr final
477
- : public IdentTypeRepr,
478
- private llvm::TrailingObjects<GenericIdentTypeRepr, TypeRepr *> {
479
- friend TrailingObjects;
480
- SourceRange AngleBrackets;
448
+ static UnqualifiedIdentTypeRepr *
449
+ create (const ASTContext &C, DeclNameLoc NameLoc, DeclNameRef Name);
481
450
482
- GenericIdentTypeRepr (DeclNameLoc Loc, DeclNameRef Id,
483
- ArrayRef<TypeRepr *> GenericArgs,
484
- SourceRange AngleBrackets);
451
+ static UnqualifiedIdentTypeRepr *create (const ASTContext &C,
452
+ DeclNameLoc NameLoc, DeclNameRef Name,
453
+ ArrayRef<TypeRepr *> GenericArgs,
454
+ SourceRange AngleBrackets);
485
455
486
- public:
487
- static GenericIdentTypeRepr *create (const ASTContext &C,
488
- DeclNameLoc Loc,
489
- DeclNameRef Id,
490
- ArrayRef<TypeRepr*> GenericArgs,
491
- SourceRange AngleBrackets);
456
+ ArrayRef<TypeRepr *> getGenericArgs () const ;
492
457
493
- ArrayRef<TypeRepr*> getGenericArgs () const {
494
- return {getTrailingObjects<TypeRepr *>(), getNumGenericArgs ()};
495
- }
496
- SourceRange getAngleBrackets () const { return AngleBrackets; }
458
+ SourceRange getAngleBrackets () const ;
497
459
498
460
static bool classof (const TypeRepr *T) {
499
- return T->getKind () == TypeReprKind::GenericIdent ;
461
+ return T->getKind () == TypeReprKind::UnqualifiedIdent ;
500
462
}
501
- static bool classof (const GenericIdentTypeRepr *T) { return true ; }
463
+ static bool classof (const UnqualifiedIdentTypeRepr *T) { return true ; }
464
+
465
+ protected:
466
+ SourceLoc getStartLocImpl () const { return getNameLoc ().getStartLoc (); }
502
467
503
- private:
504
- SourceLoc getEndLocImpl () const { return AngleBrackets.End ; }
505
468
friend class TypeRepr ;
506
469
};
507
470
@@ -511,9 +474,10 @@ class GenericIdentTypeRepr final
511
474
// / Foo.Bar<Gen>.Baz
512
475
// / [Int].Bar
513
476
// / \endcode
514
- class MemberTypeRepr final
477
+ class QualifiedIdentTypeRepr final
515
478
: public DeclRefTypeRepr,
516
- private llvm::TrailingObjects<MemberTypeRepr, TypeRepr *, SourceRange> {
479
+ private llvm::TrailingObjects<QualifiedIdentTypeRepr, TypeRepr *,
480
+ SourceRange> {
517
481
friend TrailingObjects;
518
482
519
483
// / The qualifier or base type representation. For example, `A.B` for `A.B.C`.
@@ -523,19 +487,20 @@ class MemberTypeRepr final
523
487
return getNumGenericArgs ();
524
488
}
525
489
526
- MemberTypeRepr (TypeRepr *Base, DeclNameRef Name, DeclNameLoc NameLoc);
490
+ QualifiedIdentTypeRepr (TypeRepr *Base, DeclNameRef Name, DeclNameLoc NameLoc);
527
491
528
- MemberTypeRepr (TypeRepr *Base, DeclNameRef Name, DeclNameLoc NameLoc,
529
- ArrayRef<TypeRepr *> GenericArgs, SourceRange AngleBrackets);
492
+ QualifiedIdentTypeRepr (TypeRepr *Base, DeclNameRef Name, DeclNameLoc NameLoc,
493
+ ArrayRef<TypeRepr *> GenericArgs,
494
+ SourceRange AngleBrackets);
530
495
531
496
public:
532
- static MemberTypeRepr *create (const ASTContext &C, TypeRepr *Base,
533
- DeclNameLoc NameLoc, DeclNameRef Name);
497
+ static QualifiedIdentTypeRepr *create (const ASTContext &C, TypeRepr *Base,
498
+ DeclNameLoc NameLoc, DeclNameRef Name);
534
499
535
- static MemberTypeRepr *create (const ASTContext &C, TypeRepr *Base,
536
- DeclNameLoc NameLoc, DeclNameRef Name,
537
- ArrayRef<TypeRepr *> GenericArgs,
538
- SourceRange AngleBrackets);
500
+ static QualifiedIdentTypeRepr *create (const ASTContext &C, TypeRepr *Base,
501
+ DeclNameLoc NameLoc, DeclNameRef Name,
502
+ ArrayRef<TypeRepr *> GenericArgs,
503
+ SourceRange AngleBrackets);
539
504
540
505
// / Returns the qualifier or base type representation. For example, `A.B`
541
506
// / for `A.B.C`.
@@ -549,13 +514,12 @@ class MemberTypeRepr final
549
514
SourceRange getAngleBrackets () const ;
550
515
551
516
static bool classof (const TypeRepr *T) {
552
- return T->getKind () == TypeReprKind::Member ;
517
+ return T->getKind () == TypeReprKind::QualifiedIdent ;
553
518
}
554
- static bool classof (const MemberTypeRepr *T) { return true ; }
519
+ static bool classof (const QualifiedIdentTypeRepr *T) { return true ; }
555
520
556
521
private:
557
522
SourceLoc getStartLocImpl () const ;
558
- SourceLoc getEndLocImpl () const ;
559
523
560
524
friend class TypeRepr ;
561
525
};
@@ -1640,9 +1604,8 @@ inline bool TypeRepr::isSimple() const {
1640
1604
case TypeReprKind::Existential:
1641
1605
case TypeReprKind::PackElement:
1642
1606
return false ;
1643
- case TypeReprKind::SimpleIdent:
1644
- case TypeReprKind::GenericIdent:
1645
- case TypeReprKind::Member:
1607
+ case TypeReprKind::UnqualifiedIdent:
1608
+ case TypeReprKind::QualifiedIdent:
1646
1609
case TypeReprKind::Metatype:
1647
1610
case TypeReprKind::Protocol:
1648
1611
case TypeReprKind::Dictionary:
0 commit comments