forked from qt-creator/qt-creator
ClangCodeModel: Fix another output argument mis-detection
We need to relax the range check: In expressions such as x.y->z, the second argument for the operator->call is x.y, not just y. Fixes: QTCREATORBUG-27352 Change-Id: Ida542c11c129630f0a1d301508ec5f8076eb9902 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -2735,7 +2735,7 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
|||||||
// The callable is never displayed as an output parameter.
|
// The callable is never displayed as an output parameter.
|
||||||
// TODO: A good argument can be made to display objects on which a non-const
|
// TODO: A good argument can be made to display objects on which a non-const
|
||||||
// operator or function is called as output parameters.
|
// operator or function is called as output parameters.
|
||||||
if (children.at(1).range() == range)
|
if (children.at(1).range().contains(range))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QList<AstNode> firstChildTree{children.first()};
|
QList<AstNode> firstChildTree{children.first()};
|
||||||
|
|||||||
@@ -1321,6 +1321,8 @@ void ClangdTestHighlighting::test_data()
|
|||||||
<< QList<int>{C_FIELD} << 0;
|
<< QList<int>{C_FIELD} << 0;
|
||||||
QTest::newRow("member call on dependent (3)") << 999 << 9 << 999 << 12
|
QTest::newRow("member call on dependent (3)") << 999 << 9 << 999 << 12
|
||||||
<< QList<int>{C_LOCAL} << 0;
|
<< QList<int>{C_LOCAL} << 0;
|
||||||
|
QTest::newRow("member access via operator->") << 1009 << 7 << 1009 << 21
|
||||||
|
<< QList<int>{C_FIELD} << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangdTestHighlighting::test()
|
void ClangdTestHighlighting::test()
|
||||||
|
|||||||
@@ -999,3 +999,12 @@ public:
|
|||||||
ptr->bar();
|
ptr->bar();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace std { template<typename T> struct optional { T* operator->(); }; }
|
||||||
|
struct structWithData { int value; };
|
||||||
|
struct structWithOptional { std::optional<structWithData> opt_my_struct1; };
|
||||||
|
|
||||||
|
void foo(structWithOptional & s)
|
||||||
|
{
|
||||||
|
s.opt_my_struct1->value = 5;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user