Commit 5dbcb974 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Nikolai Kosjar

C++: added missing cloning of AnonymousNameId

When instantiate a template with anonymous class/struct/union
AnonymousNameId has to be cloned.

Task-number: QTCREATORBUG-9227

Change-Id: Iedca5e41589e68a94a35cd4387241052c70c50df
Reviewed-by: default avatarSergey Shambir <sergey.shambir.auto@gmail.com>
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent cd8cd4fd
......@@ -408,6 +408,11 @@ void CloneName::visit(const Identifier *name)
_name = _control->identifier(name->chars(), name->size());
}
void CloneName::visit(const AnonymousNameId *name)
{
_name = _control->anonymousNameId(name->classTokenIndex());
}
void CloneName::visit(const TemplateNameId *name)
{
std::vector<FullySpecifiedType> args(name->templateArgumentCount());
......
......@@ -109,6 +109,7 @@ public:
protected:
virtual void visit(const Identifier *name);
virtual void visit(const AnonymousNameId *name);
virtual void visit(const TemplateNameId *name);
virtual void visit(const DestructorNameId *name);
virtual void visit(const OperatorNameId *name);
......
......@@ -2015,3 +2015,35 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
<< code << completions;
}
void CppToolsPlugin::test_completion_instantiate_template_with_anonymous_class()
{
TestData data;
data.srcText =
"template <typename T>\n"
"struct S\n"
"{\n"
" union { int i; char c; };\n"
"};\n"
"void fun()\n"
"{\n"
" S<int> s;\n"
" @\n"
" // padding so we get the scope right\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("s.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
QStringList completions = getCompletions(data);
QCOMPARE(completions.size(), 1);
QVERIFY(completions.contains(QLatin1String("S")));
}
......@@ -126,6 +126,7 @@ private slots:
void test_completion_QTCREATORBUG9098();
void test_completion_type_and_using_declaration();
void test_completion_type_and_using_declaration_data();
void test_completion_instantiate_template_with_anonymous_class();
void test_format_pointerdeclaration_in_simpledeclarations();
void test_format_pointerdeclaration_in_simpledeclarations_data();
......
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