@@ -141,22 +141,13 @@ class ASTScopeImpl {
141
141
ASTScopeImpl *parent = nullptr ; // null at the root
142
142
143
143
// / Child scopes, sorted by source range.
144
- // / Must clear source range change whenever this changes
145
144
Children storedChildren;
146
145
147
146
bool wasExpanded = false ;
148
147
149
148
// / Can clear storedChildren, so must remember this
150
149
bool haveAddedCleanup = false ;
151
150
152
- // Must be updated after last child is added and after last child's source
153
- // position is known
154
- mutable Optional<SourceRange> cachedSourceRange;
155
-
156
- // When ignoring ASTNodes in a scope, they still must count towards a scope's
157
- // source range. So include their ranges here
158
- SourceRange sourceRangeOfIgnoredASTNodes;
159
-
160
151
mutable Optional<CharSourceRange> cachedCharSourceRange;
161
152
162
153
#pragma mark - constructor / destructor
@@ -194,9 +185,6 @@ class ASTScopeImpl {
194
185
public:
195
186
void addChild (ASTScopeImpl *child, ASTContext &);
196
187
197
- private:
198
- NullablePtr<ASTScopeImpl> getPriorSibling () const ;
199
-
200
188
public:
201
189
void preOrderDo (function_ref<void (ASTScopeImpl *)>);
202
190
// / Like preorderDo but without myself.
@@ -205,67 +193,15 @@ class ASTScopeImpl {
205
193
206
194
#pragma mark - source ranges
207
195
208
- #pragma mark - source range queries
209
-
210
196
public:
211
197
// / Return signum of ranges. Centralize the invariant that ASTScopes use ends.
212
198
static int compare (SourceRange, SourceRange, const SourceManager &,
213
199
bool ensureDisjoint);
214
200
215
- SourceRange getSourceRangeOfScope (bool omitAssertions = false ) const ;
216
-
217
201
CharSourceRange getCharSourceRangeOfScope (SourceManager &SM,
218
202
bool omitAssertions = false ) const ;
219
203
bool isCharSourceRangeCached () const ;
220
204
221
- // / InterpolatedStringLiteralExprs and EditorPlaceHolders respond to
222
- // / getSourceRange with the starting point. But we might be asked to lookup an
223
- // / identifer within one of them. So, find the real source range of them here.
224
- SourceRange getEffectiveSourceRange (ASTNode) const ;
225
-
226
- void computeAndCacheSourceRangeOfScope (bool omitAssertions = false ) const ;
227
- bool isSourceRangeCached (bool omitAssertions = false ) const ;
228
-
229
- bool checkSourceRangeOfThisASTNode () const ;
230
-
231
- // / For debugging
232
- bool doesRangeMatch (unsigned start, unsigned end, StringRef file = " " ,
233
- StringRef className = " " );
234
-
235
- unsigned countDescendants () const ;
236
-
237
- // / Make sure that when the argument is executed, there are as many
238
- // / descendants after as before.
239
- void assertThatTreeDoesNotShrink (function_ref<void ()>);
240
-
241
- private:
242
- SourceRange computeSourceRangeOfScope (bool omitAssertions = false ) const ;
243
- SourceRange
244
- computeSourceRangeOfScopeWithChildASTNodes (bool omitAssertions = false ) const ;
245
- bool ensureNoAncestorsSourceRangeIsCached () const ;
246
-
247
- #pragma mark - source range adjustments
248
- private:
249
- SourceRange widenSourceRangeForIgnoredASTNodes (SourceRange range) const ;
250
-
251
- // / If the scope refers to a Decl whose source range tells the whole story,
252
- // / for example a NominalTypeScope, it is not necessary to widen the source
253
- // / range by examining the children. In that case we could just return
254
- // / the childlessRange here.
255
- // / But, we have not marked such scopes yet. Doing so would be an
256
- // / optimization.
257
- SourceRange widenSourceRangeForChildren (SourceRange range,
258
- bool omitAssertions) const ;
259
-
260
- // / Even ASTNodes that do not form scopes must be included in a Scope's source
261
- // / range. Widen the source range of the receiver to include the (ignored)
262
- // / node.
263
- void widenSourceRangeForIgnoredASTNode (ASTNode);
264
-
265
- private:
266
- void clearCachedSourceRangesOfMeAndAncestors ();
267
-
268
- public: // public for debugging
269
205
// / Returns source range of this node alone, without factoring in any
270
206
// / children.
271
207
virtual SourceRange
@@ -331,19 +267,11 @@ class ASTScopeImpl {
331
267
void setWasExpanded () { wasExpanded = true ; }
332
268
virtual ASTScopeImpl *expandSpecifically (ScopeCreator &) = 0;
333
269
334
- private:
335
- // / Compare the pre-expasion range with the post-expansion range and return
336
- // / false if lazyiness couild miss lookups.
337
- bool checkLazySourceRange (const ASTContext &) const ;
338
-
339
270
public:
340
271
// / Some scopes can be expanded lazily.
341
- // / Such scopes must: not change their source ranges after expansion, and
342
- // / their expansion must return an insertion point outside themselves.
343
- // / After a node is expanded, its source range (getSourceRangeofThisASTNode
344
- // / union children's ranges) must be same as this.
272
+ // / Such scopes must return an insertion point outside themselves when
273
+ // / expanded.
345
274
virtual NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion ();
346
- virtual SourceRange sourceRangeForDeferredExpansion () const ;
347
275
348
276
private:
349
277
virtual ScopeCreator &getScopeCreator ();
@@ -547,8 +475,6 @@ class Portion {
547
475
548
476
virtual NullablePtr<ASTScopeImpl>
549
477
insertionPointForDeferredExpansion (IterableTypeScope *) const = 0 ;
550
- virtual SourceRange
551
- sourceRangeForDeferredExpansion (const IterableTypeScope *) const = 0 ;
552
478
};
553
479
554
480
// For the whole Decl scope of a GenericType or an Extension
@@ -572,8 +498,6 @@ class Portion {
572
498
573
499
NullablePtr<ASTScopeImpl>
574
500
insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
575
- SourceRange
576
- sourceRangeForDeferredExpansion (const IterableTypeScope *) const override ;
577
501
};
578
502
579
503
// / GenericTypeOrExtension = GenericType or Extension
@@ -605,8 +529,6 @@ class GenericTypeOrExtensionWherePortion final
605
529
606
530
NullablePtr<ASTScopeImpl>
607
531
insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
608
- SourceRange
609
- sourceRangeForDeferredExpansion (const IterableTypeScope *) const override ;
610
532
};
611
533
612
534
// / Behavior specific to representing the Body of a NominalTypeDecl or
@@ -624,8 +546,6 @@ class IterableTypeBodyPortion final
624
546
625
547
NullablePtr<ASTScopeImpl>
626
548
insertionPointForDeferredExpansion (IterableTypeScope *) const override ;
627
- SourceRange
628
- sourceRangeForDeferredExpansion (const IterableTypeScope *) const override ;
629
549
};
630
550
631
551
// / GenericType or Extension scope
@@ -722,7 +642,6 @@ class IterableTypeScope : public GenericTypeScope {
722
642
723
643
public:
724
644
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
725
- SourceRange sourceRangeForDeferredExpansion () const override ;
726
645
727
646
void countBodies (ScopeCreator &) const ;
728
647
};
@@ -931,7 +850,6 @@ class FunctionBodyScope : public ASTScopeImpl {
931
850
public:
932
851
std::string getClassName () const override ;
933
852
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
934
- SourceRange sourceRangeForDeferredExpansion () const override ;
935
853
};
936
854
937
855
class DefaultArgumentInitializerScope final : public ASTScopeImpl {
0 commit comments