@@ -196,10 +196,12 @@ class alignas(1 << TypeReprAlignInBits) TypeRepr
196196 // / \c Type::getCanonicalType() or \c Type::getWithoutParens().
197197 TypeRepr *getWithoutParens () const ;
198198
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.
200201 bool isSimpleUnqualifiedIdentifier (Identifier identifier) const ;
201202
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.
203205 bool isSimpleUnqualifiedIdentifier (StringRef str) const ;
204206
205207 // *** Allocation Routines ************************************************/
@@ -324,7 +326,7 @@ class AttributedTypeRepr final
324326 friend class TypeRepr ;
325327};
326328
327- class IdentTypeRepr ;
329+ class UnqualifiedIdentTypeRepr ;
328330
329331// / This is the abstract base class for types that directly reference a
330332// / type declaration. In written syntax, this type representation consists of
@@ -361,15 +363,15 @@ class DeclRefTypeRepr : public TypeRepr {
361363 SourceRange AngleBrackets);
362364
363365 // / 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.
365367 TypeRepr *getBase () const ;
366368
367369 // / 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.
369371 TypeRepr *getRoot ();
370372
371373 // / 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.
373375 const TypeRepr *getRoot () const ;
374376
375377 DeclNameLoc getNameLoc () const ;
@@ -407,101 +409,62 @@ class DeclRefTypeRepr : public TypeRepr {
407409 SourceRange getAngleBrackets () const ;
408410
409411 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;
413414 }
414415 static bool classof (const DeclRefTypeRepr *T) { return true ; }
415416
416417protected:
417418 SourceLoc getLocImpl () const ;
419+ SourceLoc getEndLocImpl () const ;
418420
419421 void printImpl (ASTPrinter &Printer, const PrintOptions &Opts) const ;
420422
421423 friend class TypeRepr ;
422424};
423425
424- // / An identifier type with an optional set of generic arguments.
426+ // / An unqualified identifier type an optional set of generic arguments.
425427// / \code
426428// / Foo
427429// / Bar<Gen>
428430// / \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;
434436
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 ();
439439 }
440- static bool classof (const IdentTypeRepr *T) { return true ; }
441440
442- protected:
443- SourceLoc getStartLocImpl () const { return getNameLoc ().getStartLoc (); }
441+ UnqualifiedIdentTypeRepr (DeclNameRef Name, DeclNameLoc NameLoc);
444442
445- friend class TypeRepr ;
446- };
443+ UnqualifiedIdentTypeRepr (DeclNameRef Name, DeclNameLoc NameLoc,
444+ ArrayRef<TypeRepr *> GenericArgs,
445+ SourceRange AngleBrackets);
447446
448- // / A simple identifier type like "Int".
449- class SimpleIdentTypeRepr : public IdentTypeRepr {
450447public:
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);
481450
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);
485455
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 ;
492457
493- ArrayRef<TypeRepr*> getGenericArgs () const {
494- return {getTrailingObjects<TypeRepr *>(), getNumGenericArgs ()};
495- }
496- SourceRange getAngleBrackets () const { return AngleBrackets; }
458+ SourceRange getAngleBrackets () const ;
497459
498460 static bool classof (const TypeRepr *T) {
499- return T->getKind () == TypeReprKind::GenericIdent ;
461+ return T->getKind () == TypeReprKind::UnqualifiedIdent ;
500462 }
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 (); }
502467
503- private:
504- SourceLoc getEndLocImpl () const { return AngleBrackets.End ; }
505468 friend class TypeRepr ;
506469};
507470
@@ -511,9 +474,10 @@ class GenericIdentTypeRepr final
511474// / Foo.Bar<Gen>.Baz
512475// / [Int].Bar
513476// / \endcode
514- class MemberTypeRepr final
477+ class QualifiedIdentTypeRepr final
515478 : public DeclRefTypeRepr,
516- private llvm::TrailingObjects<MemberTypeRepr, TypeRepr *, SourceRange> {
479+ private llvm::TrailingObjects<QualifiedIdentTypeRepr, TypeRepr *,
480+ SourceRange> {
517481 friend TrailingObjects;
518482
519483 // / The qualifier or base type representation. For example, `A.B` for `A.B.C`.
@@ -523,19 +487,20 @@ class MemberTypeRepr final
523487 return getNumGenericArgs ();
524488 }
525489
526- MemberTypeRepr (TypeRepr *Base, DeclNameRef Name, DeclNameLoc NameLoc);
490+ QualifiedIdentTypeRepr (TypeRepr *Base, DeclNameRef Name, DeclNameLoc NameLoc);
527491
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);
530495
531496public:
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);
534499
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);
539504
540505 // / Returns the qualifier or base type representation. For example, `A.B`
541506 // / for `A.B.C`.
@@ -549,13 +514,12 @@ class MemberTypeRepr final
549514 SourceRange getAngleBrackets () const ;
550515
551516 static bool classof (const TypeRepr *T) {
552- return T->getKind () == TypeReprKind::Member ;
517+ return T->getKind () == TypeReprKind::QualifiedIdent ;
553518 }
554- static bool classof (const MemberTypeRepr *T) { return true ; }
519+ static bool classof (const QualifiedIdentTypeRepr *T) { return true ; }
555520
556521private:
557522 SourceLoc getStartLocImpl () const ;
558- SourceLoc getEndLocImpl () const ;
559523
560524 friend class TypeRepr ;
561525};
@@ -1640,9 +1604,8 @@ inline bool TypeRepr::isSimple() const {
16401604 case TypeReprKind::Existential:
16411605 case TypeReprKind::PackElement:
16421606 return false ;
1643- case TypeReprKind::SimpleIdent:
1644- case TypeReprKind::GenericIdent:
1645- case TypeReprKind::Member:
1607+ case TypeReprKind::UnqualifiedIdent:
1608+ case TypeReprKind::QualifiedIdent:
16461609 case TypeReprKind::Metatype:
16471610 case TypeReprKind::Protocol:
16481611 case TypeReprKind::Dictionary:
0 commit comments