Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s |
Timur Iskhodzhanov | 8f88a1d | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 2 | |
| 3 | class C { |
| 4 | public: |
| 5 | void simple_method() {} |
| 6 | |
| 7 | void __cdecl cdecl_method() {} |
| 8 | |
| 9 | void vararg_method(const char *fmt, ...) {} |
| 10 | |
| 11 | static void static_method() {} |
| 12 | |
| 13 | int a; |
| 14 | }; |
| 15 | |
| 16 | void call_simple_method() { |
| 17 | C instance; |
| 18 | |
| 19 | instance.simple_method(); |
| 20 | // Make sure that the call uses the right calling convention: |
| 21 | // CHECK: call x86_thiscallcc void @"\01?simple_method@C@@QAEXXZ" |
| 22 | // CHECK: ret |
| 23 | |
| 24 | // Make sure that the definition uses the right calling convention: |
| 25 | // CHECK: define linkonce_odr x86_thiscallcc void @"\01?simple_method@C@@QAEXXZ" |
| 26 | // CHECK: ret |
| 27 | } |
| 28 | |
| 29 | void call_cdecl_method() { |
| 30 | C instance; |
| 31 | instance.cdecl_method(); |
| 32 | // Make sure that the call uses the right calling convention: |
| 33 | // CHECK: call void @"\01?cdecl_method@C@@QAAXXZ" |
| 34 | // CHECK: ret |
| 35 | |
| 36 | // Make sure that the definition uses the right calling convention: |
| 37 | // CHECK: define linkonce_odr void @"\01?cdecl_method@C@@QAAXXZ" |
| 38 | // CHECK: ret |
| 39 | } |
| 40 | |
| 41 | void call_vararg_method() { |
| 42 | C instance; |
| 43 | instance.vararg_method("Hello"); |
| 44 | // Make sure that the call uses the right calling convention: |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 45 | // CHECK: call void (%class.C*, i8*, ...) @"\01?vararg_method@C@@QAAXPBDZZ" |
Timur Iskhodzhanov | 8f88a1d | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 46 | // CHECK: ret |
| 47 | |
| 48 | // Make sure that the definition uses the right calling convention: |
| 49 | // CHECK: define linkonce_odr void @"\01?vararg_method@C@@QAAXPBDZZ" |
| 50 | } |
| 51 | |
| 52 | void call_static_method() { |
| 53 | C::static_method(); |
| 54 | // Make sure that the call uses the right calling convention: |
| 55 | // CHECK: call void @"\01?static_method@C@@SAXXZ" |
| 56 | // CHECK: ret |
| 57 | |
| 58 | // Make sure that the definition uses the right calling convention: |
| 59 | // CHECK: define linkonce_odr void @"\01?static_method@C@@SAXXZ" |
| 60 | } |
| 61 | |
| 62 | class Base { |
| 63 | public: |
| 64 | Base() {} |
| 65 | ~Base() {} |
| 66 | }; |
| 67 | |
| 68 | class Child: public Base { }; |
| 69 | |
| 70 | void constructors() { |
| 71 | Child c; |
| 72 | // Make sure that the Base constructor call in the Child constructor uses |
| 73 | // the right calling convention: |
John McCall | bd31574 | 2012-09-25 08:00:39 +0000 | [diff] [blame] | 74 | // CHECK: define linkonce_odr x86_thiscallcc %class.Child* @"\01??0Child@@QAE@XZ" |
NAKAMURA Takumi | 0e33dcd | 2012-09-25 09:53:18 +0000 | [diff] [blame] | 75 | // CHECK: %{{[.0-9A-Z_a-z]+}} = call x86_thiscallcc %class.Base* @"\01??0Base@@QAE@XZ" |
Timur Iskhodzhanov | 8f88a1d | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 76 | // CHECK: ret |
| 77 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 78 | // Make sure that the Base constructor definition uses the right CC: |
| 79 | // CHECK: define linkonce_odr x86_thiscallcc %class.Base* @"\01??0Base@@QAE@XZ" |
| 80 | |
Timur Iskhodzhanov | 8f88a1d | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 81 | // Make sure that the Base destructor call in the Child denstructor uses |
| 82 | // the right calling convention: |
| 83 | // CHECK: define linkonce_odr x86_thiscallcc void @"\01??1Child@@QAE@XZ" |
| 84 | // CHECK: call x86_thiscallcc void @"\01??1Base@@QAE@XZ" |
| 85 | // CHECK: ret |
| 86 | |
| 87 | // Make sure that the Base destructor definition uses the right CC: |
| 88 | // CHECK: define linkonce_odr x86_thiscallcc void @"\01??1Base@@QAE@XZ" |
Timur Iskhodzhanov | 8f88a1d | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 89 | } |