forked from qt-creator/qt-creator
Fix crashes when cyclic inheritance
More complex situation. Base class is a template and derived class is a template. Task-number: QTCREATORBUG-8072 Task-number: QTCREATORBUG-7962 Change-Id: I7e8aa727fccd2bd4a779e6fe781553cd12196682 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
40a6f0b1ca
commit
e53f435219
@@ -58,7 +58,15 @@ public:
|
||||
}
|
||||
bool contains(const T *item)
|
||||
{
|
||||
return _container.contains(item);
|
||||
if (_container.contains(item))
|
||||
return true;
|
||||
|
||||
foreach (const T *existingItem, _container) {
|
||||
if (existingItem->isEqualTo(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void clear(const T *item)
|
||||
|
@@ -930,4 +930,43 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
|
||||
QTest::newRow("case: indirect cyclic inheritance with templates")
|
||||
<< code << completions;
|
||||
|
||||
completions.clear();
|
||||
code = "\n"
|
||||
"namespace NS\n"
|
||||
"{\n"
|
||||
"template <typename T> struct SuperClass\n"
|
||||
"{\n"
|
||||
" typedef T Type;\n"
|
||||
" Type super_class_type;\n"
|
||||
"};\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"template <typename T>\n"
|
||||
"struct Class;\n"
|
||||
"\n"
|
||||
"template <typename T, typename S>\n"
|
||||
"struct ClassRecurse : Class<S>\n"
|
||||
"{\n"
|
||||
" T class_recurse_t;\n"
|
||||
" S class_recurse_s;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"template <typename T>\n"
|
||||
"struct Class : ClassRecurse< T, typename ::NS::SuperClass<T>::Type >\n"
|
||||
"{\n"
|
||||
" T class_t;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Class<int> c;\n"
|
||||
"c.\n"
|
||||
"@\n"
|
||||
;
|
||||
completions.append("Class");
|
||||
completions.append("ClassRecurse");
|
||||
completions.append("class_t");
|
||||
completions.append("class_recurse_s");
|
||||
completions.append("class_recurse_t");
|
||||
QTest::newRow("case: direct cyclic inheritance with templates, more complex situation")
|
||||
<< code << completions;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user