CPlusPlus: Check for static member functions in FindUsages

Static member functions cannot modify the object and therefore must not
be reported as writable references.
Note that this does not have an effect yet, as the function type lacks
information about the "static" specifier.

Task-number: QTCREATORBUG-24894
Change-Id: Ib04a17864a0ca5b7610579a2f5efbcfde257e08a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-11-06 14:07:14 +01:00
parent fdaed3aa09
commit 1988d89198
2 changed files with 17 additions and 5 deletions

View File

@@ -285,8 +285,13 @@ Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
if (items.isEmpty())
return Usage::Type::Other;
for (const LookupItem &item : qAsConst(items)) {
if (item.type()->isFunctionType())
return item.type().isConst() ? Usage::Type::Read : Usage::Type::WritableRef;
if (item.type()->isFunctionType()) {
if (item.type().isConst())
return Usage::Type::Read;
if (item.type().isStatic())
return Usage::Type::Other;
return Usage::Type::WritableRef;
}
}
}
return Usage::Type::Other;