Revert "Revert "Merge remote-tracking branch 'origin/4.15'""

This reverts commit f0a86d4510.

Reverting a merge doesn't "undo" it - the changes would be lost
forever even with subsequent merges.
So we need to revert the revert to get the changes.

Change-Id: I65928f876f4dc886561bed17c4b2aa42b388c1e3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Eike Ziller
2021-05-07 09:19:39 +02:00
parent 635993fbdc
commit bf5b1d714c
42 changed files with 415 additions and 335 deletions

View File

@@ -1366,7 +1366,9 @@ bool Check::visit(Block *ast)
&& !cast<WhileStatement *>(p)
&& !cast<IfStatement *>(p)
&& !cast<SwitchStatement *>(p)
&& !cast<WithStatement *>(p)) {
&& !isCaseOrDefault(p)
&& !cast<WithStatement *>(p)
&& hasVarStatement(ast)) {
addMessage(WarnBlock, ast->lbraceToken);
}
if (!ast->statements
@@ -1656,6 +1658,33 @@ bool Check::isQtQuick2Ui() const
return _doc->language() == Dialect::QmlQtQuick2Ui;
}
bool Check::isCaseOrDefault(Node *n)
{
if (!cast<StatementList *>(n))
return false;
if (Node *p = parent(1))
return p->kind == Node::Kind_CaseClause || p->kind == Node::Kind_DefaultClause;
return false;
}
bool Check::hasVarStatement(AST::Block *b) const
{
QTC_ASSERT(b, return false);
StatementList *s = b->statements;
while (s) {
if (auto var = cast<VariableStatement *>(s->statement)) {
VariableDeclarationList *declList = var->declarations;
while (declList) {
if (declList->declaration && declList->declaration->scope == VariableScope::Var)
return true;
declList = declList->next;
}
}
s = s->next;
}
return false;
}
bool Check::visit(NewExpression *ast)
{
checkNewExpression(ast->expression);