r187751 - [ms-cxxabi] Handle template-template arguments
David Majnemer
david.majnemer at gmail.com
Mon Aug 5 15:26:47 PDT 2013
Author: majnemer
Date: Mon Aug 5 17:26:46 2013
New Revision: 187751
URL: http://llvm.org/viewvc/llvm-project?rev=187751&view=rev
Log:
[ms-cxxabi] Handle template-template arguments
Template-template arguments appear to be a rather simple encoding of the
template's templated tag type.
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=187751&r1=187750&r2=187751&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Aug 5 17:26:46 2013
@@ -123,7 +123,7 @@ private:
#undef NON_CANONICAL_TYPE
#undef TYPE
- void mangleType(const TagType*);
+ void mangleType(const TagDecl *TD);
void mangleDecayedArrayType(const ArrayType *T, bool IsGlobal);
void mangleArrayType(const ArrayType *T);
void mangleFunctionClass(const FunctionDecl *FD);
@@ -904,6 +904,9 @@ void MicrosoftCXXNameMangler::mangleTemp
mangleTemplateArg(TD, *I, ArgIndex);
break;
case TemplateArgument::Template:
+ mangleType(cast<TagDecl>(
+ TA.getAsTemplate().getAsTemplateDecl()->getTemplatedDecl()));
+ break;
case TemplateArgument::TemplateExpansion: {
// Issue a diagnostic.
DiagnosticsEngine &Diags = Context.getDiags();
@@ -1407,13 +1410,13 @@ void MicrosoftCXXNameMangler::mangleType
// <class-type> ::= V <name>
// <enum-type> ::= W <size> <name>
void MicrosoftCXXNameMangler::mangleType(const EnumType *T, SourceRange) {
- mangleType(cast<TagType>(T));
+ mangleType(cast<TagType>(T)->getDecl());
}
void MicrosoftCXXNameMangler::mangleType(const RecordType *T, SourceRange) {
- mangleType(cast<TagType>(T));
+ mangleType(cast<TagType>(T)->getDecl());
}
-void MicrosoftCXXNameMangler::mangleType(const TagType *T) {
- switch (T->getDecl()->getTagKind()) {
+void MicrosoftCXXNameMangler::mangleType(const TagDecl *TD) {
+ switch (TD->getTagKind()) {
case TTK_Union:
Out << 'T';
break;
@@ -1427,10 +1430,10 @@ void MicrosoftCXXNameMangler::mangleType
case TTK_Enum:
Out << 'W';
Out << getASTContext().getTypeSizeInChars(
- cast<EnumDecl>(T->getDecl())->getIntegerType()).getQuantity();
+ cast<EnumDecl>(TD)->getIntegerType()).getQuantity();
break;
}
- mangleName(T->getDecl());
+ mangleName(TD);
}
// <type> ::= <array-type>
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp?rev=187751&r1=187750&r2=187751&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp Mon Aug 5 17:26:46 2013
@@ -157,6 +157,35 @@ void variadic_class_instantiate() {
// CHECK: call {{.*}} @"\01??0?$VariadicClass at HD_N@@QAE at XZ"
// CHECK: call {{.*}} @"\01??0?$VariadicClass at _NDH@@QAE at XZ"
+template <typename T>
+struct Second {};
+
+template <typename T, template <class> class>
+struct Type {};
+
+template <template <class> class T>
+struct Type2 {};
+
+template <template <class> class T, bool B>
+struct Thing;
+
+template <template <class> class T>
+struct Thing<T, false> { };
+
+template <template <class> class T>
+struct Thing<T, true> { };
+
+void template_template_fun(Type<Thing<Second, true>, Second>) { }
+// CHECK: "\01?template_template_fun@@YAXU?$Type at U?$Thing at USecond@@$00@@USecond@@@@@Z"
+
+template <typename T>
+void template_template_specialization();
+
+template <>
+void template_template_specialization<void (Type<Thing<Second, true>, Second>)>() {
+}
+// CHECK: "\01??$template_template_specialization@$$A6AXU?$Type at U?$Thing at USecond@@$00@@USecond@@@@@Z@@YAXXZ"
+
// PR16788
template <decltype(nullptr)> struct S1 {};
void f(S1<nullptr>) {}
More information about the cfe-commits
mailing list