forked from qt-creator/qt-creator
ClangCodeModel: Fix another false positive
... in output argument highlighting. Fixes: QTCREATORBUG-27367 Change-Id: I80fc7628d62de18f9114290b8104a7a1e9a95c4b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -2710,11 +2710,10 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (it->kind() == "Call") {
|
if (it->kind() == "Call") {
|
||||||
// In class templates, member calls can result in "Call" nodes rather than
|
// The first child is e.g. a called lambda or an object on which
|
||||||
// "CXXMemberCall". We try to detect this by checking for a certain kind of
|
// the call happens, and should not be highlighted as an output argument.
|
||||||
// child node.
|
|
||||||
const QList<AstNode> children = it->children().value_or(QList<AstNode>());
|
const QList<AstNode> children = it->children().value_or(QList<AstNode>());
|
||||||
return children.isEmpty() || children.first().kind() != "CXXDependentScopeMember";
|
return children.isEmpty() || children.first().range() != (it - 1)->range();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The token should get marked for e.g. lambdas, but not for assignment operators,
|
// The token should get marked for e.g. lambdas, but not for assignment operators,
|
||||||
|
@@ -1323,6 +1323,10 @@ void ClangdTestHighlighting::test_data()
|
|||||||
<< QList<int>{C_LOCAL} << 0;
|
<< QList<int>{C_LOCAL} << 0;
|
||||||
QTest::newRow("member access via operator->") << 1009 << 7 << 1009 << 21
|
QTest::newRow("member access via operator->") << 1009 << 7 << 1009 << 21
|
||||||
<< QList<int>{C_FIELD} << 0;
|
<< QList<int>{C_FIELD} << 0;
|
||||||
|
QTest::newRow("lambda call in member") << 1023 << 9 << 1023 << 15
|
||||||
|
<< QList<int>{C_LOCAL} << 0;
|
||||||
|
QTest::newRow("call on inherited member") << 1024 << 9 << 1024 << 12
|
||||||
|
<< QList<int>{C_FIELD} << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangdTestHighlighting::test()
|
void ClangdTestHighlighting::test()
|
||||||
@@ -1425,12 +1429,12 @@ void ClangdTestHighlighting::test()
|
|||||||
void ClangdTestHighlighting::testIfdefedOutBlocks()
|
void ClangdTestHighlighting::testIfdefedOutBlocks()
|
||||||
{
|
{
|
||||||
QCOMPARE(m_ifdefedOutBlocks.size(), 3);
|
QCOMPARE(m_ifdefedOutBlocks.size(), 3);
|
||||||
QCOMPARE(m_ifdefedOutBlocks.at(0).first(), 12033);
|
QCOMPARE(m_ifdefedOutBlocks.at(0).first(), 12056);
|
||||||
QCOMPARE(m_ifdefedOutBlocks.at(0).last(), 12050);
|
QCOMPARE(m_ifdefedOutBlocks.at(0).last(), 12073);
|
||||||
QCOMPARE(m_ifdefedOutBlocks.at(1).first(), 13351);
|
QCOMPARE(m_ifdefedOutBlocks.at(1).first(), 13374);
|
||||||
QCOMPARE(m_ifdefedOutBlocks.at(1).last(), 13364);
|
QCOMPARE(m_ifdefedOutBlocks.at(1).last(), 13387);
|
||||||
QCOMPARE(m_ifdefedOutBlocks.at(2).first(), 13390);
|
QCOMPARE(m_ifdefedOutBlocks.at(2).first(), 13413);
|
||||||
QCOMPARE(m_ifdefedOutBlocks.at(2).last(), 13402);
|
QCOMPARE(m_ifdefedOutBlocks.at(2).last(), 13425);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ auto *rawVariable = R"(Vari
|
|||||||
auto Character = 'c';
|
auto Character = 'c';
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template<typename T> class vector {};
|
template<typename T> class vector { public: void clear(); };
|
||||||
template<typename T, typename U> class pair {};
|
template<typename T, typename U> class pair {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1008,3 +1008,19 @@ void foo(structWithOptional & s)
|
|||||||
{
|
{
|
||||||
s.opt_my_struct1->value = 5;
|
s.opt_my_struct1->value = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BaseWithMember
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
std::vector<unsigned char> vec;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T> class Derived : public BaseWithMember
|
||||||
|
{
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
auto lambda = [&] {};
|
||||||
|
lambda();
|
||||||
|
vec.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user