diff options
author | Anders Carlsson <andersca@mac.com> | 2010-02-13 23:40:17 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-02-13 23:40:17 +0000 |
commit | d3adb0ced900e3ad55235accaedec15ab29ec8db (patch) | |
tree | 5b3b40e238641eceac7470ea0624a8b13a4125e3 /clang/test/CodeGenCXX/vtable-layout.cpp | |
parent | 0daaf13b977be49d822ebdb213108414d9571d74 (diff) | |
download | bcm5719-llvm-d3adb0ced900e3ad55235accaedec15ab29ec8db.tar.gz bcm5719-llvm-d3adb0ced900e3ad55235accaedec15ab29ec8db.zip |
Add basic support for simple non-virtual 'this' pointer adjustments.
llvm-svn: 96136
Diffstat (limited to 'clang/test/CodeGenCXX/vtable-layout.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/vtable-layout.cpp | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/clang/test/CodeGenCXX/vtable-layout.cpp b/clang/test/CodeGenCXX/vtable-layout.cpp index d509431a52f..181ebc5c3e0 100644 --- a/clang/test/CodeGenCXX/vtable-layout.cpp +++ b/clang/test/CodeGenCXX/vtable-layout.cpp @@ -1,6 +1,16 @@ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts 2>&1 | FileCheck %s -namespace Test1 { +// For now, just verify this doesn't crash. +namespace test0 { + struct Obj {}; + + struct Base { virtual const Obj *foo() = 0; }; + struct Derived : Base { virtual Obj *foo() { return new Obj(); } }; + + void test(Derived *D) { D->foo(); } +} + +namespace Test1 { // CHECK: Vtable for 'Test1::A' (3 entries). // CHECK-NEXT: 0 | offset_to_top (0) // CHECK-NEXT: 1 | Test1::A RTTI @@ -202,7 +212,7 @@ void F::g() { } namespace Test5 { -// Simple secondary vtables without this-adjustments. +// Simple secondary vtables without 'this' pointer adjustments. struct A { virtual void f(); virtual void g(); @@ -240,12 +250,33 @@ struct C : B1, B2 { void C::h() { } } -// For now, just verify this doesn't crash. -namespace test0 { - struct Obj {}; +namespace Test6 { - struct Base { virtual const Obj *foo() = 0; }; - struct Derived : Base { virtual Obj *foo() { return new Obj(); } }; +// Simple non-virtual 'this' pointer adjustments. +struct A1 { + virtual void f(); + int a; +}; - void test(Derived *D) { D->foo(); } -} +struct A2 { + virtual void f(); + int a; +}; + +// CHECK: Vtable for 'Test6::C' (6 entries). +// CHECK-NEXT: 0 | offset_to_top (0) +// CHECK-NEXT: 1 | Test6::C RTTI +// CHECK-NEXT: -- (Test6::A1, 0) vtable address -- +// CHECK-NEXT: -- (Test6::C, 0) vtable address -- +// CHECK-NEXT: 2 | void Test6::C::f() +// CHECK-NEXT: 3 | offset_to_top (-16) +// CHECK-NEXT: 4 | Test6::C RTTI +// CHECK-NEXT: -- (Test6::A2, 16) vtable address -- +// CHECK-NEXT: 5 | void Test6::C::f() +// CHECK-NEXT: [this adjustment: -16 non-virtual] +struct C : A1, A2 { + virtual void f(); +}; +void C::f() { } + +}
\ No newline at end of file |