@@ -146,9 +146,6 @@ class ASTScopeImpl {
146
146
147
147
bool wasExpanded = false ;
148
148
149
- // / For use-before-def, ASTAncestor scopes may be added to a BraceStmt.
150
- unsigned astAncestorScopeCount = 0 ;
151
-
152
149
// / Can clear storedChildren, so must remember this
153
150
bool haveAddedCleanup = false ;
154
151
@@ -192,26 +189,10 @@ class ASTScopeImpl {
192
189
193
190
const Children &getChildren () const { return storedChildren; }
194
191
195
- // / Get ride of descendants and remove them from scopedNodes so the scopes
196
- // / can be recreated. Needed because typechecking inserts a return statment
197
- // / into initializers.
198
- void disownDescendants (ScopeCreator &);
199
-
200
- public: // for addReusedBodyScopes
192
+ public:
201
193
void addChild (ASTScopeImpl *child, ASTContext &);
202
- std::vector<ASTScopeImpl *> rescueASTAncestorScopesForReuseFromMe ();
203
-
204
- // / When reexpanding, do we always create a new body?
205
- virtual NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued ();
206
- std::vector<ASTScopeImpl *>
207
- rescueASTAncestorScopesForReuseFromMeOrDescendants ();
208
- void replaceASTAncestorScopes (ArrayRef<ASTScopeImpl *>);
209
-
210
- private:
211
- void removeChildren ();
212
194
213
195
private:
214
- void emancipate () { parent = nullptr ; }
215
196
NullablePtr<ASTScopeImpl> getPriorSibling () const ;
216
197
217
198
public:
@@ -278,12 +259,6 @@ class ASTScopeImpl {
278
259
private:
279
260
void clearCachedSourceRangesOfMeAndAncestors ();
280
261
281
- public:
282
- // / Since source ranges are cached but depend on child ranges,
283
- // / when descendants are added, my and my ancestor ranges must be
284
- // / recalculated.
285
- void ensureSourceRangesAreCorrectWhenAddingDescendants (function_ref<void ()>);
286
-
287
262
public: // public for debugging
288
263
// / Returns source range of this node alone, without factoring in any
289
264
// / children.
@@ -349,23 +324,11 @@ class ASTScopeImpl {
349
324
// / fact, above and beyond adding Decls to the SourceFile.
350
325
ASTScopeImpl *expandAndBeCurrent (ScopeCreator &);
351
326
352
- unsigned getASTAncestorScopeCount () const { return astAncestorScopeCount; }
353
327
bool getWasExpanded () const { return wasExpanded; }
354
328
355
329
protected:
356
- void resetASTAncestorScopeCount () { astAncestorScopeCount = 0 ; }
357
- void increaseASTAncestorScopeCount (unsigned c) { astAncestorScopeCount += c; }
358
330
void setWasExpanded () { wasExpanded = true ; }
359
331
virtual ASTScopeImpl *expandSpecifically (ScopeCreator &) = 0;
360
- virtual void beCurrent ();
361
- virtual bool doesExpansionOnlyAddNewDeclsAtEnd () const ;
362
-
363
- public:
364
- bool isExpansionNeeded (const ScopeCreator &) const ;
365
-
366
- protected:
367
- bool isCurrent () const ;
368
- virtual bool isCurrentIfWasExpanded () const ;
369
332
370
333
private:
371
334
// / Compare the pre-expasion range with the post-expansion range and return
@@ -382,13 +345,6 @@ class ASTScopeImpl {
382
345
virtual SourceRange sourceRangeForDeferredExpansion () const ;
383
346
384
347
public:
385
- // Some nodes (VarDecls and Accessors) are created directly from
386
- // pattern scope code and should neither be deferred nor should
387
- // contribute to widenSourceRangeForIgnoredASTNode.
388
- // Closures and captures are also created directly but are
389
- // screened out because they are expressions.
390
- static bool isHandledSpeciallyByPatterns (const ASTNode n);
391
-
392
348
virtual NullablePtr<AbstractStorageDecl>
393
349
getEnclosingAbstractStorageDecl () const ;
394
350
@@ -530,12 +486,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
530
486
ScopeCreator *const scopeCreator;
531
487
ASTScopeImpl *insertionPoint;
532
488
533
- // / The number of \c Decls in the \c SourceFile that were already seen.
534
- // / Since parsing can be interleaved with type-checking, on every
535
- // / lookup, look at creating scopes for any \c Decls beyond this number.
536
- // / TODO: Unify with numberOfChildrenWhenLastExpanded
537
- size_t numberOfDeclsAlreadySeen = 0 ;
538
-
539
489
ASTSourceFileScope (SourceFile *SF, ScopeCreator *scopeCreator);
540
490
541
491
std::string getClassName () const override ;
@@ -560,9 +510,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
560
510
561
511
protected:
562
512
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
563
- bool isCurrentIfWasExpanded () const override ;
564
- void beCurrent () override ;
565
- bool doesExpansionOnlyAddNewDeclsAtEnd () const override ;
566
513
567
514
ScopeCreator &getScopeCreator () override ;
568
515
@@ -609,8 +556,6 @@ class Portion {
609
556
virtual const Decl *
610
557
getReferrentOfScope (const GenericTypeOrExtensionScope *s) const ;
611
558
612
- virtual void beCurrent (IterableTypeScope *) const = 0;
613
- virtual bool isCurrentIfWasExpanded (const IterableTypeScope *) const = 0;
614
559
virtual NullablePtr<ASTScopeImpl>
615
560
insertionPointForDeferredExpansion (IterableTypeScope *) const = 0 ;
616
561
virtual SourceRange
@@ -636,19 +581,6 @@ class Portion {
636
581
const Decl *
637
582
getReferrentOfScope (const GenericTypeOrExtensionScope *s) const override ;
638
583
639
- // / Make whole portion lazy to avoid circularity in lookup of generic
640
- // / parameters of extensions. When \c bindExtension is called, it needs to
641
- // / unqualifed-lookup the type being extended. That causes an \c
642
- // / ExtensionScope
643
- // / (\c GenericTypeOrExtensionWholePortion) to be built.
644
- // / The building process needs the generic parameters, but that results in a
645
- // / request for the extended nominal type of the \c ExtensionDecl, which is
646
- // / an endless recursion. Although we only need to make \c ExtensionScope
647
- // / lazy, might as well do it for all \c IterableTypeScopes.
648
-
649
- void beCurrent (IterableTypeScope *) const override ;
650
- bool isCurrentIfWasExpanded (const IterableTypeScope *) const override ;
651
-
652
584
NullablePtr<ASTScopeImpl>
653
585
insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
654
586
SourceRange
@@ -682,9 +614,6 @@ class GenericTypeOrExtensionWherePortion final
682
614
SourceRange getChildlessSourceRangeOf (const GenericTypeOrExtensionScope *,
683
615
bool omitAssertions) const override ;
684
616
685
- void beCurrent (IterableTypeScope *) const override ;
686
- bool isCurrentIfWasExpanded (const IterableTypeScope *) const override ;
687
-
688
617
NullablePtr<ASTScopeImpl>
689
618
insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
690
619
SourceRange
@@ -704,8 +633,6 @@ class IterableTypeBodyPortion final
704
633
SourceRange getChildlessSourceRangeOf (const GenericTypeOrExtensionScope *,
705
634
bool omitAssertions) const override ;
706
635
707
- void beCurrent (IterableTypeScope *) const override ;
708
- bool isCurrentIfWasExpanded (const IterableTypeScope *) const override ;
709
636
NullablePtr<ASTScopeImpl>
710
637
insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
711
638
SourceRange
@@ -796,11 +723,6 @@ class GenericTypeScope : public GenericTypeOrExtensionScope {
796
723
};
797
724
798
725
class IterableTypeScope : public GenericTypeScope {
799
- // / Because of \c parseDelayedDecl members can get added after the tree is
800
- // / constructed, and they can be out of order. Detect this happening by
801
- // / remembering the member count.
802
- unsigned memberCount = 0 ;
803
-
804
726
public:
805
727
IterableTypeScope (const Portion *p) : GenericTypeScope(p) {}
806
728
virtual ~IterableTypeScope () {}
@@ -810,15 +732,7 @@ class IterableTypeScope : public GenericTypeScope {
810
732
bool doesDeclHaveABody () const override ;
811
733
void expandBody (ScopeCreator &) override ;
812
734
813
- protected:
814
- void beCurrent () override ;
815
- bool isCurrentIfWasExpanded () const override ;
816
-
817
735
public:
818
- void makeWholeCurrent ();
819
- bool isWholeCurrent () const ;
820
- void makeBodyCurrent ();
821
- bool isBodyCurrent () const ;
822
736
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
823
737
SourceRange sourceRangeForDeferredExpansion () const override ;
824
738
@@ -1019,18 +933,11 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
1019
933
public:
1020
934
AbstractFunctionDecl *const decl;
1021
935
1022
- // / \c Parser::parseAbstractFunctionBodyDelayed can call \c
1023
- // / AbstractFunctionDecl::setBody after the tree has been constructed. So if
1024
- // / this changes, have to rebuild body.
1025
- NullablePtr<BraceStmt> bodyWhenLastExpanded;
1026
-
1027
936
AbstractFunctionBodyScope (AbstractFunctionDecl *e) : decl(e) {}
1028
937
virtual ~AbstractFunctionBodyScope () {}
1029
938
1030
939
protected:
1031
940
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1032
- void beCurrent () override ;
1033
- bool isCurrentIfWasExpanded () const override ;
1034
941
1035
942
private:
1036
943
void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
@@ -1045,8 +952,6 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
1045
952
virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1046
953
Decl *getDecl () const { return decl; }
1047
954
1048
- NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued () override ;
1049
-
1050
955
protected:
1051
956
bool lookupLocalsOrMembers (DeclConsumer) const override ;
1052
957
@@ -1173,9 +1078,6 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
1173
1078
};
1174
1079
1175
1080
class PatternEntryDeclScope final : public AbstractPatternEntryScope {
1176
- const Expr *initWhenLastExpanded;
1177
- unsigned varCountWhenLastExpanded = 0 ;
1178
-
1179
1081
public:
1180
1082
PatternEntryDeclScope (PatternBindingDecl *pbDecl, unsigned entryIndex,
1181
1083
DeclVisibilityKind vis)
@@ -1184,8 +1086,6 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
1184
1086
1185
1087
protected:
1186
1088
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1187
- void beCurrent () override ;
1188
- bool isCurrentIfWasExpanded () const override ;
1189
1089
1190
1090
private:
1191
1091
AnnotatedInsertionPoint
@@ -1354,20 +1254,16 @@ class ClosureParametersScope final : public ASTScopeImpl {
1354
1254
class TopLevelCodeScope final : public ASTScopeImpl {
1355
1255
public:
1356
1256
TopLevelCodeDecl *const decl;
1357
- BraceStmt *bodyWhenLastExpanded;
1358
1257
1359
1258
TopLevelCodeScope (TopLevelCodeDecl *e) : decl(e) {}
1360
1259
virtual ~TopLevelCodeScope () {}
1361
1260
1362
1261
protected:
1363
1262
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1364
- void beCurrent () override ;
1365
- bool isCurrentIfWasExpanded () const override ;
1366
1263
1367
1264
private:
1368
1265
AnnotatedInsertionPoint
1369
1266
expandAScopeThatCreatesANewInsertionPoint (ScopeCreator &);
1370
- std::vector<ASTScopeImpl *> rescueBodyScopesToReuse ();
1371
1267
1372
1268
public:
1373
1269
std::string getClassName () const override ;
@@ -1379,8 +1275,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
1379
1275
virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1380
1276
Decl *getDecl () const { return decl; }
1381
1277
NullablePtr<const void > getReferrent () const override ;
1382
-
1383
- NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued () override ;
1384
1278
};
1385
1279
1386
1280
// / The \c _@specialize attribute.
0 commit comments