diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-10-18 10:25:52 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-10-18 14:07:00 +0200 |
commit | e58906a9ed718b0e65a0f805c165e7bacf54d936 (patch) | |
tree | 7b90dd84042d7452020cf8f7433b4c758f264f6e /src/libs/cplusplus/ResolveExpression.cpp | |
parent | c4c9b90b7f32b6b04026079ba5953bcf9730f562 (diff) | |
download | qt-creator-e58906a9ed718b0e65a0f805c165e7bacf54d936.tar.gz |
C++: Limit typedef resolving depth
This reverts commit 5be56c0 except for its tests. While it fixed the
problem described in the bug report, it also introduced regressions.
For now, we use a hard limit.
Change-Id: I19a85be454e3d7969371707e3eb1c3d42a16ecee
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/libs/cplusplus/ResolveExpression.cpp')
-rw-r--r-- | src/libs/cplusplus/ResolveExpression.cpp | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index fd144a4e61..fd29b1972b 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -886,23 +886,12 @@ public: { QSet<Symbol *> visited; _binding = binding; - while (NamedType *namedTy = getNamedType(*type)) { - const Name *name = namedTy->name(); - Scope *templateScope = *scope; - if (const QualifiedNameId *q = name->asQualifiedNameId()) { - do { - const TemplateNameId *templateNameId = 0; - name = q->name(); - if (name && (templateNameId = name->asTemplateNameId())) - resolve(templateNameId, templateScope, binding); - - name = q->base(); - if (name && (templateNameId = name->asTemplateNameId())) - resolve(templateNameId, templateScope, binding); - } while ((name && (q = name->asQualifiedNameId()))); - } else if (const TemplateNameId *templateNameId = name->asTemplateNameId()) { - resolve(templateNameId, templateScope, binding); - } + // Use a hard limit when trying to resolve typedefs. Typedefs in templates can refer to + // each other, each time enhancing the template argument and thus making it impossible to + // use an "alreadyResolved" container. FIXME: We might overcome this by resolving the + // template parameters. + unsigned maxDepth = 15; + for (NamedType *namedTy = 0; maxDepth && (namedTy = getNamedType(*type)); --maxDepth) { QList<LookupItem> namedTypeItems = getNamedTypeItems(namedTy->name(), *scope, _binding); #ifdef DEBUG_LOOKUP @@ -915,16 +904,6 @@ public: } private: - void resolve(const TemplateNameId *templateNameId, Scope *templateScope, - ClassOrNamespace *binding) - { - for (unsigned i = 0; i < templateNameId->templateArgumentCount(); ++i) { - FullySpecifiedType &templateArgumentType - = const_cast<FullySpecifiedType &>(templateNameId->templateArgumentAt(i)); - resolve(&templateArgumentType, &templateScope, binding); - } - } - NamedType *getNamedType(FullySpecifiedType& type) const { NamedType *namedTy = type->asNamedType(); |