C++: Ignore explicit template instantiations

Defined in section 14.7.2 of the standard.

Fixes completion for std::string.

The following explicit instantiation appears in bits/basic_string.tcc:
  extern template class basic_string<char>;

This is wrongfully considered a specialization for a forward declaration
(like `template<> class basic_string<char>` is).

Introduce a new Symbol type for explicit instantiations.

Use-case:
template<class T>
struct Foo { T bar; };

template class Foo<int>;

void func()
{
    Foo<int> foo;
    foo.bar; // bar not highlighted
}

Change-Id: I9e35c8c32f6b78fc87b4f4f1fc903b42cfbd2c2b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-06-20 22:37:53 +03:00
committed by Orgad Shaneh
parent 70bc5e842c
commit a77e32800c
21 changed files with 208 additions and 14 deletions

View File

@@ -796,6 +796,21 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("Data")
<< QLatin1String("dataMember"));
QTest::newRow("explicit_instantiation") << _(
"template<class T>\n"
"struct Foo { T bar; };\n"
"\n"
"template class Foo<int>;\n"
"\n"
"void func()\n"
"{\n"
" Foo<int> foo;\n"
" @\n"
"}\n"
) << _("foo.") << (QStringList()
<< QLatin1String("Foo")
<< QLatin1String("bar"));
QTest::newRow("use_global_identifier_as_base_class: derived as global and base as global") << _(
"struct Global\n"
"{\n"