C++: use pointer in template specialization and initialization

Fix code completion for using pointer in template specialization and
initialization.
Example:
template <typename T>
struct S {};

template <typename T>
struct S<T*> { T* t; };

struct Foo { int foo; };

int main()
{
  S<Foo*> s;
  s.t-> //no code completion
  return 0;
}

Task-number: QTCREATORBUG-12638
Change-Id: Idcd461806a22f08b76236f2db6346f157b12f5d3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Przemyslaw Gorszkowski
2014-07-09 09:01:36 +02:00
parent 916d3dfa13
commit 0bc202d52f
2 changed files with 39 additions and 0 deletions

View File

@@ -1084,6 +1084,10 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
Subst subst(_control.data());
if (_factory->expandTemplates()) {
const TemplateNameId *templSpecId
= templateSpecialization->name()->asTemplateNameId();
const unsigned templSpecArgumentCount = templSpecId ?
templSpecId->templateArgumentCount() : 0;
Clone cloner(_control.data());
for (unsigned i = 0; i < argumentCountOfSpecialization; ++i) {
const TypenameArgument *tParam
@@ -1098,6 +1102,12 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
templId->templateArgumentAt(i):
cloner.type(tParam->type(), &subst);
if (i < templSpecArgumentCount
&& templSpecId->templateArgumentAt(i)->isPointerType()) {
if (PointerType *pointerType = ty->asPointerType())
ty = pointerType->elementType();
}
subst.bind(cloner.name(name, &subst), ty);
}