aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-04-27 00:57:59 +0000
committerJohn McCall <rjmccall@apple.com>2010-04-27 00:57:59 +0000
commit31f17ecbef57b5679c017c375db330546b7b5145 (patch)
tree284e3662375c4f1d59e72b2390c99e2b0e682eb1 /lib/Sema/SemaTemplateDeduction.cpp
parent184d7900e0202ac468710b731e42075129bb6000 (diff)
Make the InjectedClassNameType the canonical type of the current instantiation
of a class template or class template partial specialization. That is to say, in template <class T> class A { ... }; or template <class T> class B<const T*> { ... }; make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType when written inside the appropriate context. This allows us to track the current instantiation appropriately even inside AST routines. It also allows us to compute a DeclContext for a type much more efficiently, at some extra cost every time we write a template specialization (which can be optimized, but I've left it simple in this patch). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index d61a767dc5..7154d62d6c 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -638,7 +638,8 @@ DeduceTemplateArguments(Sema &S,
case Type::InjectedClassName: {
// Treat a template's injected-class-name as if the template
// specialization type had been used.
- Param = cast<InjectedClassNameType>(Param)->getUnderlyingType();
+ Param = cast<InjectedClassNameType>(Param)
+ ->getInjectedSpecializationType();
assert(isa<TemplateSpecializationType>(Param) &&
"injected class name is not a template specialization type");
// fall through
@@ -2340,13 +2341,16 @@ Sema::getMoreSpecializedPartialSpecialization(
// are more constrained. We know that every template parameter is deduc
llvm::SmallVector<DeducedTemplateArgument, 4> Deduced;
Sema::TemplateDeductionInfo Info(Context, Loc);
+
+ QualType PT1 = PS1->getInjectedSpecializationType();
+ QualType PT2 = PS2->getInjectedSpecializationType();
// Determine whether PS1 is at least as specialized as PS2
Deduced.resize(PS2->getTemplateParameters()->size());
bool Better1 = !DeduceTemplateArgumentsDuringPartialOrdering(*this,
PS2->getTemplateParameters(),
- Context.getTypeDeclType(PS2),
- Context.getTypeDeclType(PS1),
+ PT2,
+ PT1,
Info,
Deduced,
0);
@@ -2356,8 +2360,8 @@ Sema::getMoreSpecializedPartialSpecialization(
Deduced.resize(PS1->getTemplateParameters()->size());
bool Better2 = !DeduceTemplateArgumentsDuringPartialOrdering(*this,
PS1->getTemplateParameters(),
- Context.getTypeDeclType(PS1),
- Context.getTypeDeclType(PS2),
+ PT1,
+ PT2,
Info,
Deduced,
0);
@@ -2537,6 +2541,10 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T,
break;
}
+ case Type::InjectedClassName:
+ T = cast<InjectedClassNameType>(T)->getInjectedSpecializationType();
+ // fall through
+
case Type::TemplateSpecialization: {
const TemplateSpecializationType *Spec
= cast<TemplateSpecializationType>(T);