CPlusPlus: Improve type name minimization

... for function parameters. These are located in the scope of the
surrounding class or namespace.
This uncovered a bug in the "Insert Virtual Functions of Base Classes"
quickfix, which we also fix here.

Fixes: QTCREATORBUG-8030
Change-Id: I7f11659dc8e252e3819df8178734e8958fa1b496
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-02-02 14:01:15 +01:00
parent f47c7b2e90
commit b066b3029e
4 changed files with 103 additions and 9 deletions

View File

@@ -142,6 +142,17 @@ public:
funTy->setReturnType(rewrite->rewriteType(type->returnType()));
// Function parameters have the function's enclosing scope.
Scope *scope = nullptr;
ClassOrNamespace *target = nullptr;
if (rewrite->env->context().bindings())
target = rewrite->env->context().lookupType(type->enclosingScope());
UseMinimalNames useMinimalNames(target);
if (target) {
scope = rewrite->env->switchScope(type->enclosingScope());
rewrite->env->enter(&useMinimalNames);
}
for (unsigned i = 0, argc = type->argumentCount(); i < argc; ++i) {
Symbol *arg = type->argumentAt(i);
@@ -156,6 +167,11 @@ public:
funTy->addMember(newArg);
}
if (target) {
rewrite->env->switchScope(scope);
rewrite->env->leave();
}
temps.append(funTy);
}