From 97d93ed32d7c8314b6864b5e91cbb68b43109c6b Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Wed, 11 Aug 2010 15:34:02 +0200 Subject: [PATCH] Enabled the template instantiation. --- src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp | 9 +++------ src/shared/cplusplus/Symbol.cpp | 9 +++++++++ src/shared/cplusplus/Symbol.h | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp index 762e197e331..b82e16cf6e5 100644 --- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp +++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp @@ -399,18 +399,16 @@ FullySpecifiedType DeprecatedGenTemplateInstance::gen(Symbol *symbol) FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *className, Symbol *candidate, QSharedPointer<Control> control) { -#warning robe: enable template instantiation -#if 0 if (className) { if (const TemplateNameId *templId = className->asTemplateNameId()) { - if (Class *klass = candidate->scope()->asClass()) { + if (Template *templ = candidate->enclosingTemplate()) { DeprecatedGenTemplateInstance::Substitution subst; for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) { FullySpecifiedType templArgTy = templId->templateArgumentAt(i); - if (i < klass->templateParameterCount()) { - const Name *templArgName = klass->templateParameterAt(i)->name(); + if (i < templ->templateParameterCount()) { + const Name *templArgName = templ->templateParameterAt(i)->name(); if (templArgName && templArgName->identifier()) { const Identifier *templArgId = templArgName->identifier(); @@ -424,6 +422,5 @@ FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *classN } } } -#endif return candidate->type(); } diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp index cfb61bfae44..f41c02d3a9e 100644 --- a/src/shared/cplusplus/Symbol.cpp +++ b/src/shared/cplusplus/Symbol.cpp @@ -251,6 +251,15 @@ Namespace *Symbol::enclosingNamespace() const return 0; } +Template *Symbol::enclosingTemplate() const +{ + for (Scope *s = _scope; s; s = s->scope()) { + if (Template *templ = s->asTemplate()) + return templ; + } + return 0; +} + Class *Symbol::enclosingClass() const { for (Scope *s = _scope; s; s = s->scope()) { diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h index 7b80e5093cf..3ca9f13f8fd 100644 --- a/src/shared/cplusplus/Symbol.h +++ b/src/shared/cplusplus/Symbol.h @@ -292,6 +292,9 @@ public: /// Returns the eclosing namespace scope. Namespace *enclosingNamespace() const; + /// Returns the eclosing template scope. + Template *enclosingTemplate() const; + /// Returns the enclosing class scope. Class *enclosingClass() const; -- GitLab