forked from qt-creator/qt-creator
C++: fix crash during code completion with base template class
ResolveExpression has to have a reference of ContextLookup. If not there will be a crash because of deleted instanitated base template class. Task-number: QTCREATORBUG-9329 Change-Id: I7f8c83da0d81ac6311e76d15a897adbc70b08d75 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
2e9f6a7935
commit
80e1ae8059
@@ -1798,3 +1798,37 @@ void CppToolsPlugin::test_completion_namespace_alias_with_many_namespace_declara
|
||||
QVERIFY(completions.contains(QLatin1String("Foo1")));
|
||||
QVERIFY(completions.contains(QLatin1String("Foo2")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_crash_cloning_template_class_QTCREATORBUG9329()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText =
|
||||
"struct A {};\n"
|
||||
"template <typename T>\n"
|
||||
"struct Templ {};\n"
|
||||
"struct B : A, Templ<A>\n"
|
||||
"{\n"
|
||||
" int f()\n"
|
||||
" {\n"
|
||||
" @\n"
|
||||
" // padding so we get the scope right\n"
|
||||
" }\n"
|
||||
"};\n"
|
||||
;
|
||||
setup(&data);
|
||||
|
||||
Utils::ChangeSet change;
|
||||
QString txt = QLatin1String("this->");
|
||||
change.insert(data.pos, txt);
|
||||
QTextCursor cursor(data.doc);
|
||||
change.apply(&cursor);
|
||||
data.pos += txt.length();
|
||||
|
||||
QStringList completions = getCompletions(data);
|
||||
|
||||
QCOMPARE(completions.size(), 4);
|
||||
QVERIFY(completions.contains(QLatin1String("A")));
|
||||
QVERIFY(completions.contains(QLatin1String("B")));
|
||||
QVERIFY(completions.contains(QLatin1String("Templ")));
|
||||
QVERIFY(completions.contains(QLatin1String("f")));
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ private slots:
|
||||
void test_completion_typedef_using_templates1();
|
||||
void test_completion_typedef_using_templates2();
|
||||
void test_completion_namespace_alias_with_many_namespace_declarations();
|
||||
void test_completion_crash_cloning_template_class_QTCREATORBUG9329();
|
||||
|
||||
void test_format_pointerdeclaration_in_simpledeclarations();
|
||||
void test_format_pointerdeclaration_in_simpledeclarations_data();
|
||||
|
||||
Reference in New Issue
Block a user