microsoft-abi-structors.cpp revision 6c9dccd7c437d091a911b749eb0b96f7baea7715
1// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s 2 3class A { 4 public: 5 A() { } 6 ~A() { } 7}; 8 9void no_constructor_destructor_infinite_recursion() { 10 A a; 11 12// CHECK: define linkonce_odr x86_thiscallcc %class.A* @"\01??0A@@QAE@XZ"(%class.A* %this) 13// CHECK: [[THIS_ADDR:%[.0-9A-Z_a-z]+]] = alloca %class.A*, align 4 14// CHECK-NEXT: store %class.A* %this, %class.A** [[THIS_ADDR]], align 4 15// CHECK-NEXT: [[T1:%[.0-9A-Z_a-z]+]] = load %class.A** [[THIS_ADDR]] 16// CHECK-NEXT: ret %class.A* [[T1]] 17// CHECK-NEXT: } 18 19// Make sure that the destructor doesn't call itself: 20// CHECK: define {{.*}} @"\01??1A@@QAE@XZ" 21// CHECK-NOT: call void @"\01??1A@@QAE@XZ" 22// CHECK: ret 23} 24 25struct B { 26 virtual ~B(); 27 virtual void foo(); 28}; 29 30void check_vftable_offset() { 31 B b; 32// The vftable pointer should point at the beginning of the vftable. 33// CHECK: [[THIS_PTR:%[0-9]+]] = bitcast %struct.B* {{.*}} to i8*** 34// CHECK: store i8** getelementptr inbounds ([2 x i8*]* @"\01??_7B@@6B@", i64 0, i64 0), i8*** [[THIS_PTR]] 35} 36