forked from qt-creator/qt-creator
ClangCodeModel: Fix mis-detection of class members as operators
The name check was not tight enough. Change-Id: I5d813a29525bd5b5c23ce04f0bd9e5982a36536e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -3839,10 +3839,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());
|
||||
|
||||
Reference in New Issue
Block a user