[cfe-commits] [PATCH] [VCPP] Mangle template parameters pack
pravic
ehysta at gmail.com
Sun Nov 11 10:30:32 PST 2012
1) x64 tests moved out
2) this test passed successfully on clang release build
3) there is a problem with assertions at TemplateArgumentLoc that will be resolved later
Hi cdavis5x, eli.friedman,
http://llvm-reviews.chandlerc.com/D99
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D99?vs=262&id=293#toc
Files:
lib/AST/MicrosoftMangle.cpp
test/CodeGenCXX/mangle-ms-variadic-templates.cpp
Index: lib/AST/MicrosoftMangle.cpp
===================================================================
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -807,11 +807,25 @@
case TemplateArgument::Expression:
mangleExpression(TA.getAsExpr());
break;
+ case TemplateArgument::Pack: {
+ SourceRange loc = TAL.getSourceRange();
+ if (TA.pack_size() > 0) {
+ // mangle pack as template types sequence
+ for (TemplateArgument::pack_iterator PA = TA.pack_begin(),
+ PAEnd = TA.pack_end(); PA != PAEnd; ++PA) {
+ mangleType(PA->getAsType(), loc);
+ }
+ } else {
+ // mangle empty pack as VC11 (17.0.51025) does
+ // <empty VT> ::= '@' "$$$V" '@'
+ Out << "$$$V";
+ }
+ break;
+ }
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion:
case TemplateArgument::Declaration:
- case TemplateArgument::NullPtr:
- case TemplateArgument::Pack: {
+ case TemplateArgument::NullPtr: {
// Issue a diagnostic.
DiagnosticsEngine &Diags = Context.getDiags();
unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
Index: test/CodeGenCXX/mangle-ms-variadic-templates.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/mangle-ms-variadic-templates.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -fms-extensions -cxx-abi microsoft -triple=i386-pc-win32 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -fms-extensions -cxx-abi microsoft -triple=x86_64-pc-win32 -o - %s | FileCheck %s
+// expected-no-diagnostics
+
+// Simple mangling test
+template<typename... T> void va(T...);
+
+void test_va() {
+ // CHECK: call void @"\01??$va@$$$V@@YAXXZ"()
+ va();
+ // CHECK: call void @"\01??$va at H@@YAXH at Z"(i32 1)
+ va(1);
+ // CHECK: call void @"\01??$va at HN@@YAXHN at Z"(i32 1, double 2.300000e+00)
+ va(1,2.3);
+ // CHECK: call void @"\01??$va at M@@YAXM at Z"(float 2.500000e+00)
+ va(2.5f);
+}
+
+// Mangling for template argument packs
+template<typename ...Types> void f1() {}
+// CHECK: define weak_odr void @"\01??$f1@$$$V@@YAXXZ"
+template void f1<>();
+// CHECK: define weak_odr void @"\01??$f1 at H@@YAXXZ"
+template void f1<int>();
+// CHECK: define weak_odr void @"\01??$f1 at HM@@YAXXZ"
+template void f1<int, float>();
+
+// Mangling function parameter packs
+template<typename ...Types> void f2(Types...) {}
+// CHECK: define weak_odr void @"\01??$f2@$$$V@@YAXXZ"
+template void f2<>();
+
+// Mangling non-trivial function parameter packs
+template<typename ...Types> void f3(const Types *...) {}
+// CHECK: define weak_odr void @"\01??$f3@$$$V@@YAXXZ"
+template void f3<>();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99.5.patch
Type: text/x-patch
Size: 2734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121111/12836622/attachment.bin>
More information about the cfe-commits
mailing list