Merge "Merge remote-tracking branch 'origin/7.0'"

This commit is contained in:
The Qt Project
2022-04-22 08:30:05 +00:00
23 changed files with 341 additions and 492 deletions

View File

@@ -3973,10 +3973,18 @@ void ExtraHighlightingResultsCollector::collectFromNode(const AstNode &node)
QString detail = node.detail().value_or(QString());
const bool isCallToNew = node.kind() == "CXXNew";
const bool isCallToDelete = node.kind() == "CXXDelete";
if (!isCallToNew && !isCallToDelete
&& (!detail.startsWith(operatorPrefix) || detail == operatorPrefix)) {
const auto isProperOperator = [&] {
if (isCallToNew || isCallToDelete)
return true;
if (!detail.startsWith(operatorPrefix))
return false;
if (detail == operatorPrefix)
return false;
const QChar nextChar = detail.at(operatorPrefix.length());
return !nextChar.isLetterOrNumber() && nextChar != '_';
};
if (!isProperOperator())
return;
}
if (!isCallToNew && !isCallToDelete)
detail.remove(0, operatorPrefix.length());

View File

@@ -1329,6 +1329,14 @@ void ClangdTestHighlighting::test_data()
<< QList<int>{C_FIELD} << 0;
QTest::newRow("pass inherited member by value") << 1038 << 21 << 1038 << 26
<< QList<int>{C_FIELD} << 0;
QTest::newRow("fake operator member declaration") << 1045 << 9 << 1045 << 23
<< QList<int>{C_FIELD, C_DECLARATION} << 0;
QTest::newRow("fake operator method declaration") << 1046 << 10 << 1046 << 24
<< QList<int>{C_FUNCTION, C_DECLARATION} << 0;
QTest::newRow("fake operator member access") << 1049 << 8 << 1049 << 22
<< QList<int>{C_FIELD} << 0;
QTest::newRow("fake operator method call") << 1050 << 8 << 1050 << 22
<< QList<int>{C_FUNCTION} << 0;
}
void ClangdTestHighlighting::test()

View File

@@ -1040,3 +1040,12 @@ template<typename T> class Derived2 : public BaseWithMember2
return false;
}
};
struct StructWithMisleadingMemberNames {
int operatormember;
void operatorMethod();
};
void useStrangeStruct(StructWithMisleadingMemberNames *s) {
s->operatormember = 5;
s->operatorMethod();
}