Commit 4f0ae3b5 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Nikolai Kosjar
Browse files

CppEditor: Optimize non-overriding virtual functions lookup

Instead of building the hierarchy from the most basic class that
implements the virtual function, start from the looked up class.

Change-Id: Ia674fbb4a92dd45d4ca7bc621c54b411264cbe3d
Reviewed-by: default avatarNikolai Kosjar <>
parent 85e6f8a1
......@@ -255,35 +255,6 @@ bool FunctionHelper::isPureVirtualFunction(const Function *function, const Snaps
return isVirtualFunction_helper(function, snapshot, PureVirtual);
static bool isDerivedOf(Class *derivedClassCandidate, Class *baseClass,
const Snapshot &snapshot)
QTC_ASSERT(derivedClassCandidate && baseClass, return false);
QList<CppClass> l = QList<CppClass>() << CppClass(derivedClassCandidate);
while (!l.isEmpty()) {
CppClass clazz = l.takeFirst();
QTC_ASSERT(clazz.declaration, continue);
const QString fileName = QString::fromUtf8(clazz.declaration->fileName());
const Document::Ptr document = snapshot.document(fileName);
if (!document)
const LookupContext context(document, snapshot);
clazz.lookupBases(clazz.declaration, context);
foreach (const CppClass &base, clazz.bases) {
if (base.declaration == baseClass)
return true;
if (!l.contains(base))
l << base;
return false;
QList<Symbol *> FunctionHelper::overrides(Function *function, Class *functionsClass,
Class *staticClass, const Snapshot &snapshot)
......@@ -296,7 +267,7 @@ QList<Symbol *> FunctionHelper::overrides(Function *function, Class *functionsCl
// Find overrides
CppEditor::Internal::CppClass cppClass = CppClass(functionsClass);
cppClass.lookupDerived(functionsClass, snapshot);
cppClass.lookupDerived(staticClass, snapshot);
QList<CppClass> l;
l << cppClass;
......@@ -309,11 +280,6 @@ QList<Symbol *> FunctionHelper::overrides(Function *function, Class *functionsCl
Class *c = clazz.declaration->asClass();
QTC_ASSERT(c, continue);
if (c != functionsClass && c != staticClass) {
if (!isDerivedOf(c, staticClass, snapshot))
foreach (const CppClass &d, clazz.derived) {
if (!l.contains(d))
l << d;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment