Skip to content

Commit

Permalink
CppEditor: Consider operators
Browse files Browse the repository at this point in the history
... when looking for reimplemented member functions in the "Insert
virtual functions of base class" quickfix.

Fixes: QTCREATORBUG-12218
Change-Id: I6e37e28ab747a76dcc97df242bd6c6199fbc7e2e
Reviewed-by: Christian Stenger <[email protected]>
  • Loading branch information
ckandeler committed Jul 29, 2020
1 parent c467ae6 commit 4e9951a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/plugins/cppeditor/cppinsertvirtualmethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,12 @@ class InsertVirtualMethodsOp : public CppQuickFixOperation
// Do not implement existing functions inside target class
bool funcExistsInClass = false;
const Name *funcName = func->name();
for (Symbol *symbol = m_classAST->symbol->find(funcName->identifier());
symbol; symbol = symbol->next()) {
if (!symbol->name()
|| !funcName->identifier()->match(symbol->identifier())) {
const OperatorNameId * const opName = funcName->asOperatorNameId();
Symbol *symbol = opName ? m_classAST->symbol->find(opName->kind())
: m_classAST->symbol->find(funcName->identifier());
for (; symbol; symbol = symbol->next()) {
if (!opName && (!symbol->name()
|| !funcName->identifier()->match(symbol->identifier()))) {
continue;
}
if (symbol->type().match(func->type())) {
Expand Down Expand Up @@ -1541,10 +1543,12 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
"class BaseA {\n"
"public:\n"
" virtual int virtualFuncA();\n"
" virtual operator==(const BaseA &);\n"
"};\n\n"
"class Derived : public Bas@eA {\n"
"public:\n"
" virtual int virtualFuncA() = 0;\n"
" virtual operator==(const BaseA &);\n"
"};\n"
) << _();

Expand Down

0 comments on commit 4e9951a

Please sign in to comment.