Merge pull request #68344 from hamishknight/do-it

This commit is contained in:
Hamish Knight
2023-10-10 10:26:12 +01:00
committed by GitHub
23 changed files with 1134 additions and 73 deletions

View File

@@ -671,7 +671,8 @@ bool ConstraintLocator::isForSingleValueStmtConjunction() const {
}
bool ConstraintLocator::isForSingleValueStmtConjunctionOrBrace() const {
if (!isExpr<SingleValueStmtExpr>(getAnchor()))
auto *SVE = getAsExpr<SingleValueStmtExpr>(getAnchor());
if (!SVE)
return false;
auto path = getPath();
@@ -682,11 +683,17 @@ bool ConstraintLocator::isForSingleValueStmtConjunctionOrBrace() const {
continue;
}
// Ignore a SyntaticElement path element for a case statement of a switch.
// Ignore a SyntaticElement path element for a case statement of a switch,
// or the catch of a do-catch, or the brace of a do-statement.
if (auto elt = path.back().getAs<LocatorPathElt::SyntacticElement>()) {
if (elt->getElement().isStmt(StmtKind::Case)) {
path = path.drop_back();
continue;
break;
}
if (elt->getElement().isStmt(StmtKind::Brace) &&
isa<DoCatchStmt>(SVE->getStmt())) {
path = path.drop_back();
break;
}
}
break;