aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/TreeTransform.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-03-05 17:19:27 +0000
committerDouglas Gregor <dgregor@apple.com>2011-03-05 17:19:27 +0000
commit0b4bcb639a9aab9c466a9e6d6e61b3bd1bb36d68 (patch)
tree8d1b4b199e003240e41e24080c6db895aea6932d /lib/Sema/TreeTransform.h
parent476fc6715c4119a8e39ec70fbf9df1c57580ead8 (diff)
When transforming a substituted template type parameter, try to
transform the type that replaces the template type parameter. In the vast majority of cases, there's nothing to do, because most template type parameters are replaced with something non-dependent that doesn't need further transformation. However, when we're dealing with the default template arguments of template template parameters, we might end up replacing a template parameter (of the template template parameter) with a template parameter of the enclosing template. This addresses part of PR9016, but not within function templates. That's a separate issue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127091 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/TreeTransform.h')
-rw-r--r--lib/Sema/TreeTransform.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 1a5a98a23e..94aac52e5b 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -4126,7 +4126,28 @@ template<typename Derived>
QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
TypeLocBuilder &TLB,
SubstTemplateTypeParmTypeLoc TL) {
- return TransformTypeSpecType(TLB, TL);
+ const SubstTemplateTypeParmType *T = TL.getTypePtr();
+
+ // Substitute into the replacement type, which itself might involve something
+ // that needs to be transformed. This only tends to occur with default
+ // template arguments of template template parameters.
+ TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
+ QualType Replacement = getDerived().TransformType(T->getReplacementType());
+ if (Replacement.isNull())
+ return QualType();
+
+ // Always canonicalize the replacement type.
+ Replacement = SemaRef.Context.getCanonicalType(Replacement);
+ QualType Result
+ = SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
+ Replacement);
+
+ // Propagate type-source information.
+ SubstTemplateTypeParmTypeLoc NewTL
+ = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
+ NewTL.setNameLoc(TL.getNameLoc());
+ return Result;
+
}
template<typename Derived>