diff options
| author | John McCall <rjmccall@apple.com> | 2012-08-25 01:12:56 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2012-08-25 01:12:56 +0000 |
| commit | 3351dc397ba46f24c79ae3655fa62b85dd84ec86 (patch) | |
| tree | d7ba57ec04cf16054644984a0b0dfabf88164c15 /clang/test/CodeGenCXX | |
| parent | 0a0aa84da3300f4b5c8c7b5c7778940770a96323 (diff) | |
| download | bcm5719-llvm-3351dc397ba46f24c79ae3655fa62b85dd84ec86.tar.gz bcm5719-llvm-3351dc397ba46f24c79ae3655fa62b85dd84ec86.zip | |
Fix the mangling of function pointers in the MS ABI.
Patch by Timur Iskhodzhanov!
llvm-svn: 162638
Diffstat (limited to 'clang/test/CodeGenCXX')
| -rw-r--r-- | clang/test/CodeGenCXX/mangle-ms-template-callback.cpp | 72 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/mangle-ms.cpp | 4 |
2 files changed, 76 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/mangle-ms-template-callback.cpp b/clang/test/CodeGenCXX/mangle-ms-template-callback.cpp new file mode 100644 index 00000000000..68781487513 --- /dev/null +++ b/clang/test/CodeGenCXX/mangle-ms-template-callback.cpp @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +template<typename Signature> +class C; + +template<typename Ret> +class C<Ret(void)> {}; +typedef C<void(void)> C0; + +template<typename Ret, typename Arg1> +class C<Ret(Arg1)> {}; + +template<typename Ret, typename Arg1, typename Arg2> +class C<Ret(Arg1, Arg2)> {}; + +C0 callback_void; +// CHECK: "\01?callback_void@@3V?$C@$$A6AXXZ@@A" + +volatile C0 callback_void_volatile; +// CHECK: "\01?callback_void_volatile@@3V?$C@$$A6AXXZ@@C" + +class Type {}; + +C<int(void)> callback_int; +// CHECK: "\01?callback_int@@3V?$C@$$A6AHXZ@@A" +C<Type(void)> callback_Type; +// CHECK: "\01?callback_Type@@3V?$C@$$A6A?AVType@@XZ@@A" + +C<void(int)> callback_void_int; +// CHECK: "\01?callback_void_int@@3V?$C@$$A6AXH@Z@@A" +C<int(int)> callback_int_int; +// CHECK: "\01?callback_int_int@@3V?$C@$$A6AHH@Z@@A" +C<void(Type)> callback_void_Type; +// CHECK: "\01?callback_void_Type@@3V?$C@$$A6AXVType@@@Z@@A" + +void foo(C0 c) {} +// CHECK: "\01?foo@@YAXV?$C@$$A6AXXZ@@@Z" + +// Here be dragons! +// Let's face the magic of template partial specialization... + +void function(C<void(void)>) {} +// CHECK: "\01?function@@YAXV?$C@$$A6AXXZ@@@Z" + +template<typename Ret> class C<Ret(*)(void)> {}; +void function_pointer(C<void(*)(void)>) {} +// CHECK: "\01?function_pointer@@YAXV?$C@P6AXXZ@@@Z" + +// Block equivalent to the previous definitions. +template<typename Ret> class C<Ret(^)(void)> {}; +void block(C<void(^)(void)>) {} +// CHECK: "\01?block@@YAXV?$C@P_EAXXZ@@@Z" +// FYI blocks are not present in MSVS, so we're free to choose the spec. + +template<typename T> class C<void (T::*)(void)> {}; +class Z { + public: + void method() {} +}; +void member_pointer(C<void (Z::*)(void)>) {} +// CHECK: "\01?member_pointer@@YAXV?$C@P8Z@@AEXXZ@@@Z" + +template<typename T> void bar(T) {} + +void call_bar() { + bar<int (*)(int)>(0); +// CHECK: "\01??$bar@P6AHH@Z@@YAXP6AHH@Z@Z" + + bar<int (^)(int)>(0); +// CHECK: "\01??$bar@P_EAHH@Z@@YAXP_EAHH@Z@Z" +// FYI blocks are not present in MSVS, so we're free to choose the spec. +} diff --git a/clang/test/CodeGenCXX/mangle-ms.cpp b/clang/test/CodeGenCXX/mangle-ms.cpp index f392c1701ed..ef210f54cd8 100644 --- a/clang/test/CodeGenCXX/mangle-ms.cpp +++ b/clang/test/CodeGenCXX/mangle-ms.cpp @@ -128,6 +128,10 @@ void zeta(int (*)(int, int)) {} void eta(int (^)(int, int)) {} // CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z" +typedef int theta_arg(int,int); +void theta(theta_arg^ block) {} +// CHECK: @"\01?theta@@YAXP_EAHHH@Z@Z" + void operator_new_delete() { char *ptr = new char; // CHECK: @"\01??2@YAPAXI@Z" |

