forked from qt-creator/qt-creator
ClangCodeModel: Fix another false positive
... in output argument highlighting. If there is not enough information for clang to determine the const-ness of the argument passing (as it can happen in templates), do not report an output argument. Change-Id: I8d0143042f02ac44d8d971398014828cff14697f 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:
@@ -2712,8 +2712,12 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
||||
if (it->kind() == "Call") {
|
||||
// The first child is e.g. a called lambda or an object on which
|
||||
// the call happens, and should not be highlighted as an output argument.
|
||||
// If the call is not fully resolved (as in templates), we don't
|
||||
// know whether the argument is passed as const or not.
|
||||
const QList<AstNode> children = it->children().value_or(QList<AstNode>());
|
||||
return children.isEmpty() || children.first().range() != (it - 1)->range();
|
||||
return children.isEmpty()
|
||||
|| (children.first().range() != (it - 1)->range()
|
||||
&& children.first().kind() != "UnresolvedLookup");
|
||||
}
|
||||
|
||||
// The token should get marked for e.g. lambdas, but not for assignment operators,
|
||||
|
@@ -1327,6 +1327,8 @@ void ClangdTestHighlighting::test_data()
|
||||
<< QList<int>{C_LOCAL} << 0;
|
||||
QTest::newRow("call on inherited member") << 1024 << 9 << 1024 << 12
|
||||
<< QList<int>{C_FIELD} << 0;
|
||||
QTest::newRow("pass inherited member by value") << 1038 << 21 << 1038 << 26
|
||||
<< QList<int>{C_FIELD} << 0;
|
||||
}
|
||||
|
||||
void ClangdTestHighlighting::test()
|
||||
|
@@ -1024,3 +1024,19 @@ template<typename T> class Derived : public BaseWithMember
|
||||
vec.clear();
|
||||
}
|
||||
};
|
||||
|
||||
static bool testVal(int val);
|
||||
class BaseWithMember2
|
||||
{
|
||||
protected:
|
||||
int value;
|
||||
};
|
||||
template<typename T> class Derived2 : public BaseWithMember2
|
||||
{
|
||||
bool foo()
|
||||
{
|
||||
if (testVal(value))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user