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