Anders Carlsson | 824d7ea | 2010-02-11 08:02:13 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts 2>&1 | FileCheck %s |
| 2 | namespace Test1 { |
| 3 | |
| 4 | // CHECK: Vtable for 'Test1::A' (3 entries). |
| 5 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 6 | // CHECK-NEXT: 1 | Test1::A RTTI |
Anders Carlsson | 822307b | 2010-02-11 17:18:51 +0000 | [diff] [blame] | 7 | // CHECK-NEXT: -- (Test1::A, 0) vtable address -- |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 8 | // CHECK-NEXT: 2 | void Test1::A::f() |
Anders Carlsson | 824d7ea | 2010-02-11 08:02:13 +0000 | [diff] [blame] | 9 | struct A { |
| 10 | virtual void f(); |
| 11 | }; |
Anders Carlsson | 824d7ea | 2010-02-11 08:02:13 +0000 | [diff] [blame] | 12 | void A::f() { } |
Anders Carlsson | 57071e2 | 2010-02-12 05:25:12 +0000 | [diff] [blame^] | 13 | |
Anders Carlsson | 824d7ea | 2010-02-11 08:02:13 +0000 | [diff] [blame] | 14 | } |
| 15 | |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 16 | namespace Test2 { |
| 17 | |
| 18 | // This is a smoke test of the vtable dumper. |
Anders Carlsson | bac7271 | 2010-02-11 18:21:49 +0000 | [diff] [blame] | 19 | // CHECK: Vtable for 'Test2::A' (9 entries). |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 20 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 21 | // CHECK-NEXT: 1 | Test2::A RTTI |
| 22 | // CHECK-NEXT: -- (Test2::A, 0) vtable address -- |
| 23 | // CHECK-NEXT: 2 | void Test2::A::f() |
| 24 | // CHECK-NEXT: 3 | void Test2::A::f() const |
| 25 | // CHECK-NEXT: 4 | Test2::A *Test2::A::g(int) |
| 26 | // CHECK-NEXT: 5 | Test2::A::~A() [complete] |
| 27 | // CHECK-NEXT: 6 | Test2::A::~A() [deleting] |
| 28 | // CHECK-NEXT: 7 | void Test2::A::h() |
Anders Carlsson | bac7271 | 2010-02-11 18:21:49 +0000 | [diff] [blame] | 29 | // CHECK-NEXT: 8 | Test2::A &Test2::A::operator=(Test2::A const &) |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 30 | struct A { |
| 31 | virtual void f(); |
| 32 | virtual void f() const; |
| 33 | |
| 34 | virtual A* g(int a); |
| 35 | virtual ~A(); |
| 36 | virtual void h(); |
Anders Carlsson | bac7271 | 2010-02-11 18:21:49 +0000 | [diff] [blame] | 37 | virtual A& operator=(const A&); |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 38 | }; |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 39 | void A::f() { } |
| 40 | |
Anders Carlsson | 9824142 | 2010-02-12 02:38:13 +0000 | [diff] [blame] | 41 | // Another simple vtable dumper test. |
Anders Carlsson | 57071e2 | 2010-02-12 05:25:12 +0000 | [diff] [blame^] | 42 | |
Anders Carlsson | 9824142 | 2010-02-12 02:38:13 +0000 | [diff] [blame] | 43 | // CHECK: Vtable for 'Test2::B' (6 entries). |
| 44 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 45 | // CHECK-NEXT: 1 | Test2::B RTTI |
| 46 | // CHECK-NEXT: -- (Test2::B, 0) vtable address -- |
| 47 | // CHECK-NEXT: 2 | void Test2::B::f() |
| 48 | // CHECK-NEXT: 3 | void Test2::B::g() [pure] |
| 49 | // CHECK-NEXT: 4 | Test2::B::~B() [complete] [pure] |
| 50 | // CHECK-NEXT: 5 | Test2::B::~B() [deleting] [pure] |
Anders Carlsson | 9824142 | 2010-02-12 02:38:13 +0000 | [diff] [blame] | 51 | struct B { |
| 52 | virtual void f(); |
| 53 | virtual void g() = 0; |
| 54 | virtual ~B() = 0; |
| 55 | }; |
Anders Carlsson | 9824142 | 2010-02-12 02:38:13 +0000 | [diff] [blame] | 56 | void B::f() { } |
| 57 | |
Anders Carlsson | 848fa64 | 2010-02-11 18:20:28 +0000 | [diff] [blame] | 58 | } |
Anders Carlsson | 57071e2 | 2010-02-12 05:25:12 +0000 | [diff] [blame^] | 59 | |
| 60 | namespace Test3 { |
| 61 | |
| 62 | // If a function in a derived class overrides a function in a primary base, |
| 63 | // then the function should not have an entry in the derived class (unless the return |
| 64 | // value requires adjusting). |
| 65 | |
| 66 | // CHECK: Vtable for 'Test3::A' (3 entries). |
| 67 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 68 | // CHECK-NEXT: 1 | Test3::A RTTI |
| 69 | // CHECK-NEXT: -- (Test3::A, 0) vtable address -- |
| 70 | // CHECK-NEXT: 2 | void Test3::A::f() |
| 71 | struct A { |
| 72 | virtual void f(); |
| 73 | }; |
| 74 | void A::f() { } |
| 75 | |
| 76 | // CHECK: Vtable for 'Test3::B' (4 entries). |
| 77 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 78 | // CHECK-NEXT: 1 | Test3::B RTTI |
| 79 | // CHECK-NEXT: -- (Test3::B, 0) vtable address -- |
| 80 | // CHECK-NEXT: 2 | void Test3::A::f() |
| 81 | // CHECK-NEXT: 3 | void Test3::B::g() |
| 82 | struct B : A { |
| 83 | virtual void f(); |
| 84 | virtual void g(); |
| 85 | }; |
| 86 | void B::f() { } |
| 87 | |
| 88 | // CHECK: Vtable for 'Test3::C' (5 entries). |
| 89 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 90 | // CHECK-NEXT: 1 | Test3::C RTTI |
| 91 | // CHECK-NEXT: -- (Test3::C, 0) vtable address -- |
| 92 | // CHECK-NEXT: 2 | void Test3::A::f() |
| 93 | // CHECK-NEXT: 3 | void Test3::C::g() |
| 94 | // CHECK-NEXT: 4 | void Test3::C::h() |
| 95 | struct C : A { |
| 96 | virtual void g(); |
| 97 | virtual void h(); |
| 98 | }; |
| 99 | void C::g() { } |
| 100 | |
| 101 | // CHECK: Vtable for 'Test3::D' (5 entries). |
| 102 | // CHECK-NEXT: 0 | offset_to_top (0) |
| 103 | // CHECK-NEXT: 1 | Test3::D RTTI |
| 104 | // CHECK-NEXT: -- (Test3::D, 0) vtable address -- |
| 105 | // CHECK-NEXT: 2 | void Test3::A::f() |
| 106 | // CHECK-NEXT: 3 | void Test3::B::g() |
| 107 | // CHECK-NEXT: 4 | void Test3::D::h() |
| 108 | struct D : B { |
| 109 | virtual void f(); |
| 110 | virtual void g(); |
| 111 | virtual void h(); |
| 112 | }; |
| 113 | |
| 114 | void D::f() { } |
| 115 | } |