@@ -261,7 +261,7 @@ inline UnqualifiedLookupOptions operator|(UnqualifiedLookupFlags flag1,
261
261
// / Describes the reason why a certain declaration is visible.
262
262
enum class DeclVisibilityKind {
263
263
// / Declaration is a local variable or type.
264
- LocalVariable ,
264
+ LocalDecl ,
265
265
266
266
// / Declaration is a function parameter.
267
267
FunctionParameter,
@@ -442,8 +442,8 @@ class AccessFilteringDeclConsumer final : public VisibleDeclConsumer {
442
442
DynamicLookupInfo dynamicLookupInfo = {}) override ;
443
443
};
444
444
445
- // / Filters out decls that are not usable based on their source location, eg .
446
- // / a decl inside its own initializer or a non-type decl before its definition .
445
+ // / Filters out decls that are not usable based on their source location, e.g .
446
+ // / a top-level decl inside its own initializer or shadowed decls .
447
447
class UsableFilteringDeclConsumer final : public VisibleDeclConsumer {
448
448
const SourceManager &SM;
449
449
const DeclContext *DC;
@@ -465,7 +465,7 @@ class UsableFilteringDeclConsumer final : public VisibleDeclConsumer {
465
465
}
466
466
467
467
void foundDecl (ValueDecl *D, DeclVisibilityKind reason,
468
- DynamicLookupInfo dynamicLookupInfo) override ;
468
+ DynamicLookupInfo dynamicLookupInfo = {} ) override ;
469
469
};
470
470
471
471
// / Remove any declarations in the given set that were overridden by
@@ -504,14 +504,11 @@ bool removeShadowedDecls(TinyPtrVector<OperatorDecl *> &decls,
504
504
bool removeShadowedDecls (TinyPtrVector<PrecedenceGroupDecl *> &decls,
505
505
const DeclContext *dc);
506
506
507
- // / Finds decls visible in the given context and feeds them to the given
508
- // / VisibleDeclConsumer. If the current DeclContext is nested in a function,
509
- // / the SourceLoc is used to determine which declarations in that function
510
- // / are visible.
511
- void lookupVisibleDecls (VisibleDeclConsumer &Consumer,
512
- const DeclContext *DC,
513
- bool IncludeTopLevel,
514
- SourceLoc Loc = SourceLoc());
507
+ // / Finds decls visible in the given context at the given location and feeds
508
+ // / them to the given VisibleDeclConsumer. The \p Loc must be valid, and \p DC
509
+ // / must be in a SourceFile.
510
+ void lookupVisibleDecls (VisibleDeclConsumer &Consumer, SourceLoc Loc,
511
+ const DeclContext *DC, bool IncludeTopLevel);
515
512
516
513
// / Finds decls visible as members of the given type and feeds them to the given
517
514
// / VisibleDeclConsumer.
@@ -630,70 +627,6 @@ SelfBounds getSelfBoundsFromGenericSignature(const ExtensionDecl *extDecl);
630
627
631
628
namespace namelookup {
632
629
633
- // / Searches through statements and patterns for local variable declarations.
634
- class FindLocalVal : public StmtVisitor <FindLocalVal> {
635
- friend class ASTVisitor <FindLocalVal>;
636
-
637
- const SourceManager &SM;
638
- SourceLoc Loc;
639
- VisibleDeclConsumer &Consumer;
640
-
641
- public:
642
- FindLocalVal (const SourceManager &SM, SourceLoc Loc,
643
- VisibleDeclConsumer &Consumer)
644
- : SM(SM), Loc(Loc), Consumer(Consumer) {}
645
-
646
- void checkValueDecl (ValueDecl *D, DeclVisibilityKind Reason);
647
-
648
- void checkPattern (const Pattern *Pat, DeclVisibilityKind Reason);
649
-
650
- void checkParameterList (const ParameterList *params);
651
-
652
- void checkGenericParams (GenericParamList *Params);
653
-
654
- void checkSourceFile (const SourceFile &SF);
655
-
656
- private:
657
- bool isReferencePointInRange (SourceRange R) {
658
- return SM.rangeContainsTokenLoc (R, Loc);
659
- }
660
-
661
- void visitBreakStmt (BreakStmt *) {}
662
- void visitContinueStmt (ContinueStmt *) {}
663
- void visitFallthroughStmt (FallthroughStmt *) {}
664
- void visitFailStmt (FailStmt *) {}
665
- void visitReturnStmt (ReturnStmt *) {}
666
- void visitYieldStmt (YieldStmt *) {}
667
- void visitThenStmt (ThenStmt *) {}
668
- void visitThrowStmt (ThrowStmt *) {}
669
- void visitDiscardStmt (DiscardStmt *) {}
670
- void visitPoundAssertStmt (PoundAssertStmt *) {}
671
- void visitDeferStmt (DeferStmt *DS) {
672
- // Nothing in the defer is visible.
673
- }
674
-
675
- void checkStmtCondition (const StmtCondition &Cond);
676
-
677
- void visitIfStmt (IfStmt *S);
678
- void visitGuardStmt (GuardStmt *S);
679
-
680
- void visitWhileStmt (WhileStmt *S);
681
- void visitRepeatWhileStmt (RepeatWhileStmt *S);
682
- void visitDoStmt (DoStmt *S);
683
-
684
- void visitForEachStmt (ForEachStmt *S);
685
-
686
- void visitBraceStmt (BraceStmt *S, bool isTopLevelCode = false );
687
-
688
- void visitSwitchStmt (SwitchStmt *S);
689
-
690
- void visitCaseStmt (CaseStmt *S);
691
-
692
- void visitDoCatchStmt (DoCatchStmt *S);
693
-
694
- };
695
-
696
-
697
630
// / The bridge between the legacy UnqualifiedLookupFactory and the new ASTScope
698
631
// / lookup system
699
632
class AbstractASTScopeDeclConsumer {
@@ -737,9 +670,9 @@ class AbstractASTScopeDeclConsumer {
737
670
}
738
671
739
672
#ifndef NDEBUG
740
- virtual void startingNextLookupStep () = 0;
741
- virtual void finishingLookup (std::string) const = 0;
742
- virtual bool isTargetLookup () const = 0;
673
+ virtual void startingNextLookupStep () {}
674
+ virtual void finishingLookup (std::string) const {}
675
+ virtual bool isTargetLookup () const { return false ; }
743
676
#endif
744
677
};
745
678
0 commit comments