summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index d3d771b..562749e 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -503,6 +503,10 @@ InstantiateTemplateSpecializationType(
for (TemplateSpecializationType::iterator Arg = T->begin(), ArgEnd = T->end();
Arg != ArgEnd; ++Arg) {
switch (Arg->getKind()) {
+ case TemplateArgument::Null:
+ assert(false && "Should never have a NULL template argument");
+ break;
+
case TemplateArgument::Type: {
QualType T = SemaRef.InstantiateType(Arg->getAsType(),
TemplateArgs,
@@ -829,21 +833,23 @@ Sema::InstantiateClassTemplateSpecialization(
// Determine whether any class template partial specializations
// match the given template arguments.
- llvm::SmallVector<ClassTemplatePartialSpecializationDecl *, 4> Matched;
+ typedef std::pair<ClassTemplatePartialSpecializationDecl *,
+ TemplateArgumentList *> MatchResult;
+ llvm::SmallVector<MatchResult, 4> Matched;
for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator
Partial = Template->getPartialSpecializations().begin(),
PartialEnd = Template->getPartialSpecializations().end();
Partial != PartialEnd;
++Partial) {
- if (DeduceTemplateArguments(&*Partial, ClassTemplateSpec->getTemplateArgs()))
- Matched.push_back(&*Partial);
+ if (TemplateArgumentList *Deduced
+ = DeduceTemplateArguments(&*Partial,
+ ClassTemplateSpec->getTemplateArgs()))
+ Matched.push_back(std::make_pair(&*Partial, Deduced));
}
if (Matched.size() == 1) {
- Pattern = Matched[0];
- // FIXME: set TemplateArgs to the template arguments of the
- // partial specialization, instantiated with the deduced template
- // arguments.
+ Pattern = Matched[0].first;
+ TemplateArgs = Matched[0].second;
} else if (Matched.size() > 1) {
// FIXME: Implement partial ordering of class template partial
// specializations.
@@ -856,9 +862,17 @@ Sema::InstantiateClassTemplateSpecialization(
ExplicitInstantiation? TSK_ExplicitInstantiation
: TSK_ImplicitInstantiation);
- return InstantiateClass(ClassTemplateSpec->getLocation(),
- ClassTemplateSpec, Pattern, *TemplateArgs,
- ExplicitInstantiation);
+ bool Result = InstantiateClass(ClassTemplateSpec->getLocation(),
+ ClassTemplateSpec, Pattern, *TemplateArgs,
+ ExplicitInstantiation);
+
+ for (unsigned I = 0, N = Matched.size(); I != N; ++I) {
+ // FIXME: Implement TemplateArgumentList::Destroy!
+ // if (Matched[I].first != Pattern)
+ // Matched[I].second->Destroy(Context);
+ }
+
+ return Result;
}
/// \brief Instantiate the definitions of all of the member of the
OpenPOWER on IntegriCloud