@@ -676,6 +676,7 @@ class alignas(1 << DeclAlignInBits) Decl {
676
676
677
677
Decl (const Decl&) = delete ;
678
678
void operator =(const Decl&) = delete ;
679
+ SourceLoc getLocFromSource () const ;
679
680
680
681
protected:
681
682
@@ -1582,7 +1583,7 @@ enum class ImportKind : uint8_t {
1582
1583
class ImportDecl final : public Decl,
1583
1584
private llvm::TrailingObjects<ImportDecl, std::pair<Identifier,SourceLoc>> {
1584
1585
friend TrailingObjects;
1585
-
1586
+ friend class Decl ;
1586
1587
public:
1587
1588
typedef std::pair<Identifier, SourceLoc> AccessPathElement;
1588
1589
@@ -1654,7 +1655,7 @@ class ImportDecl final : public Decl,
1654
1655
}
1655
1656
1656
1657
SourceLoc getStartLoc () const { return ImportLoc; }
1657
- SourceLoc getLoc () const { return getFullAccessPath ().front ().second ; }
1658
+ SourceLoc getLocFromSource () const { return getFullAccessPath ().front ().second ; }
1658
1659
SourceRange getSourceRange () const {
1659
1660
return SourceRange (ImportLoc, getFullAccessPath ().back ().second );
1660
1661
}
@@ -1716,6 +1717,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
1716
1717
std::pair<LazyMemberLoader *, uint64_t > takeConformanceLoaderSlow ();
1717
1718
1718
1719
friend class ExtendedNominalRequest ;
1720
+ friend class Decl ;
1719
1721
public:
1720
1722
using Decl::getASTContext;
1721
1723
@@ -1728,7 +1730,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
1728
1730
ClangNode clangNode = ClangNode());
1729
1731
1730
1732
SourceLoc getStartLoc () const { return ExtensionLoc; }
1731
- SourceLoc getLoc () const { return ExtensionLoc; }
1733
+ SourceLoc getLocFromSource () const { return ExtensionLoc; }
1732
1734
SourceRange getSourceRange () const {
1733
1735
return { ExtensionLoc, Braces.End };
1734
1736
}
@@ -2041,7 +2043,7 @@ class PatternBindingEntry {
2041
2043
class PatternBindingDecl final : public Decl,
2042
2044
private llvm::TrailingObjects<PatternBindingDecl, PatternBindingEntry> {
2043
2045
friend TrailingObjects;
2044
-
2046
+ friend class Decl ;
2045
2047
SourceLoc StaticLoc; // /< Location of the 'static/class' keyword, if present.
2046
2048
SourceLoc VarLoc; // /< Location of the 'var' keyword.
2047
2049
@@ -2050,7 +2052,7 @@ class PatternBindingDecl final : public Decl,
2050
2052
PatternBindingDecl (SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
2051
2053
SourceLoc VarLoc, unsigned NumPatternEntries,
2052
2054
DeclContext *Parent);
2053
-
2055
+ SourceLoc getLocFromSource () const { return VarLoc; }
2054
2056
public:
2055
2057
static PatternBindingDecl *create (ASTContext &Ctx, SourceLoc StaticLoc,
2056
2058
StaticSpellingKind StaticSpelling,
@@ -2080,7 +2082,6 @@ class PatternBindingDecl final : public Decl,
2080
2082
SourceLoc getStartLoc () const {
2081
2083
return StaticLoc.isValid () ? StaticLoc : VarLoc;
2082
2084
}
2083
- SourceLoc getLoc () const { return VarLoc; }
2084
2085
SourceRange getSourceRange () const ;
2085
2086
2086
2087
unsigned getNumPatternEntries () const {
@@ -2216,7 +2217,8 @@ class PatternBindingDecl final : public Decl,
2216
2217
// / global variables.
2217
2218
class TopLevelCodeDecl : public DeclContext , public Decl {
2218
2219
BraceStmt *Body;
2219
-
2220
+ SourceLoc getLocFromSource () const { return getStartLoc (); }
2221
+ friend class Decl ;
2220
2222
public:
2221
2223
TopLevelCodeDecl (DeclContext *Parent, BraceStmt *Body = nullptr )
2222
2224
: DeclContext(DeclContextKind::TopLevelCodeDecl, Parent),
@@ -2227,7 +2229,6 @@ class TopLevelCodeDecl : public DeclContext, public Decl {
2227
2229
void setBody (BraceStmt *b) { Body = b; }
2228
2230
2229
2231
SourceLoc getStartLoc () const ;
2230
- SourceLoc getLoc () const { return getStartLoc (); }
2231
2232
SourceRange getSourceRange () const ;
2232
2233
2233
2234
static bool classof (const Decl *D) {
@@ -2266,6 +2267,8 @@ class IfConfigDecl : public Decl {
2266
2267
// / The array is ASTContext allocated.
2267
2268
ArrayRef<IfConfigClause> Clauses;
2268
2269
SourceLoc EndLoc;
2270
+ SourceLoc getLocFromSource () const { return Clauses[0 ].Loc ; }
2271
+ friend class Decl ;
2269
2272
public:
2270
2273
2271
2274
IfConfigDecl (DeclContext *Parent, ArrayRef<IfConfigClause> Clauses,
@@ -2291,7 +2294,6 @@ class IfConfigDecl : public Decl {
2291
2294
}
2292
2295
2293
2296
SourceLoc getEndLoc () const { return EndLoc; }
2294
- SourceLoc getLoc () const { return Clauses[0 ].Loc ; }
2295
2297
2296
2298
bool hadMissingEnd () const { return Bits.IfConfigDecl .HadMissingEnd ; }
2297
2299
@@ -2308,7 +2310,8 @@ class PoundDiagnosticDecl : public Decl {
2308
2310
SourceLoc StartLoc;
2309
2311
SourceLoc EndLoc;
2310
2312
StringLiteralExpr *Message;
2311
-
2313
+ SourceLoc getLocFromSource () const { return StartLoc; }
2314
+ friend class Decl ;
2312
2315
public:
2313
2316
PoundDiagnosticDecl (DeclContext *Parent, bool IsError, SourceLoc StartLoc,
2314
2317
SourceLoc EndLoc, StringLiteralExpr *Message)
@@ -2337,7 +2340,6 @@ class PoundDiagnosticDecl : public Decl {
2337
2340
}
2338
2341
2339
2342
SourceLoc getEndLoc () const { return EndLoc; };
2340
- SourceLoc getLoc () const { return StartLoc; }
2341
2343
2342
2344
SourceRange getSourceRange () const {
2343
2345
return SourceRange (StartLoc, EndLoc);
@@ -2400,7 +2402,8 @@ class ValueDecl : public Decl {
2400
2402
friend class IsFinalRequest ;
2401
2403
friend class IsDynamicRequest ;
2402
2404
friend class IsImplicitlyUnwrappedOptionalRequest ;
2403
-
2405
+ friend class Decl ;
2406
+ SourceLoc getLocFromSource () const { return NameLoc; }
2404
2407
protected:
2405
2408
ValueDecl (DeclKind K,
2406
2409
llvm::PointerUnion<DeclContext *, ASTContext *> context,
@@ -2473,7 +2476,6 @@ class ValueDecl : public Decl {
2473
2476
bool canInferObjCFromRequirement (ValueDecl *requirement);
2474
2477
2475
2478
SourceLoc getNameLoc () const { return NameLoc; }
2476
- SourceLoc getLoc () const { return NameLoc; }
2477
2479
2478
2480
bool isUsableFromInline () const ;
2479
2481
@@ -6281,6 +6283,7 @@ AbstractStorageDecl::AccessorRecord::getAccessor(AccessorKind kind) const {
6281
6283
class EnumCaseDecl final : public Decl,
6282
6284
private llvm::TrailingObjects<EnumCaseDecl, EnumElementDecl *> {
6283
6285
friend TrailingObjects;
6286
+ friend class Decl ;
6284
6287
SourceLoc CaseLoc;
6285
6288
6286
6289
EnumCaseDecl (SourceLoc CaseLoc,
@@ -6293,6 +6296,7 @@ class EnumCaseDecl final : public Decl,
6293
6296
std::uninitialized_copy (Elements.begin (), Elements.end (),
6294
6297
getTrailingObjects<EnumElementDecl *>());
6295
6298
}
6299
+ SourceLoc getLocFromSource () const { return CaseLoc; }
6296
6300
6297
6301
public:
6298
6302
static EnumCaseDecl *create (SourceLoc CaseLoc,
@@ -6304,11 +6308,6 @@ class EnumCaseDecl final : public Decl,
6304
6308
return {getTrailingObjects<EnumElementDecl *>(),
6305
6309
Bits.EnumCaseDecl .NumElements };
6306
6310
}
6307
-
6308
- SourceLoc getLoc () const {
6309
- return CaseLoc;
6310
- }
6311
-
6312
6311
SourceRange getSourceRange () const ;
6313
6312
6314
6313
static bool classof (const Decl *D) {
@@ -6721,7 +6720,8 @@ class PrecedenceGroupDecl : public Decl {
6721
6720
SourceLoc higherThanLoc, ArrayRef<Relation> higherThan,
6722
6721
SourceLoc lowerThanLoc, ArrayRef<Relation> lowerThan,
6723
6722
SourceLoc rbraceLoc);
6724
-
6723
+ friend class Decl ;
6724
+ SourceLoc getLocFromSource () const { return NameLoc; }
6725
6725
public:
6726
6726
static PrecedenceGroupDecl *create (DeclContext *dc,
6727
6727
SourceLoc precedenceGroupLoc,
@@ -6741,7 +6741,6 @@ class PrecedenceGroupDecl : public Decl {
6741
6741
SourceLoc rbraceLoc);
6742
6742
6743
6743
6744
- SourceLoc getLoc () const { return NameLoc; }
6745
6744
SourceRange getSourceRange () const {
6746
6745
return { PrecedenceGroupLoc, RBraceLoc };
6747
6746
}
@@ -6860,7 +6859,8 @@ class OperatorDecl : public Decl {
6860
6859
ArrayRef<Identifier> Identifiers;
6861
6860
ArrayRef<SourceLoc> IdentifierLocs;
6862
6861
ArrayRef<NominalTypeDecl *> DesignatedNominalTypes;
6863
-
6862
+ SourceLoc getLocFromSource () const { return NameLoc; }
6863
+ friend class Decl ;
6864
6864
public:
6865
6865
OperatorDecl (DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
6866
6866
Identifier Name, SourceLoc NameLoc,
@@ -6875,7 +6875,6 @@ class OperatorDecl : public Decl {
6875
6875
: Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
6876
6876
DesignatedNominalTypes(DesignatedNominalTypes) {}
6877
6877
6878
- SourceLoc getLoc () const { return NameLoc; }
6879
6878
6880
6879
SourceLoc getOperatorLoc () const { return OperatorLoc; }
6881
6880
SourceLoc getNameLoc () const { return NameLoc; }
@@ -7038,6 +7037,10 @@ class MissingMemberDecl : public Decl {
7038
7037
&& " not enough bits" );
7039
7038
setImplicit ();
7040
7039
}
7040
+ friend class Decl ;
7041
+ SourceLoc getLocFromSource () const {
7042
+ return SourceLoc ();
7043
+ }
7041
7044
public:
7042
7045
static MissingMemberDecl *
7043
7046
create (ASTContext &ctx, DeclContext *DC, DeclName name,
@@ -7062,10 +7065,6 @@ class MissingMemberDecl : public Decl {
7062
7065
return Bits.MissingMemberDecl .NumberOfFieldOffsetVectorEntries ;
7063
7066
}
7064
7067
7065
- SourceLoc getLoc () const {
7066
- return SourceLoc ();
7067
- }
7068
-
7069
7068
SourceRange getSourceRange () const {
7070
7069
return SourceRange ();
7071
7070
}
0 commit comments