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
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index c281b96..5f37899 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -324,10 +324,6 @@
/// 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 @@
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 @@
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