@@ -146,9 +146,6 @@ class ASTScopeImpl {
146146
147147 bool wasExpanded = false ;
148148
149- // / For use-before-def, ASTAncestor scopes may be added to a BraceStmt.
150- unsigned astAncestorScopeCount = 0 ;
151-
152149 // / Can clear storedChildren, so must remember this
153150 bool haveAddedCleanup = false ;
154151
@@ -192,26 +189,10 @@ class ASTScopeImpl {
192189
193190 const Children &getChildren () const { return storedChildren; }
194191
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:
201193 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 ();
212194
213195private:
214- void emancipate () { parent = nullptr ; }
215196 NullablePtr<ASTScopeImpl> getPriorSibling () const ;
216197
217198public:
@@ -278,12 +259,6 @@ class ASTScopeImpl {
278259private:
279260 void clearCachedSourceRangesOfMeAndAncestors ();
280261
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-
287262public: // public for debugging
288263 // / Returns source range of this node alone, without factoring in any
289264 // / children.
@@ -349,23 +324,11 @@ class ASTScopeImpl {
349324 // / fact, above and beyond adding Decls to the SourceFile.
350325 ASTScopeImpl *expandAndBeCurrent (ScopeCreator &);
351326
352- unsigned getASTAncestorScopeCount () const { return astAncestorScopeCount; }
353327 bool getWasExpanded () const { return wasExpanded; }
354328
355329protected:
356- void resetASTAncestorScopeCount () { astAncestorScopeCount = 0 ; }
357- void increaseASTAncestorScopeCount (unsigned c) { astAncestorScopeCount += c; }
358330 void setWasExpanded () { wasExpanded = true ; }
359331 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 ;
369332
370333private:
371334 // / Compare the pre-expasion range with the post-expansion range and return
@@ -382,13 +345,6 @@ class ASTScopeImpl {
382345 virtual SourceRange sourceRangeForDeferredExpansion () const ;
383346
384347public:
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-
392348 virtual NullablePtr<AbstractStorageDecl>
393349 getEnclosingAbstractStorageDecl () const ;
394350
@@ -530,12 +486,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
530486 ScopeCreator *const scopeCreator;
531487 ASTScopeImpl *insertionPoint;
532488
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-
539489 ASTSourceFileScope (SourceFile *SF, ScopeCreator *scopeCreator);
540490
541491 std::string getClassName () const override ;
@@ -560,9 +510,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
560510
561511protected:
562512 ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
563- bool isCurrentIfWasExpanded () const override ;
564- void beCurrent () override ;
565- bool doesExpansionOnlyAddNewDeclsAtEnd () const override ;
566513
567514 ScopeCreator &getScopeCreator () override ;
568515
@@ -609,8 +556,6 @@ class Portion {
609556 virtual const Decl *
610557 getReferrentOfScope (const GenericTypeOrExtensionScope *s) const ;
611558
612- virtual void beCurrent (IterableTypeScope *) const = 0;
613- virtual bool isCurrentIfWasExpanded (const IterableTypeScope *) const = 0;
614559 virtual NullablePtr<ASTScopeImpl>
615560 insertionPointForDeferredExpansion (IterableTypeScope *) const = 0 ;
616561 virtual SourceRange
@@ -636,19 +581,6 @@ class Portion {
636581 const Decl *
637582 getReferrentOfScope (const GenericTypeOrExtensionScope *s) const override ;
638583
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-
652584 NullablePtr<ASTScopeImpl>
653585 insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
654586 SourceRange
@@ -682,9 +614,6 @@ class GenericTypeOrExtensionWherePortion final
682614 SourceRange getChildlessSourceRangeOf (const GenericTypeOrExtensionScope *,
683615 bool omitAssertions) const override ;
684616
685- void beCurrent (IterableTypeScope *) const override ;
686- bool isCurrentIfWasExpanded (const IterableTypeScope *) const override ;
687-
688617 NullablePtr<ASTScopeImpl>
689618 insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
690619 SourceRange
@@ -704,8 +633,6 @@ class IterableTypeBodyPortion final
704633 SourceRange getChildlessSourceRangeOf (const GenericTypeOrExtensionScope *,
705634 bool omitAssertions) const override ;
706635
707- void beCurrent (IterableTypeScope *) const override ;
708- bool isCurrentIfWasExpanded (const IterableTypeScope *) const override ;
709636 NullablePtr<ASTScopeImpl>
710637 insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
711638 SourceRange
@@ -796,11 +723,6 @@ class GenericTypeScope : public GenericTypeOrExtensionScope {
796723};
797724
798725class 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-
804726public:
805727 IterableTypeScope (const Portion *p) : GenericTypeScope(p) {}
806728 virtual ~IterableTypeScope () {}
@@ -810,15 +732,7 @@ class IterableTypeScope : public GenericTypeScope {
810732 bool doesDeclHaveABody () const override ;
811733 void expandBody (ScopeCreator &) override ;
812734
813- protected:
814- void beCurrent () override ;
815- bool isCurrentIfWasExpanded () const override ;
816-
817735public:
818- void makeWholeCurrent ();
819- bool isWholeCurrent () const ;
820- void makeBodyCurrent ();
821- bool isBodyCurrent () const ;
822736 NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
823737 SourceRange sourceRangeForDeferredExpansion () const override ;
824738
@@ -1019,18 +933,11 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
1019933public:
1020934 AbstractFunctionDecl *const decl;
1021935
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-
1027936 AbstractFunctionBodyScope (AbstractFunctionDecl *e) : decl(e) {}
1028937 virtual ~AbstractFunctionBodyScope () {}
1029938
1030939protected:
1031940 ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1032- void beCurrent () override ;
1033- bool isCurrentIfWasExpanded () const override ;
1034941
1035942private:
1036943 void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
@@ -1045,8 +952,6 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
1045952 virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1046953 Decl *getDecl () const { return decl; }
1047954
1048- NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued () override ;
1049-
1050955protected:
1051956 bool lookupLocalsOrMembers (DeclConsumer) const override ;
1052957
@@ -1173,9 +1078,6 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
11731078};
11741079
11751080class PatternEntryDeclScope final : public AbstractPatternEntryScope {
1176- const Expr *initWhenLastExpanded;
1177- unsigned varCountWhenLastExpanded = 0 ;
1178-
11791081public:
11801082 PatternEntryDeclScope (PatternBindingDecl *pbDecl, unsigned entryIndex,
11811083 DeclVisibilityKind vis)
@@ -1184,8 +1086,6 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
11841086
11851087protected:
11861088 ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1187- void beCurrent () override ;
1188- bool isCurrentIfWasExpanded () const override ;
11891089
11901090private:
11911091 AnnotatedInsertionPoint
@@ -1354,20 +1254,16 @@ class ClosureParametersScope final : public ASTScopeImpl {
13541254class TopLevelCodeScope final : public ASTScopeImpl {
13551255public:
13561256 TopLevelCodeDecl *const decl;
1357- BraceStmt *bodyWhenLastExpanded;
13581257
13591258 TopLevelCodeScope (TopLevelCodeDecl *e) : decl(e) {}
13601259 virtual ~TopLevelCodeScope () {}
13611260
13621261protected:
13631262 ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1364- void beCurrent () override ;
1365- bool isCurrentIfWasExpanded () const override ;
13661263
13671264private:
13681265 AnnotatedInsertionPoint
13691266 expandAScopeThatCreatesANewInsertionPoint (ScopeCreator &);
1370- std::vector<ASTScopeImpl *> rescueBodyScopesToReuse ();
13711267
13721268public:
13731269 std::string getClassName () const override ;
@@ -1379,8 +1275,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
13791275 virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
13801276 Decl *getDecl () const { return decl; }
13811277 NullablePtr<const void > getReferrent () const override ;
1382-
1383- NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued () override ;
13841278};
13851279
13861280// / The \c _@specialize attribute.
0 commit comments