forked from qt-creator/qt-creator
C++: Handle recursive using/typedef declarations
Remember using/typedef declarations we have already looked up and
stop if we try it again.
Change-Id: I91bf0aef4df18539a47d015f0113543aef1f692a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
(cherry picked from commit 50a900e509)
This commit is contained in:
@@ -275,7 +275,8 @@ ClassOrNamespace *LookupContext::globalNamespace() const
|
||||
}
|
||||
|
||||
ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
|
||||
ClassOrNamespace* enclosingTemplateInstantiation) const
|
||||
ClassOrNamespace* enclosingTemplateInstantiation,
|
||||
QSet<const Declaration *> typedefsBeingResolved) const
|
||||
{
|
||||
if (! scope) {
|
||||
return 0;
|
||||
@@ -294,8 +295,14 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
|
||||
Overview oo;
|
||||
qDebug() << "Looks like" << oo(name) << "is a typedef for" << oo(d->type());
|
||||
#endif // DEBUG_LOOKUP
|
||||
if (const NamedType *namedTy = d->type()->asNamedType())
|
||||
return lookupType(namedTy->name(), scope);
|
||||
if (const NamedType *namedTy = d->type()->asNamedType()) {
|
||||
// Stop on recursive typedef declarations
|
||||
if (typedefsBeingResolved.contains(d))
|
||||
return 0;
|
||||
return lookupType(namedTy->name(), scope, 0,
|
||||
QSet<const Declaration *>(typedefsBeingResolved)
|
||||
<< d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user