Commit a01f6cad authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Eike Ziller

CppEditor: Return on invalid code in ExtractLiteralAsParameter::match

No declarator was provided but we assumed one.

Task-number: QTCREATORBUG-12853
Change-Id: I5faf96b63f39aff43c0165f7277345737e53f191
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent be3dbd26
......@@ -201,13 +201,14 @@ private slots:
void test_quickfix_ExtractLiteralAsParameter_typeDeduction();
void test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles();
void test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles();
void test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode();
void test_quickfix_InsertVirtualMethods_data();
void test_quickfix_InsertVirtualMethods();
void test_quickfix_InsertVirtualMethods_implementationFile();
void test_quickfix_InsertVirtualMethods_BaseClassInNamespace();
// tests for "Include Hiererchy"
// tests for "Include Hierarchy"
void test_includehierarchy_data();
void test_includehierarchy();
......
......@@ -3614,3 +3614,21 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_sep
ExtractLiteralAsParameter factory;
QuickFixTestCase(testFiles, &factory);
}
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode()
{
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
original =
"T(\"test\")\n"
"{\n"
" const int i = @14;\n"
"}\n";
expected = original;
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
ExtractLiteralAsParameter factory;
QuickFixTestCase(testFiles, &factory);
}
......@@ -3884,13 +3884,15 @@ void ExtractLiteralAsParameter::match(const CppQuickFixInterface &interface,
return;
}
FunctionDeclaratorAST *functionDeclarator
= function->declarator->postfix_declarator_list->value->asFunctionDeclarator();
if (functionDeclarator
&& functionDeclarator->parameter_declaration_clause
&& functionDeclarator->parameter_declaration_clause->dot_dot_dot_token) {
// Do not handle functions with ellipsis parameter.
PostfixDeclaratorListAST * const declaratorList = function->declarator->postfix_declarator_list;
if (!declaratorList)
return;
if (FunctionDeclaratorAST *declarator = declaratorList->value->asFunctionDeclarator()) {
if (declarator->parameter_declaration_clause
&& declarator->parameter_declaration_clause->dot_dot_dot_token) {
// Do not handle functions with ellipsis parameter.
return;
}
}
const int priority = path.size() - 1;
......
Markdown is supported
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