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