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
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index bb9f57b..0922538 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -628,6 +628,7 @@
case TypeOfExpr:
case TypeOf:
case TemplateTypeParm:
+ case SubstTemplateTypeParm:
case TemplateSpecialization:
case QualifiedName:
case Typename:
@@ -1267,6 +1268,10 @@
InnerString = Name->getName() + InnerString;
}
+void SubstTemplateTypeParmType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
+ getReplacementType().getAsStringInternal(InnerString, Policy);
+}
+
std::string
TemplateSpecializationType::PrintTemplateArgumentList(
const TemplateArgument *Args,