Improve the representation of template names in the AST. This
representation handles the various ways in which one can name a
template, including unqualified references ("vector"), qualified
references ("std::vector"), and dependent template names
("MetaFun::template apply").
One immediate effect of this change is that the representation of
nested-name-specifiers in type names for class template
specializations (e.g., std::vector<int>) is more accurate. Rather than
representing std::vector<int> as
std::(vector<int>)
we represent it as
(std::vector)<int>
which more closely follows the C++ grammar.
Additionally, templates are no longer represented as declarations
(DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new
OpaquePtr type (TemplateTy) that holds the representation of a
TemplateName. This will simplify the handling of dependent
template-names, once we get there.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68074 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 2578703..08f9601 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -114,7 +114,7 @@
case ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation: {
TemplateDecl *Template = cast<TemplateDecl>((Decl *)Active->Entity);
std::string TemplateArgsStr
- = ClassTemplateSpecializationType::PrintTemplateArgumentList(
+ = TemplateSpecializationType::PrintTemplateArgumentList(
Active->TemplateArgs,
Active->NumTemplateArgs);
Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
@@ -433,13 +433,12 @@
QualType
TemplateTypeInstantiator::
-InstantiateClassTemplateSpecializationType(
- const ClassTemplateSpecializationType *T,
+InstantiateTemplateSpecializationType(
+ const TemplateSpecializationType *T,
unsigned Quals) const {
llvm::SmallVector<TemplateArgument, 16> InstantiatedTemplateArgs;
InstantiatedTemplateArgs.reserve(T->getNumArgs());
- for (ClassTemplateSpecializationType::iterator Arg = T->begin(),
- ArgEnd = T->end();
+ for (TemplateSpecializationType::iterator Arg = T->begin(), ArgEnd = T->end();
Arg != ArgEnd; ++Arg) {
switch (Arg->getKind()) {
case TemplateArgument::Type: {
@@ -473,12 +472,13 @@
// FIXME: We're missing the locations of the template name, '<', and
// '>'.
- return SemaRef.CheckClassTemplateId(cast<ClassTemplateDecl>(T->getTemplate()),
- Loc,
- SourceLocation(),
- &InstantiatedTemplateArgs[0],
- InstantiatedTemplateArgs.size(),
- SourceLocation());
+ // FIXME: Need to instantiate into the template name.
+ return SemaRef.CheckTemplateIdType(T->getTemplateName(),
+ Loc,
+ SourceLocation(),
+ &InstantiatedTemplateArgs[0],
+ InstantiatedTemplateArgs.size(),
+ SourceLocation());
}
QualType