Skip to content

Commit b7bd4fb

Browse files
committed
ASTScope: Remove 'history' vector
1 parent c9f2060 commit b7bd4fb

File tree

5 files changed

+47
-90
lines changed

5 files changed

+47
-90
lines changed

include/swift/AST/ASTScope.h

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ class ASTScopeImpl {
407407
using DeclConsumer = namelookup::AbstractASTScopeDeclConsumer &;
408408

409409
/// Entry point into ASTScopeImpl-land for lookups
410-
static llvm::SmallVector<const ASTScopeImpl *, 0>
410+
static void
411411
unqualifiedLookup(SourceFile *, DeclNameRef, SourceLoc, DeclConsumer);
412412

413413
/// Entry point into ASTScopeImpl-land for labeled statement lookups.
@@ -457,22 +457,17 @@ class ASTScopeImpl {
457457
/// duplicating work.
458458
///
459459
/// Look in this scope.
460-
/// \param history are the scopes traversed for this lookup (including this
461-
/// one) \param limit A scope into which lookup should not go. See \c
460+
/// \param limit A scope into which lookup should not go. See \c
462461
/// getLookupLimit. \param lastListSearched Last list searched.
463462
/// \param consumer is the object to which found decls are reported.
464-
void lookup(llvm::SmallVectorImpl<const ASTScopeImpl *> &history,
465-
NullablePtr<const ASTScopeImpl> limit,
463+
void lookup(NullablePtr<const ASTScopeImpl> limit,
466464
NullablePtr<const GenericParamList> lastListSearched,
467465
DeclConsumer consumer) const;
468466

469467
protected:
470468
/// Find either locals or members (no scope has both)
471-
/// \param history The scopes visited since the start of lookup (including
472-
/// this one)
473469
/// \return True if lookup is done
474-
virtual bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *> history,
475-
DeclConsumer consumer) const;
470+
virtual bool lookupLocalsOrMembers(DeclConsumer consumer) const;
476471

477472
/// Returns isDone and the list searched, if any
478473
std::pair<bool, NullablePtr<const GenericParamList>>
@@ -606,7 +601,6 @@ class Portion {
606601
bool omitAssertions) const = 0;
607602

608603
virtual bool lookupMembersOf(const GenericTypeOrExtensionScope *scope,
609-
ArrayRef<const ASTScopeImpl *>,
610604
ASTScopeImpl::DeclConsumer consumer) const;
611605

612606
virtual NullablePtr<const ASTScopeImpl>
@@ -668,7 +662,6 @@ class Portion {
668662
virtual ~GenericTypeOrExtensionWhereOrBodyPortion() {}
669663

670664
bool lookupMembersOf(const GenericTypeOrExtensionScope *scope,
671-
ArrayRef<const ASTScopeImpl *>,
672665
ASTScopeImpl::DeclConsumer consumer) const override;
673666
};
674667

@@ -681,7 +674,6 @@ class GenericTypeOrExtensionWherePortion final
681674
: GenericTypeOrExtensionWhereOrBodyPortion("Where") {}
682675

683676
bool lookupMembersOf(const GenericTypeOrExtensionScope *scope,
684-
ArrayRef<const ASTScopeImpl *>,
685677
ASTScopeImpl::DeclConsumer consumer) const override;
686678

687679
ASTScopeImpl *expandScope(GenericTypeOrExtensionScope *,
@@ -785,8 +777,7 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
785777

786778
protected:
787779
bool
788-
lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *> history,
789-
ASTScopeImpl::DeclConsumer consumer) const override;
780+
lookupLocalsOrMembers(ASTScopeImpl::DeclConsumer consumer) const override;
790781
void printSpecifics(llvm::raw_ostream &out) const override;
791782

792783
public:
@@ -952,8 +943,7 @@ class GenericParamScope final : public ASTScopeImpl {
952943
}
953944

954945
protected:
955-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
956-
DeclConsumer) const override;
946+
bool lookupLocalsOrMembers(DeclConsumer) const override;
957947
};
958948

959949
/// Concrete class for a function/initializer/deinitializer
@@ -1058,8 +1048,7 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
10581048
NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued() override;
10591049

10601050
protected:
1061-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1062-
DeclConsumer) const override;
1051+
bool lookupLocalsOrMembers(DeclConsumer) const override;
10631052

10641053
public:
10651054
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion() override;
@@ -1072,8 +1061,7 @@ class FunctionBodyScope final : public AbstractFunctionBodyScope {
10721061
FunctionBodyScope(AbstractFunctionDecl *e)
10731062
: AbstractFunctionBodyScope(e) {}
10741063
std::string getClassName() const override;
1075-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1076-
DeclConsumer consumer) const override;
1064+
bool lookupLocalsOrMembers(DeclConsumer consumer) const override;
10771065
};
10781066

10791067
class DefaultArgumentInitializerScope final : public ASTScopeImpl {
@@ -1211,8 +1199,7 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
12111199
NullablePtr<const void> getReferrent() const override;
12121200

12131201
protected:
1214-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1215-
DeclConsumer) const override;
1202+
bool lookupLocalsOrMembers(DeclConsumer) const override;
12161203
};
12171204

12181205
class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
@@ -1239,8 +1226,7 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
12391226
virtual NullablePtr<DeclContext> getDeclContext() const override;
12401227

12411228
protected:
1242-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1243-
DeclConsumer) const override;
1229+
bool lookupLocalsOrMembers(DeclConsumer) const override;
12441230
};
12451231

