@@ -676,7 +676,6 @@ class alignas(1 << DeclAlignInBits) Decl {
676
676
677
677
Decl (const Decl&) = delete ;
678
678
void operator =(const Decl&) = delete ;
679
- SourceLoc getLocFromSource () const ;
680
679
681
680
protected:
682
681
@@ -1583,7 +1582,7 @@ enum class ImportKind : uint8_t {
1583
1582
class ImportDecl final : public Decl,
1584
1583
private llvm::TrailingObjects<ImportDecl, std::pair<Identifier,SourceLoc>> {
1585
1584
friend TrailingObjects;
1586
- friend class Decl ;
1585
+
1587
1586
public:
1588
1587
typedef std::pair<Identifier, SourceLoc> AccessPathElement;
1589
1588
@@ -1655,7 +1654,7 @@ class ImportDecl final : public Decl,
1655
1654
}
1656
1655
1657
1656
SourceLoc getStartLoc () const { return ImportLoc; }
1658
- SourceLoc getLocFromSource () const { return getFullAccessPath ().front ().second ; }
1657
+ SourceLoc getLoc () const { return getFullAccessPath ().front ().second ; }
1659
1658
SourceRange getSourceRange () const {
1660
1659
return SourceRange (ImportLoc, getFullAccessPath ().back ().second );
1661
1660
}
@@ -1717,7 +1716,6 @@ class ExtensionDecl final : public GenericContext, public Decl,
1717
1716
std::pair<LazyMemberLoader *, uint64_t > takeConformanceLoaderSlow ();
1718
1717
1719
1718
friend class ExtendedNominalRequest ;
1720
- friend class Decl ;
1721
1719
public:
1722
1720
using Decl::getASTContext;
1723
1721
@@ -1730,7 +1728,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
1730
1728
ClangNode clangNode = ClangNode());
1731
1729
1732
1730
SourceLoc getStartLoc () const { return ExtensionLoc; }
1733
- SourceLoc getLocFromSource () const { return ExtensionLoc; }
1731
+ SourceLoc getLoc () const { return ExtensionLoc; }
1734
1732
SourceRange getSourceRange () const {
1735
1733
return { ExtensionLoc, Braces.End };
1736
1734
}
@@ -2043,7 +2041,7 @@ class PatternBindingEntry {
2043
2041
class PatternBindingDecl final : public Decl,
2044
2042
private llvm::TrailingObjects<PatternBindingDecl, PatternBindingEntry> {
2045
2043
friend TrailingObjects;
2046
- friend class Decl ;
2044
+
2047
2045
SourceLoc StaticLoc; // /< Location of the 'static/class' keyword, if present.
2048
2046
SourceLoc VarLoc; // /< Location of the 'var' keyword.
2049
2047
@@ -2052,7 +2050,7 @@ class PatternBindingDecl final : public Decl,
2052
2050
PatternBindingDecl (SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
2053
2051
SourceLoc VarLoc, unsigned NumPatternEntries,
2054
2052
DeclContext *Parent);
2055
- SourceLoc getLocFromSource () const { return VarLoc; }
2053
+
2056
2054
public:
2057
2055
static PatternBindingDecl *create (ASTContext &Ctx, SourceLoc StaticLoc,
2058
2056
StaticSpellingKind StaticSpelling,
@@ -2082,6 +2080,7 @@ class PatternBindingDecl final : public Decl,
2082
2080
SourceLoc getStartLoc () const {
2083
2081
return StaticLoc.isValid () ? StaticLoc : VarLoc;
2084
2082
}
2083
+ SourceLoc getLoc () const { return VarLoc; }
2085
2084
SourceRange getSourceRange () const ;
2086
2085
2087
2086
unsigned getNumPatternEntries () const {
@@ -2217,8 +2216,7 @@ class PatternBindingDecl final : public Decl,
2217
2216
// / global variables.
2218
2217
class TopLevelCodeDecl : public DeclContext , public Decl {
2219
2218
BraceStmt *Body;
2220
- SourceLoc getLocFromSource () const { return getStartLoc (); }
2221
- friend class Decl ;
2219
+
2222
2220
public:
2223
2221
TopLevelCodeDecl (DeclContext *Parent, BraceStmt *Body = nullptr )
2224
2222
: DeclContext(DeclContextKind::TopLevelCodeDecl, Parent),
@@ -2229,6 +2227,7 @@ class TopLevelCodeDecl : public DeclContext, public Decl {
2229
2227
void setBody (BraceStmt *b) { Body = b; }
2230
2228
2231
2229
SourceLoc getStartLoc () const ;
2230
+ SourceLoc getLoc () const { return getStartLoc (); }
2232
2231
SourceRange getSourceRange () const ;
2233
2232
2234
2233
static bool classof (const Decl *D) {
@@ -2267,8 +2266,6 @@ class IfConfigDecl : public Decl {
2267
2266
// / The array is ASTContext allocated.
2268
2267
ArrayRef<IfConfigClause> Clauses;
2269
2268
SourceLoc EndLoc;
2270
- SourceLoc getLocFromSource () const { return Clauses[0 ].Loc ; }
2271
- friend class Decl ;
2272
2269
public:
2273
2270
2274
2271
IfConfigDecl (DeclContext *Parent, ArrayRef<IfConfigClause> Clauses,
@@ -2294,6 +2291,7 @@ class IfConfigDecl : public Decl {
2294
2291
}
2295
2292
2296
2293
SourceLoc getEndLoc () const { return EndLoc; }
2294
+ SourceLoc getLoc () const { return Clauses[0 ].Loc ; }
2297
2295
2298
2296
bool hadMissingEnd () const { return Bits.IfConfigDecl .HadMissingEnd ; }
2299
2297
@@ -2310,8 +2308,7 @@ class PoundDiagnosticDecl : public Decl {
2310
2308
SourceLoc StartLoc;
2311
2309
SourceLoc EndLoc;
2312
2310
StringLiteralExpr *Message;
2313
- SourceLoc getLocFromSource () const { return StartLoc; }
2314
- friend class Decl ;
2311
+
2315
2312
public:
2316
2313
PoundDiagnosticDecl (DeclContext *Parent, bool IsError, SourceLoc StartLoc,
2317
2314
SourceLoc EndLoc, StringLiteralExpr *Message)
@@ -2340,6 +2337,7 @@ class PoundDiagnosticDecl : public Decl {
2340
2337
}
2341
2338
2342
2339
SourceLoc getEndLoc () const { return EndLoc; };
2340
+ SourceLoc getLoc () const { return StartLoc; }
2343
2341
2344
2342
SourceRange getSourceRange () const {
2345
2343
return SourceRange (StartLoc, EndLoc);
@@ -2402,8 +2400,7 @@ class ValueDecl : public Decl {
2402
2400
friend class IsFinalRequest ;
2403
2401
friend class IsDynamicRequest ;
2404
2402
friend class IsImplicitlyUnwrappedOptionalRequest ;
2405
- friend class Decl ;
2406
- SourceLoc getLocFromSource () const { return NameLoc; }
2403
+
2407
2404
protected:
2408
2405
ValueDecl (DeclKind K,
2409
2406
llvm::PointerUnion<DeclContext *, ASTContext *> context,
@@ -2476,6 +2473,7 @@ class ValueDecl : public Decl {
2476
2473
bool canInferObjCFromRequirement (ValueDecl *requirement);
2477
2474
2478
2475
SourceLoc getNameLoc () const { return NameLoc; }
2476
+ SourceLoc getLoc () const { return NameLoc; }
2479
2477
2480
2478
bool isUsableFromInline () const ;
2481
2479
@@ -5691,8 +5689,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5691
5689
// / Note that a true return value does not imply that the body was actually
5692
5690
// / parsed.
5693
5691
bool hasBody () const {
5694
- return getBodyKind () != BodyKind::None &&
5695
- getBodyKind () != BodyKind::Skipped;
5692
+ return getBodyKind () != BodyKind::None;
5696
5693
}
5697
5694
5698
5695
// / Returns true if the text of this function's body can be retrieved either
@@ -5719,22 +5716,14 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5719
5716
// / Note that the body was skipped for this function. Function body
5720
5717
// / cannot be attached after this call.
5721
5718
void setBodySkipped (SourceRange bodyRange) {
5722
- // FIXME: Remove 'Parsed' from this once we can delay parsing function
5723
- // bodies. Right now -experimental-skip-non-inlinable-function-bodies
5724
- // requires being able to change the state from Parsed to Skipped,
5725
- // because we're still eagerly parsing function bodies.
5726
- assert (getBodyKind () == BodyKind::None ||
5727
- getBodyKind () == BodyKind::Unparsed ||
5728
- getBodyKind () == BodyKind::Parsed);
5729
- assert (bodyRange.isValid ());
5719
+ assert (getBodyKind () == BodyKind::None);
5730
5720
BodyRange = bodyRange;
5731
5721
setBodyKind (BodyKind::Skipped);
5732
5722
}
5733
5723
5734
5724
// / Note that parsing for the body was delayed.
5735
5725
void setBodyDelayed (SourceRange bodyRange) {
5736
5726
assert (getBodyKind () == BodyKind::None);
5737
- assert (bodyRange.isValid ());
5738
5727
BodyRange = bodyRange;
5739
5728
setBodyKind (BodyKind::Unparsed);
5740
5729
}
@@ -5780,10 +5769,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5780
5769
return getBodyKind () == BodyKind::TypeChecked;
5781
5770
}
5782
5771
5783
- bool isBodySkipped () const {
5784
- return getBodyKind () == BodyKind::Skipped;
5785
- }
5786
-
5787
5772
bool isMemberwiseInitializer () const {
5788
5773
return getBodyKind () == BodyKind::MemberwiseInitializer;
5789
5774
}
@@ -6283,7 +6268,6 @@ AbstractStorageDecl::AccessorRecord::getAccessor(AccessorKind kind) const {
6283
6268
class EnumCaseDecl final : public Decl,
6284
6269
private llvm::TrailingObjects<EnumCaseDecl, EnumElementDecl *> {
6285
6270
friend TrailingObjects;
6286
- friend class Decl ;
6287
6271
SourceLoc CaseLoc;
6288
6272
6289
6273
EnumCaseDecl (SourceLoc CaseLoc,
@@ -6296,7 +6280,6 @@ class EnumCaseDecl final : public Decl,
6296
6280
std::uninitialized_copy (Elements.begin (), Elements.end (),
6297
6281
getTrailingObjects<EnumElementDecl *>());
6298
6282
}
6299
- SourceLoc getLocFromSource () const { return CaseLoc; }
6300
6283
6301
6284
public:
6302
6285
static EnumCaseDecl *create (SourceLoc CaseLoc,
@@ -6308,6 +6291,11 @@ class EnumCaseDecl final : public Decl,
6308
6291
return {getTrailingObjects<EnumElementDecl *>(),
6309
6292
Bits.EnumCaseDecl .NumElements };
6310
6293
}
6294
+
6295
+ SourceLoc getLoc () const {
6296
+ return CaseLoc;
6297
+ }
6298
+
6311
6299
SourceRange getSourceRange () const ;
6312
6300
6313
6301
static bool classof (const Decl *D) {
@@ -6341,7 +6329,9 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
6341
6329
6342
6330
// / The raw value literal for the enum element, or null.
6343
6331
LiteralExpr *RawValueExpr;
6344
-
6332
+ // / The type-checked raw value expression.
6333
+ Expr *TypeCheckedRawValueExpr = nullptr ;
6334
+
6345
6335
public:
6346
6336
EnumElementDecl (SourceLoc IdentifierLoc, DeclName Name,
6347
6337
ParameterList *Params,
@@ -6374,6 +6364,13 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
6374
6364
bool hasRawValueExpr () const { return RawValueExpr; }
6375
6365
LiteralExpr *getRawValueExpr () const { return RawValueExpr; }
6376
6366
void setRawValueExpr (LiteralExpr *e) { RawValueExpr = e; }
6367
+
6368
+ Expr *getTypeCheckedRawValueExpr () const {
6369
+ return TypeCheckedRawValueExpr;
6370
+ }
6371
+ void setTypeCheckedRawValueExpr (Expr *e) {
6372
+ TypeCheckedRawValueExpr = e;
6373
+ }
6377
6374
6378
6375
// / Return the containing EnumDecl.
6379
6376
EnumDecl *getParentEnum () const {
@@ -6720,8 +6717,7 @@ class PrecedenceGroupDecl : public Decl {
6720
6717
SourceLoc higherThanLoc, ArrayRef<Relation> higherThan,
6721
6718
SourceLoc lowerThanLoc, ArrayRef<Relation> lowerThan,
6722
6719
SourceLoc rbraceLoc);
6723
- friend class Decl ;
6724
- SourceLoc getLocFromSource () const { return NameLoc; }
6720
+
6725
6721
public:
6726
6722
static PrecedenceGroupDecl *create (DeclContext *dc,
6727
6723
SourceLoc precedenceGroupLoc,
@@ -6741,6 +6737,7 @@ class PrecedenceGroupDecl : public Decl {
6741
6737
SourceLoc rbraceLoc);
6742
6738
6743
6739
6740
+ SourceLoc getLoc () const { return NameLoc; }
6744
6741
SourceRange getSourceRange () const {
6745
6742
return { PrecedenceGroupLoc, RBraceLoc };
6746
6743
}
@@ -6859,8 +6856,7 @@ class OperatorDecl : public Decl {
6859
6856
ArrayRef<Identifier> Identifiers;
6860
6857
ArrayRef<SourceLoc> IdentifierLocs;
6861
6858
ArrayRef<NominalTypeDecl *> DesignatedNominalTypes;
6862
- SourceLoc getLocFromSource () const { return NameLoc; }
6863
- friend class Decl ;
6859
+
6864
6860
public:
6865
6861
OperatorDecl (DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
6866
6862
Identifier Name, SourceLoc NameLoc,
@@ -6875,6 +6871,7 @@ class OperatorDecl : public Decl {
6875
6871
: Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
6876
6872
DesignatedNominalTypes(DesignatedNominalTypes) {}
6877
6873
6874
+ SourceLoc getLoc () const { return NameLoc; }
6878
6875
6879
6876
SourceLoc getOperatorLoc () const { return OperatorLoc; }
6880
6877
SourceLoc getNameLoc () const { return NameLoc; }
@@ -7037,10 +7034,6 @@ class MissingMemberDecl : public Decl {
7037
7034
&& " not enough bits" );
7038
7035
setImplicit ();
7039
7036
}
7040
- friend class Decl ;
7041
- SourceLoc getLocFromSource () const {
7042
- return SourceLoc ();
7043
- }
7044
7037
public:
7045
7038
static MissingMemberDecl *
7046
7039
create (ASTContext &ctx, DeclContext *DC, DeclName name,
@@ -7065,6 +7058,10 @@ class MissingMemberDecl : public Decl {
7065
7058
return Bits.MissingMemberDecl .NumberOfFieldOffsetVectorEntries ;
7066
7059
}
7067
7060
7061
+ SourceLoc getLoc () const {
7062
+ return SourceLoc ();
7063
+ }
7064
+
7068
7065
SourceRange getSourceRange () const {
7069
7066
return SourceRange ();
7070
7067
}
0 commit comments