@@ -1307,14 +1307,14 @@ unsigned PatternBindingDecl::getPatternEntryIndexForVarDecl(const VarDecl *VD) c
13071307
13081308 auto List = getPatternList ();
13091309 if (List.size () == 1 ) {
1310- assert (patternContainsVarDeclBinding ( List[0 ].getPattern (), VD) &&
1310+ assert (List[0 ].getPattern ()-> containsVarDecl ( VD) &&
13111311 " Single entry PatternBindingDecl is set up wrong" );
13121312 return 0 ;
13131313 }
13141314
13151315 unsigned Result = 0 ;
13161316 for (auto entry : List) {
1317- if (patternContainsVarDeclBinding ( entry.getPattern (), VD))
1317+ if (entry.getPattern ()-> containsVarDecl ( VD))
13181318 return Result;
13191319 ++Result;
13201320 }
@@ -4927,12 +4927,6 @@ SourceRange VarDecl::getTypeSourceRangeForDiagnostics() const {
49274927 return SourceRange ();
49284928}
49294929
4930- static bool isVarInPattern (const VarDecl *vd, Pattern *p) {
4931- bool foundIt = false ;
4932- p->forEachVariable ([&](VarDecl *foundFD) { foundIt |= foundFD == vd; });
4933- return foundIt;
4934- }
4935-
49364930static Optional<std::pair<CaseStmt *, Pattern *>>
49374931findParentPatternCaseStmtAndPattern (const VarDecl *inputVD) {
49384932 auto getMatchingPattern = [&](CaseStmt *cs) -> Pattern * {
@@ -4946,7 +4940,7 @@ findParentPatternCaseStmtAndPattern(const VarDecl *inputVD) {
49464940
49474941 // Then check the rest of our case label items.
49484942 for (auto &item : cs->getMutableCaseLabelItems ()) {
4949- if (isVarInPattern (inputVD, item.getPattern ())) {
4943+ if (item.getPattern ()-> containsVarDecl (inputVD )) {
49504944 return item.getPattern ();
49514945 }
49524946 }
@@ -5039,15 +5033,15 @@ Pattern *VarDecl::getParentPattern() const {
50395033 // In a case statement, search for the pattern that contains it. This is
50405034 // a bit silly, because you can't have something like "case x, y:" anyway.
50415035 for (auto items : cs->getCaseLabelItems ()) {
5042- if (isVarInPattern ( this , items.getPattern ()))
5036+ if (items.getPattern ()-> containsVarDecl ( this ))
50435037 return items.getPattern ();
50445038 }
50455039 }
50465040
50475041 if (auto *LCS = dyn_cast<LabeledConditionalStmt>(stmt)) {
50485042 for (auto &elt : LCS->getCond ())
50495043 if (auto pat = elt.getPatternOrNull ())
5050- if (isVarInPattern (this , pat ))
5044+ if (pat-> containsVarDecl (this ))
50515045 return pat;
50525046 }
50535047
0 commit comments