diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-08-06 05:28:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-08-06 05:28:30 +0000 |
commit | dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7 (patch) | |
tree | 2e20ff5efd25d6074c3c959b74165bc5f3af2f4f /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 355a692172022af7cd8935d025d096528a12340c (diff) |
Implement transformation of nested-name-specifiers within the general
tree transformation. Template instantiation uses this general
transformation rather than implementing its own transformation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 66 |
1 files changed, 3 insertions, 63 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index c281b96a9e..5f378993a2 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -324,10 +324,6 @@ namespace { /// this declaration. Decl *TransformDecl(Decl *D); - /// \brief Transform the given nested-name-specifier by instantiating it. - NestedNameSpecifier *TransformNestedNameSpecifier(NestedNameSpecifier *NNS, - SourceRange Range); - /// \brief Transform the given template name by instantiating it. TemplateName TransformTemplateName(TemplateName Template); @@ -345,12 +341,6 @@ Decl *TemplateInstantiator::TransformDecl(Decl *D) { return SemaRef.InstantiateCurrentDeclRef(cast_or_null<NamedDecl>(D)); } -NestedNameSpecifier * -TemplateInstantiator::TransformNestedNameSpecifier(NestedNameSpecifier *NNS, - SourceRange Range) { - return getSema().InstantiateNestedNameSpecifier(NNS, Range, TemplateArgs); -} - TemplateName TemplateInstantiator::TransformTemplateName(TemplateName Template) { return getSema().InstantiateTemplateName(Template, /*FIXME*/Loc, @@ -722,59 +712,9 @@ NestedNameSpecifier * Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS, SourceRange Range, const TemplateArgumentList &TemplateArgs) { - // Instantiate the prefix of this nested name specifier. - NestedNameSpecifier *Prefix = NNS->getPrefix(); - if (Prefix) { - Prefix = InstantiateNestedNameSpecifier(Prefix, Range, TemplateArgs); - if (!Prefix) - return 0; - } - - switch (NNS->getKind()) { - case NestedNameSpecifier::Identifier: { - assert(Prefix && - "Can't have an identifier nested-name-specifier with no prefix"); - CXXScopeSpec SS; - // FIXME: The source location information is all wrong. - SS.setRange(Range); - SS.setScopeRep(Prefix); - return static_cast<NestedNameSpecifier *>( - ActOnCXXNestedNameSpecifier(0, SS, - Range.getEnd(), - Range.getEnd(), - *NNS->getAsIdentifier())); - break; - } - - case NestedNameSpecifier::Namespace: - case NestedNameSpecifier::Global: - return NNS; - - case NestedNameSpecifier::TypeSpecWithTemplate: - case NestedNameSpecifier::TypeSpec: { - QualType T = QualType(NNS->getAsType(), 0); - if (!T->isDependentType()) - return NNS; - - T = InstantiateType(T, TemplateArgs, Range.getBegin(), DeclarationName()); - if (T.isNull()) - return 0; - - if (T->isDependentType() || T->isRecordType() || - (getLangOptions().CPlusPlus0x && T->isEnumeralType())) { - assert(T.getCVRQualifiers() == 0 && "Can't get cv-qualifiers here"); - return NestedNameSpecifier::Create(Context, Prefix, - NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate, - T.getTypePtr()); - } - - Diag(Range.getBegin(), diag::err_nested_name_spec_non_tag) << T; - return 0; - } - } - - // Required to silence a GCC warning - return 0; + TemplateInstantiator Instantiator(*this, TemplateArgs, Range.getBegin(), + DeclarationName()); + return Instantiator.TransformNestedNameSpecifier(NNS, Range); } TemplateName |