@@ -1005,14 +1005,11 @@ class SyntacticElementConstraintGenerator
1005
1005
}
1006
1006
1007
1007
void visitSwitchStmt (SwitchStmt *switchStmt) {
1008
- auto *switchLoc = cs.getConstraintLocator (
1009
- locator, LocatorPathElt::SyntacticElement (switchStmt));
1010
-
1011
1008
SmallVector<ElementInfo, 4 > elements;
1012
1009
{
1013
1010
auto *subjectExpr = switchStmt->getSubjectExpr ();
1014
1011
{
1015
- elements.push_back (makeElement (subjectExpr, switchLoc ));
1012
+ elements.push_back (makeElement (subjectExpr, locator ));
1016
1013
1017
1014
SyntacticElementTarget target (subjectExpr, context.getAsDeclContext (),
1018
1015
CTP_Unused, Type (),
@@ -1022,32 +1019,29 @@ class SyntacticElementConstraintGenerator
1022
1019
}
1023
1020
1024
1021
for (auto rawCase : switchStmt->getRawCases ())
1025
- elements.push_back (makeElement (rawCase, switchLoc ));
1022
+ elements.push_back (makeElement (rawCase, locator ));
1026
1023
}
1027
1024
1028
- createConjunction (elements, switchLoc );
1025
+ createConjunction (elements, locator );
1029
1026
}
1030
1027
1031
1028
void visitDoCatchStmt (DoCatchStmt *doStmt) {
1032
- auto *doLoc = cs.getConstraintLocator (
1033
- locator, LocatorPathElt::SyntacticElement (doStmt));
1034
-
1035
1029
SmallVector<ElementInfo, 4 > elements;
1036
1030
1037
1031
// First, let's record a body of `do` statement. Note we need to add a
1038
1032
// SyntaticElement locator path element here to avoid treating the inner
1039
1033
// brace conjunction as being isolated if 'doLoc' is for an isolated
1040
1034
// conjunction (as is the case with 'do' expressions).
1041
1035
auto *doBodyLoc = cs.getConstraintLocator (
1042
- doLoc , LocatorPathElt::SyntacticElement (doStmt->getBody ()));
1036
+ locator , LocatorPathElt::SyntacticElement (doStmt->getBody ()));
1043
1037
elements.push_back (makeElement (doStmt->getBody (), doBodyLoc));
1044
1038
1045
1039
// After that has been type-checked, let's switch to
1046
1040
// individual `catch` statements.
1047
1041
for (auto *catchStmt : doStmt->getCatches ())
1048
- elements.push_back (makeElement (catchStmt, doLoc ));
1042
+ elements.push_back (makeElement (catchStmt, locator ));
1049
1043
1050
- createConjunction (elements, doLoc );
1044
+ createConjunction (elements, locator );
1051
1045
}
1052
1046
1053
1047
void visitCaseStmt (CaseStmt *caseStmt) {
@@ -1546,7 +1540,9 @@ bool ConstraintSystem::generateConstraints(SingleValueStmtExpr *E) {
1546
1540
1547
1541
// Generate the conjunction for the branches.
1548
1542
auto context = SyntacticElementContext::forSingleValueStmtExpr (E, join);
1549
- SyntacticElementConstraintGenerator generator (*this , context, loc);
1543
+ auto *stmtLoc =
1544
+ getConstraintLocator (loc, LocatorPathElt::SyntacticElement (S));
1545
+ SyntacticElementConstraintGenerator generator (*this , context, stmtLoc);
1550
1546
generator.visit (S);
1551
1547
return generator.hadError ;
1552
1548
}
0 commit comments