forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
70bc5e842c
commit
a77e32800c
14
src/libs/3rdparty/cplusplus/Templates.cpp
vendored
14
src/libs/3rdparty/cplusplus/Templates.cpp
vendored
@@ -125,6 +125,12 @@ void CloneType::visit(Template *type)
|
||||
_type = templ;
|
||||
}
|
||||
|
||||
void CloneType::visit(ExplicitInstantiation *type)
|
||||
{
|
||||
ExplicitInstantiation *inst = _clone->symbol(type, _subst)->asExplicitInstantiation();
|
||||
_type = inst;
|
||||
}
|
||||
|
||||
void CloneType::visit(Class *type)
|
||||
{
|
||||
Class *klass = _clone->symbol(type, _subst)->asClass();
|
||||
@@ -291,6 +297,14 @@ bool CloneSymbol::visit(Template *symbol)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CloneSymbol::visit(ExplicitInstantiation *symbol)
|
||||
{
|
||||
ExplicitInstantiation *inst = new ExplicitInstantiation(_clone, _subst, symbol);
|
||||
_symbol = inst;
|
||||
_control->addSymbol(inst);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CloneSymbol::visit(Class *symbol)
|
||||
{
|
||||
Class *klass = new Class(_clone, _subst, symbol);
|
||||
|
||||
Reference in New Issue
Block a user