CppEditor: Fix crash

Fixes: QTCREATORBUG-26441
Change-Id: Ib5a99d474eac8677a65eb8a4a9b4fbe259c61ad3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Christian Kandeler
2021-10-19 18:15:28 +02:00
parent 5de4743bb4
commit 755932eca7

View File

@@ -417,17 +417,18 @@ bool maybeAppendArgumentOrParameterList(QString *expression, const QTextCursor &
bool isCursorOnTrailingReturnType(const QList<AST *> &astPath)
{
for (auto it = astPath.cend() - 1, begin = astPath.cbegin(); it >= begin; --it) {
if (astPath.size() < 3)
return false;
for (auto it = astPath.cend() - 3, begin = astPath.cbegin(); it >= begin; --it) {
if (!(*it)->asTrailingReturnType())
continue;
const auto nextIt = it + 1;
const auto nextNextIt = nextIt + 1;
if (nextNextIt != astPath.cend() && (*it)->asTrailingReturnType()) {
return (*nextIt)->asNamedTypeSpecifier()
&& ((*nextNextIt)->asSimpleName()
|| (*nextNextIt)->asQualifiedName()
|| (*nextNextIt)->asTemplateId());
}
return (*nextIt)->asNamedTypeSpecifier()
&& ((*nextNextIt)->asSimpleName()
|| (*nextNextIt)->asQualifiedName()
|| (*nextNextIt)->asTemplateId());
}
return false;
}