diff options
author | John McCall <rjmccall@apple.com> | 2009-10-18 09:09:24 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-10-18 09:09:24 +0000 |
commit | 49a832bd499d6f61c23655f1fac99f0dd229756e (patch) | |
tree | ddf407322f3e10a390fe7a1331cfb44b4ac3b0c0 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 6800b334e5390452c6f921dbb832dfbfce371359 (diff) |
When performing template-substitution into a type, don't just replace the
TemplateTypeParmType with the substituted type directly; instead, replace it
with a SubstTemplateTypeParmType which will note that the type was originally
written as a template type parameter. This makes it reasonable to preserve
source information even through template substitution.
Also define the new SubstTemplateTypeParmType class, obviously.
For consistency with current behavior, we stringize these types as if they
were the underlying type. I'm not sure this is the right thing to do.
At any rate, I paled at adding yet another clause to the don't-desugar 'if'
statement, so I extracted a function to do it. The new function also does
The Right Thing more often, I think: e.g. if we have a chain of typedefs
leading to a vector type, we will now desugar all but the last one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 51971d4b1a..7f8960a2bf 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -613,7 +613,11 @@ TemplateInstantiator::TransformTemplateTypeParmType( == TemplateArgument::Type && "Template argument kind mismatch"); - return TemplateArgs(T->getDepth(), T->getIndex()).getAsType(); + QualType Replacement + = TemplateArgs(T->getDepth(), T->getIndex()).getAsType(); + + // TODO: only do this uniquing once, at the start of instantiation. + return getSema().Context.getSubstTemplateTypeParmType(T, Replacement); } // The template type parameter comes from an inner template (e.g., |