[PATCH] MS ABI: Mangle empty type parameter packs compatibly
David Majnemer
david.majnemer at gmail.com
Tue Aug 5 15:52:53 PDT 2014
Closed by commit rL214932 (authored by @majnemer).
REPOSITORY
rL LLVM
http://reviews.llvm.org/D4792
Files:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
Index: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
@@ -140,6 +140,18 @@
template void templ_fun_with_pack<>();
// CHECK-DAG: @"\01??$templ_fun_with_pack@$S@@YAXXZ"
+template <typename...>
+void templ_fun_with_ty_pack() {}
+
+template void templ_fun_with_ty_pack<>();
+// CHECK-DAG: @"\01??$templ_fun_with_ty_pack@$$V@@YAXXZ"
+
+template <template <class> class...>
+void templ_fun_with_templ_templ_pack() {}
+
+template void templ_fun_with_templ_templ_pack<>();
+// CHECK-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$V@@YAXXZ"
+
namespace PR20047 {
template <typename T>
struct A {};
Index: cfe/trunk/lib/AST/MicrosoftMangle.cpp
===================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp
@@ -279,7 +279,8 @@
void mangleTemplateArgs(const TemplateDecl *TD,
const TemplateArgumentList &TemplateArgs);
- void mangleTemplateArg(const TemplateDecl *TD, const TemplateArgument &TA);
+ void mangleTemplateArg(const TemplateDecl *TD, const TemplateArgument &TA,
+ const NamedDecl *Parm);
};
}
@@ -1104,12 +1105,18 @@
void MicrosoftCXXNameMangler::mangleTemplateArgs(
const TemplateDecl *TD, const TemplateArgumentList &TemplateArgs) {
// <template-args> ::= <template-arg>+
+ const TemplateParameterList *TPL = TD->getTemplateParameters();
+ assert(TPL->size() == TemplateArgs.size() &&
+ "size mismatch between args and parms!");
+
+ unsigned Idx = 0;
for (const TemplateArgument &TA : TemplateArgs.asArray())
- mangleTemplateArg(TD, TA);
+ mangleTemplateArg(TD, TA, TPL->getParam(Idx++));
}
void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD,
- const TemplateArgument &TA) {
+ const TemplateArgument &TA,
+ const NamedDecl *Parm) {
// <template-arg> ::= <type>
// ::= <integer-literal>
// ::= <member-data-pointer>
@@ -1172,10 +1179,16 @@
case TemplateArgument::Pack: {
ArrayRef<TemplateArgument> TemplateArgs = TA.getPackAsArray();
if (TemplateArgs.empty()) {
- Out << "$S";
+ if (isa<TemplateTypeParmDecl>(Parm) ||
+ isa<TemplateTemplateParmDecl>(Parm))
+ Out << "$$V";
+ else if (isa<NonTypeTemplateParmDecl>(Parm))
+ Out << "$S";
+ else
+ llvm_unreachable("unexpected template parameter decl!");
} else {
for (const TemplateArgument &PA : TemplateArgs)
- mangleTemplateArg(TD, PA);
+ mangleTemplateArg(TD, PA, Parm);
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4792.12212.patch
Type: text/x-patch
Size: 2895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140805/2e10d575/attachment.bin>
More information about the cfe-commits
mailing list