forked from qt-creator/qt-creator
CppEditor: Do not treat friend declaration as member function
... when trying to create definitions from declarations. Instead, we completely ignore friends in this context, arguing that the respective function normally should have a proper declaration somewhere else. Fixes: QTCREATORBUG-7164 Change-Id: I3ddb89cefecbc494f9c7e63600b65fd6288b7169 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -135,6 +135,7 @@ private slots:
|
||||
void test_quickfix_InsertDefFromDecl_unicodeIdentifier();
|
||||
void test_quickfix_InsertDefFromDecl_templateClass();
|
||||
void test_quickfix_InsertDefFromDecl_templateFunction();
|
||||
void test_quickfix_InsertDefFromDecl_notTriggeredForFriendFunc();
|
||||
|
||||
void test_quickfix_InsertDeclFromDef();
|
||||
void test_quickfix_InsertDeclFromDef_templateFuncTypename();
|
||||
|
@@ -2909,6 +2909,19 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateFunction()
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeredForFriendFunc()
|
||||
{
|
||||
const QByteArray contents =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" friend void f@unc();\n"
|
||||
"};\n"
|
||||
"\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
QuickFixOperationTest(singleDocument(contents, ""), &factory);
|
||||
}
|
||||
|
||||
// Function for one of InsertDeclDef section cases
|
||||
void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
||||
{
|
||||
|
@@ -2847,7 +2847,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
if (Symbol *symbol = simpleDecl->symbols->value) {
|
||||
if (Declaration *decl = symbol->asDeclaration()) {
|
||||
if (Function *func = decl->type()->asFunctionType()) {
|
||||
if (func->isSignal() || func->isPureVirtual())
|
||||
if (func->isSignal() || func->isPureVirtual() || func->isFriend())
|
||||
return;
|
||||
|
||||
// Check if there is already a definition
|
||||
|
Reference in New Issue
Block a user