diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2012-10-18 15:06:13 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2012-10-19 14:42:32 +0200 |
commit | 2b95d81cd826c0f7f6c681f425da3b53c76aa140 (patch) | |
tree | 75176828a331893ed3a1090fff1dc86e762f0d83 /src/libs/cplusplus/ResolveExpression.cpp | |
parent | fa655dd40784346db8fb3fd47d54e59c7e7e5763 (diff) | |
download | qt-creator-2b95d81cd826c0f7f6c681f425da3b53c76aa140.tar.gz |
C++: Fix typedef resolving when templates are involved.
Task-number: QTCREATORBUG-7978
Change-Id: I27e6ebe56e410d509580a1e00f8986642cacc5ba
Reviewed-by: David Schulz <david.schulz@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/libs/cplusplus/ResolveExpression.cpp')
-rw-r--r-- | src/libs/cplusplus/ResolveExpression.cpp | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 3ffed52d5c..dfa634d799 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -830,16 +830,22 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina static void resolveTypedefs(const LookupContext &context, FullySpecifiedType *type, - Scope **scope) + Scope **scope, ClassOrNamespace *binding) { QSet<Symbol *> visited; while (NamedType *namedTy = (*type)->asNamedType()) { - ClassOrNamespace *scopeCoN = context.lookupType(*scope); - if (!scopeCoN) - break; // check if namedTy->name() resolves to a typedef - QList<LookupItem> namedTypeItems = scopeCoN->lookup(namedTy->name()); + QList<LookupItem> namedTypeItems; + if (binding) + namedTypeItems = binding->lookup(namedTy->name()); + if (ClassOrNamespace *scopeCon = context.lookupType(*scope)) + namedTypeItems += scopeCon->lookup(namedTy->name()); + +#ifdef DEBUG_LOOKUP + qDebug() << "-- we have" << namedTypeItems.size() << "candidates"; +#endif // DEBUG_LOOKUP + bool foundTypedef = false; foreach (const LookupItem &it, namedTypeItems) { if (it.declaration() && it.declaration()->isTypedef()) { @@ -864,11 +870,26 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas int accessOp, bool *replacedDotOperator) const { +#ifdef DEBUG_LOOKUP + qDebug() << "In ResolveExpression::baseExpression with" << baseResults.size() << "results..."; + int i = 0; + Overview oo; +#endif // DEBUG_LOOKUP + foreach (const LookupItem &r, baseResults) { FullySpecifiedType ty = r.type().simplified(); Scope *scope = r.scope(); - resolveTypedefs(_context, &ty, &scope); +#ifdef DEBUG_LOOKUP + qDebug("trying result #%d", ++i); + qDebug()<<"- before typedef resolving we have:"<<oo(ty); +#endif // DEBUG_LOOKUP + + resolveTypedefs(_context, &ty, &scope, r.binding()); + +#ifdef DEBUG_LOOKUP + qDebug()<<"- after typedef resolving:"<<oo(ty); +#endif // DEBUG_LOOKUP if (accessOp == T_ARROW) { if (PointerType *ptrTy = ty->asPointerType()) { @@ -892,7 +913,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas FullySpecifiedType retTy = instantiatedFunction->returnType().simplified(); - resolveTypedefs(_context, &retTy, &functionScope); + resolveTypedefs(_context, &retTy, &functionScope, r.binding()); if (PointerType *ptrTy = retTy->asPointerType()) { if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), functionScope)) |