12461232
/// The scope introduced by a conditional clause in an if/guard/while
@@ -1302,8 +1288,7 @@ class ConditionalClausePatternUseScope final : public ASTScopeImpl {
13021288

13031289
protected:
13041290
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
1305-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1306-
DeclConsumer) const override;
1291+
bool lookupLocalsOrMembers(DeclConsumer) const override;
13071292
void printSpecifics(llvm::raw_ostream &out) const override;
13081293
bool isLabeledStmtLookupTerminator() const override;
13091294
};
@@ -1330,8 +1315,7 @@ class CaptureListScope final : public ASTScopeImpl {
13301315
NullablePtr<Expr> getExprIfAny() const override { return expr; }
13311316
Expr *getExpr() const { return expr; }
13321317
NullablePtr<const void> getReferrent() const override;
1333-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1334-
DeclConsumer) const override;
1318+
bool lookupLocalsOrMembers(DeclConsumer) const override;
13351319
};
13361320

13371321
/// For a closure with named parameters, this scope does the local bindings.
@@ -1364,8 +1348,7 @@ class ClosureParametersScope final : public ASTScopeImpl {
13641348
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
13651349

13661350
protected:
1367-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1368-
DeclConsumer) const override;
1351+
bool lookupLocalsOrMembers(DeclConsumer) const override;
13691352
};
13701353

13711354
class TopLevelCodeScope final : public ASTScopeImpl {
@@ -1429,8 +1412,7 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
14291412

14301413
protected:
14311414
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
1432-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1433-
DeclConsumer) const override;
1415+
bool lookupLocalsOrMembers(DeclConsumer) const override;
14341416
};
14351417

14361418
/// A `@differentiable` attribute scope.
@@ -1463,8 +1445,7 @@ class DifferentiableAttributeScope final : public ASTScopeImpl {
14631445

14641446
protected:
14651447
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
1466-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1467-
DeclConsumer) const override;
1448+
bool lookupLocalsOrMembers(DeclConsumer) const override;
14681449
};
14691450

14701451
class SubscriptDeclScope final : public ASTScopeImpl {
@@ -1763,8 +1744,7 @@ class ForEachPatternScope final : public ASTScopeImpl {
17631744
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
17641745

17651746
protected:
1766-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1767-
DeclConsumer) const override;
1747+
bool lookupLocalsOrMembers(DeclConsumer) const override;
17681748
bool isLabeledStmtLookupTerminator() const override;
17691749
};
17701750

@@ -1842,8 +1822,7 @@ class CaseLabelItemScope final : public ASTScopeImpl {
18421822
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
18431823

18441824
protected:
1845-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1846-
ASTScopeImpl::DeclConsumer) const override;
1825+
bool lookupLocalsOrMembers(ASTScopeImpl::DeclConsumer) const override;
18471826
};
18481827

18491828
/// The scope used for the body of a 'case' statement.
@@ -1871,8 +1850,7 @@ class CaseStmtBodyScope final : public ASTScopeImpl {
18711850
SourceRange
18721851
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
18731852
protected:
1874-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1875-
ASTScopeImpl::DeclConsumer) const override;
1853+
bool lookupLocalsOrMembers(ASTScopeImpl::DeclConsumer) const override;
18761854
bool isLabeledStmtLookupTerminator() const override;
18771855
};
18781856

@@ -1900,8 +1878,7 @@ class BraceStmtScope final : public AbstractStmtScope {
19001878
Stmt *getStmt() const override { return stmt; }
19011879

19021880
protected:
1903-
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
1904-
DeclConsumer) const override;
1881+
bool lookupLocalsOrMembers(DeclConsumer) const override;
19051882
};
19061883
} // namespace ast_scope
19071884
} // namespace swift

include/swift/AST/NameLookup.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,8 @@ class ASTScope {
681681
/// Flesh out the tree for dumping
682682
void buildFullyExpandedTree();
683683

684-
/// \return the scopes traversed
685-
static llvm::SmallVector<const ast_scope::ASTScopeImpl *, 0>
686-
unqualifiedLookup(SourceFile *, DeclNameRef, SourceLoc,
687-
namelookup::AbstractASTScopeDeclConsumer &);
684+
static void unqualifiedLookup(SourceFile *, DeclNameRef, SourceLoc,
685+
namelookup::AbstractASTScopeDeclConsumer &);
688686

689687
/// Entry point to record the visible statement labels from the given
690688
/// point.

lib/AST/ASTScope.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ using namespace ast_scope;
3838

3939
#pragma mark ASTScope
4040

41-
llvm::SmallVector<const ASTScopeImpl *, 0> ASTScope::unqualifiedLookup(
41+
void ASTScope::unqualifiedLookup(
4242
SourceFile *SF, DeclNameRef name, SourceLoc loc,
4343
namelookup::AbstractASTScopeDeclConsumer &consumer) {
4444
if (auto *s = SF->getASTContext().Stats)
4545
++s->getFrontendCounters().NumASTScopeLookups;
46-
return ASTScopeImpl::unqualifiedLookup(SF, name, loc, consumer);
46+
ASTScopeImpl::unqualifiedLookup(SF, name, loc, consumer);
4747
}
4848

4949
llvm::SmallVector<LabeledStmt *, 4> ASTScope::lookupLabeledStmts(

0 commit comments

Comments
 (0)