C++: Fix lookup for instantiation of using

Yet another std::vector issue...

Use-cases:
// Case 1
template<typename T>
using type = T;

// Case 2
struct Parent {
    template<typename T>
    using type = T;
};

// Case 3
template<typename T>
struct ParentT {
    template<typename DT>
    using type = DT;
};

struct Foo { int bar; };

void func()
{
    type<Foo> p1;
    Parent::type<Foo> p2;
    ParentT<Foo>::type<Foo> p3;
    // bar not highlighted
    p1.bar;
    p2.bar;
    p3.bar;
}

Task-number: QTCREATORBUG-14480
Change-Id: I9ab08ea7360a432c48eb4b85aa0d63e08d2464c1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-05-22 13:03:55 +03:00
committed by Orgad Shaneh
parent 2a966a8917
commit b67ebf9ffc
2 changed files with 86 additions and 1 deletions

View File

@@ -210,6 +210,10 @@ bool TypeResolver::findTypedef(const QList<LookupItem> &namedTypeItems, FullySpe
{
foreach (const LookupItem &it, namedTypeItems) {
Symbol *declaration = it.declaration();
if (!declaration)
continue;
if (Template *specialization = declaration->asTemplate())
declaration = specialization->declaration();
if (!declaration || (!declaration->isTypedef() && !declaration->type().isDecltype()))
continue;
if (visited.contains(declaration))
@@ -237,7 +241,7 @@ bool TypeResolver::findTypedef(const QList<LookupItem> &namedTypeItems, FullySpe
return true;
}
} else {
*type = declaration->type();
*type = it.type();
}
*scope = it.scope();