@@ -1307,14 +1307,14 @@ unsigned PatternBindingDecl::getPatternEntryIndexForVarDecl(const VarDecl *VD) c
1307
1307
1308
1308
auto List = getPatternList ();
1309
1309
if (List.size () == 1 ) {
1310
- assert (patternContainsVarDeclBinding ( List[0 ].getPattern (), VD) &&
1310
+ assert (List[0 ].getPattern ()-> containsVarDecl ( VD) &&
1311
1311
" Single entry PatternBindingDecl is set up wrong" );
1312
1312
return 0 ;
1313
1313
}
1314
1314
1315
1315
unsigned Result = 0 ;
1316
1316
for (auto entry : List) {
1317
- if (patternContainsVarDeclBinding ( entry.getPattern (), VD))
1317
+ if (entry.getPattern ()-> containsVarDecl ( VD))
1318
1318
return Result;
1319
1319
++Result;
1320
1320
}
@@ -4927,12 +4927,6 @@ SourceRange VarDecl::getTypeSourceRangeForDiagnostics() const {
4927
4927
return SourceRange ();
4928
4928
}
4929
4929
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
-
4936
4930
static Optional<std::pair<CaseStmt *, Pattern *>>
4937
4931
findParentPatternCaseStmtAndPattern (const VarDecl *inputVD) {
4938
4932
auto getMatchingPattern = [&](CaseStmt *cs) -> Pattern * {
@@ -4946,7 +4940,7 @@ findParentPatternCaseStmtAndPattern(const VarDecl *inputVD) {
4946
4940
4947
4941
// Then check the rest of our case label items.
4948
4942
for (auto &item : cs->getMutableCaseLabelItems ()) {
4949
- if (isVarInPattern (inputVD, item.getPattern ())) {
4943
+ if (item.getPattern ()-> containsVarDecl (inputVD )) {
4950
4944
return item.getPattern ();
4951
4945
}
4952
4946
}
@@ -5039,15 +5033,15 @@ Pattern *VarDecl::getParentPattern() const {
5039
5033
// In a case statement, search for the pattern that contains it. This is
5040
5034
// a bit silly, because you can't have something like "case x, y:" anyway.
5041
5035
for (auto items : cs->getCaseLabelItems ()) {
5042
- if (isVarInPattern ( this , items.getPattern ()))
5036
+ if (items.getPattern ()-> containsVarDecl ( this ))
5043
5037
return items.getPattern ();
5044
5038
}
5045
5039
}
5046
5040
5047
5041
if (auto *LCS = dyn_cast<LabeledConditionalStmt>(stmt)) {
5048
5042
for (auto &elt : LCS->getCond ())
5049
5043
if (auto pat = elt.getPatternOrNull ())
5050
- if (isVarInPattern (this , pat ))
5044
+ if (pat-> containsVarDecl (this ))
5051
5045
return pat;
5052
5046
}
5053
5047
0 commit comments