1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s 2 // XFAIL: * 3 4 namespace Test1 { 5 6 // Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial. 7 struct A { 8 virtual void f(); 9 ~A(); 10 }; 11 12 // CHECK: define void @_ZN5Test11AD2Ev 13 // CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test11AE, i64 0, i64 2), i8*** 14 A::~A() 15 { 16 } 17 18 } 19 20 namespace Test2 { 21 22 // Check that we do initialize the vtable pointer in A::~A() since the destructor body isn't trivial. 23 struct A { 24 virtual void f(); 25 ~A(); 26 }; 27 28 // CHECK: define void @_ZN5Test21AD2Ev 29 // CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test21AE, i64 0, i64 2), i8*** 30 A::~A() { 31 f(); 32 } 33 34 } 35 36 namespace Test3 { 37 38 // Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial 39 // and Field's destructor body is also trivial. 40 struct Field { 41 ~Field() { } 42 }; 43 44 struct A { 45 virtual void f(); 46 ~A(); 47 48 Field field; 49 }; 50 51 // CHECK: define void @_ZN5Test31AD2Ev 52 // CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test31AE, i64 0, i64 2), i8*** 53 A::~A() { 54 55 } 56 57 } 58 59 namespace Test4 { 60 61 // Check that we do initialize the vtable pointer in A::~A(), since Field's destructor body 62 // isn't trivial. 63 64 void f(); 65 66 struct Field { 67 ~Field() { f(); } 68 }; 69 70 struct A { 71 virtual void f(); 72 ~A(); 73 74 Field field; 75 }; 76 77 // CHECK: define void @_ZN5Test41AD2Ev 78 // CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test41AE, i64 0, i64 2), i8*** 79 A::~A() 80 { 81 } 82 83 } 84 85 namespace Test5 { 86 87 // Check that we do initialize the vtable pointer in A::~A(), since Field's destructor isn't 88 // available in this translation unit. 89 90 struct Field { 91 ~Field(); 92 }; 93 94 struct A { 95 virtual void f(); 96 ~A(); 97 98 Field field; 99 }; 100 101 // CHECK: define void @_ZN5Test51AD2Ev 102 // CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test51AE, i64 0, i64 2), i8*** 103 A::~A() 104 { 105 } 106 107 }