@@ -530,6 +530,12 @@ class NormalProtocolConformance : public RootProtocolConformance,
530530 // / The location of this protocol conformance in the source.
531531 SourceLoc Loc;
532532
533+ // / The location of the protocol name within the conformance.
534+ SourceLoc ProtocolNameLoc;
535+
536+ // / The location of the `@preconcurrency` attribute, if any.
537+ SourceLoc PreconcurrencyLoc;
538+
533539 // / The declaration context containing the ExtensionDecl or
534540 // / NominalTypeDecl that declared the conformance.
535541 DeclContext *Context;
@@ -562,12 +568,17 @@ class NormalProtocolConformance : public RootProtocolConformance,
562568 NormalProtocolConformance (Type conformingType, ProtocolDecl *protocol,
563569 SourceLoc loc, DeclContext *dc,
564570 ProtocolConformanceState state, bool isUnchecked,
565- bool isPreconcurrency)
571+ bool isPreconcurrency,
572+ SourceLoc preconcurrencyLoc)
566573 : RootProtocolConformance(ProtocolConformanceKind::Normal,
567574 conformingType),
568- Protocol (protocol), Loc(loc), Context(dc) {
575+ Protocol (protocol), Loc(extractNearestSourceLoc(dc)),
576+ ProtocolNameLoc(loc), PreconcurrencyLoc(preconcurrencyLoc),
577+ Context(dc) {
569578 assert (!conformingType->hasArchetype () &&
570579 " ProtocolConformances should store interface types" );
580+ assert ((preconcurrencyLoc.isInvalid () || isPreconcurrency) &&
581+ " Cannot have a @preconcurrency location without isPreconcurrency" );
571582 setState (state);
572583 Bits.NormalProtocolConformance .IsInvalid = false ;
573584 Bits.NormalProtocolConformance .IsUnchecked = isUnchecked;
@@ -580,9 +591,12 @@ class NormalProtocolConformance : public RootProtocolConformance,
580591 // / Get the protocol being conformed to.
581592 ProtocolDecl *getProtocol () const { return Protocol; }
582593
583- // / Retrieve the location of this
594+ // / Retrieve the location of this conformance.
584595 SourceLoc getLoc () const { return Loc; }
585596
597+ // / Retrieve the name of the protocol location.
598+ SourceLoc getProtocolNameLoc () const { return ProtocolNameLoc; }
599+
586600 // / Get the declaration context that contains the conforming extension or
587601 // / nominal type declaration.
588602 DeclContext *getDeclContext () const { return Context; }
@@ -629,6 +643,10 @@ class NormalProtocolConformance : public RootProtocolConformance,
629643 return Bits.NormalProtocolConformance .IsPreconcurrency ;
630644 }
631645
646+ // / Retrieve the location of `@preconcurrency`, if there is one and it is
647+ // / known.
648+ SourceLoc getPreconcurrencyLoc () const { return PreconcurrencyLoc; }
649+
632650 // / Determine whether we've lazily computed the associated conformance array
633651 // / already.
634652 bool hasComputedAssociatedConformances () const {
0 commit comments