r206614 - Split out the no-thunk multiple inheritance tests

Timur Iskhodzhanov timurrrr at google.com
Fri Apr 18 08:10:05 PDT 2014


Author: timurrrr
Date: Fri Apr 18 10:10:05 2014
New Revision: 206614

URL: http://llvm.org/viewvc/llvm-project?rev=206614&view=rev
Log:
Split out the no-thunk multiple inheritance tests

Also, intentionally duplicate base class definitions per test, so it's easier to copy tests while debugging failures

Added:
    cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-no-thunks.cpp
      - copied, changed from r206458, cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance.cpp

Copied: cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-no-thunks.cpp (from r206458, cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-no-thunks.cpp?p2=cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-no-thunks.cpp&p1=cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance.cpp&r1=206458&r2=206614&rev=206614&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-no-thunks.cpp Fri Apr 18 10:10:05 2014
@@ -2,10 +2,7 @@
 // RUN: FileCheck %s < %t
 // RUN: FileCheck --check-prefix=MANGLING %s < %t.ll
 
-struct Empty {
-  // Doesn't have a vftable!
-};
-
+namespace test1 {
 struct A {
   virtual void f();
 };
@@ -16,594 +13,290 @@ struct B {
   virtual void h();
 };
 
-struct C {
-  virtual void g();  // Might "collide" with B::g if both are bases of some class.
-};
-
-
-namespace no_thunks {
+struct X : A, B {
+  // CHECK-LABEL: VFTable for 'test1::A' in 'test1::X' (1 entry)
+  // CHECK-NEXT:   0 | void test1::X::f()
+
+  // CHECK-LABEL: VFTable for 'test1::B' in 'test1::X' (2 entries)
+  // CHECK-NEXT:   0 | void test1::B::g()
+  // CHECK-NEXT:   1 | void test1::B::h()
 
-struct Test1: A, B {
-  // CHECK-LABEL:Test1' (1 entry)
-  // CHECK-NEXT: 0 | void no_thunks::Test1::f()
+  // CHECK-LABEL: VFTable indices for 'test1::X' (1 entry)
+  // CHECK-NEXT:   0 | void test1::X::f()
 
-  // CHECK-LABEL:Test1' (2 entries)
-  // CHECK-NEXT: 0 | void B::g()
-  // CHECK-NEXT: 1 | void B::h()
+  // MANGLING-DAG: @"\01??_7X at test1@@6BA at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test1@@6BB at 1@@"
 
-  // CHECK-LABEL:Test1' (1 entry)
-  // CHECK-NEXT: 0 | void no_thunks::Test1::f()
+  // Overrides only the left child's method (A::f), needs no thunks.
+  virtual void f();
+} x;
 
-  // MANGLING-DAG: @"\01??_7Test1 at no_thunks@@6BA@@@"
-  // MANGLING-DAG: @"\01??_7Test1 at no_thunks@@6BB@@@"
+void build_vftable(X *obj) { obj->f(); }
+}
 
-  // Overrides only the left child's method (A::f), needs no thunks.
+namespace test2 {
+struct A {
   virtual void f();
 };
 
-Test1 t1;
-void use(Test1 *obj) { obj->f(); }
+struct B {
+  virtual void g();
+  virtual void h();
+};
 
-struct Test2: A, B {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test2' (1 entry)
-  // CHECK-NEXT: 0 | void A::f()
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test2' (2 entries)
-  // CHECK-NEXT: 0 | void no_thunks::Test2::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test2' (1 entry).
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 0 | void no_thunks::Test2::g()
+struct X : A, B {
+  // CHECK-LABEL: VFTable for 'test2::A' in 'test2::X' (1 entry)
+  // CHECK-NEXT:   0 | void test2::A::f()
+
+  // CHECK-LABEL: VFTable for 'test2::B' in 'test2::X' (2 entries)
+  // CHECK-NEXT:   0 | void test2::X::g()
+  // CHECK-NEXT:   1 | void test2::B::h()
+
+  // CHECK-LABEL: VFTable indices for 'test2::X' (1 entry).
+  // CHECK-NEXT:   via vfptr at offset 4
+  // CHECK-NEXT:   0 | void test2::X::g()
 
   // Overrides only the right child's method (B::g), needs this adjustment but
   // not thunks.
   virtual void g();
 };
 
-Test2 t2;
-void use(Test2 *obj) { obj->g(); }
-
-struct Test3: A, B {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test3' (2 entries)
-  // CHECK-NEXT: 0 | void A::f()
-  // CHECK-NEXT: 1 | void no_thunks::Test3::i()
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test3' (2 entries)
-  // CHECK-NEXT: 0 | void B::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test3' (1 entry).
-  // CHECK-NEXT: 1 | void no_thunks::Test3::i()
-
-  // Only adds a new method.
-  virtual void i();
-};
-
-Test3 t3;
-void use(Test3 *obj) { obj->i(); }
-
-// Only the right base has a vftable, so it's laid out before the left one!
-struct Test4 : Empty, A {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test4' (1 entry)
-  // CHECK-NEXT: 0 | void no_thunks::Test4::f()
-
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test4' (1 entry).
-  // CHECK-NEXT: 0 | void no_thunks::Test4::f()
-
-  // MANGLING-DAG: @"\01??_7Test4 at no_thunks@@6B@"
+void build_vftable(X *obj) { obj->g(); }
+}
 
+namespace test3 {
+struct A {
   virtual void f();
 };
 
-Test4 t4;
-void use(Test4 *obj) { obj->f(); }
-
-// 2-level structure with repeating subobject types, but no thunks needed.
-struct Test5: Test1, Test2 {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test1' in 'no_thunks::Test5' (2 entries)
-  // CHECK-NEXT: 0 | void no_thunks::Test1::f()
-  // CHECK-NEXT: 1 | void no_thunks::Test5::z()
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test1' in 'no_thunks::Test5' (2 entries)
-  // CHECK-NEXT: 0 | void B::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test2' in 'no_thunks::Test5' (1 entry)
-  // CHECK-NEXT: 0 | void A::f()
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test2' in 'no_thunks::Test5' (2 entries)
-  // CHECK-NEXT: 0 | void no_thunks::Test2::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test5' (1 entry).
-  // CHECK-NEXT: 1 | void no_thunks::Test5::z()
-
-  // MANGLING-DAG: @"\01??_7Test5 at no_thunks@@6BA@@Test1 at 1@@"
-  // MANGLING-DAG: @"\01??_7Test5 at no_thunks@@6BA@@Test2 at 1@@"
-  // MANGLING-DAG: @"\01??_7Test5 at no_thunks@@6BB@@Test1 at 1@@"
-  // MANGLING-DAG: @"\01??_7Test5 at no_thunks@@6BB@@Test2 at 1@@"
-
-  virtual void z();
+struct B {
+  virtual void g();
+  virtual void h();
 };
 
-Test5 t5;
-void use(Test5 *obj) { obj->z(); }
-
-struct Test6: Test1 {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test1' in 'no_thunks::Test6' (1 entry).
-  // CHECK-NEXT: 0 | void no_thunks::Test6::f()
+struct X : A, B {
+  // CHECK-LABEL: VFTable for 'test3::A' in 'test3::X' (2 entries)
+  // CHECK-NEXT:   0 | void test3::A::f()
+  // CHECK-NEXT:   1 | void test3::X::i()
+
+  // CHECK-LABEL: VFTable for 'test3::B' in 'test3::X' (2 entries)
+  // CHECK-NEXT:   0 | void test3::B::g()
+  // CHECK-NEXT:   1 | void test3::B::h()
 
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test1' in 'no_thunks::Test6' (2 entries).
-  // CHECK-NEXT: 0 | void B::g()
-  // CHECK-NEXT: 1 | void B::h()
+  // CHECK-LABEL: VFTable indices for 'test3::X' (1 entry).
+  // CHECK-NEXT:   1 | void test3::X::i()
 
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test6' (1 entry).
-  // CHECK-NEXT: 0 | void no_thunks::Test6::f()
+  // Only adds a new method.
+  virtual void i();
+};
 
-  // MANGLING-DAG: @"\01??_7Test6 at no_thunks@@6BA@@@"
-  // MANGLING-DAG: @"\01??_7Test6 at no_thunks@@6BB@@@"
+void build_vftable(X *obj) { obj->i(); }
+}
 
-  // Overrides both no_thunks::Test1::f and A::f.
+namespace test4 {
+struct A {
   virtual void f();
 };
 
-Test6 t6;
-void use(Test6 *obj) { obj->f(); }
-
-struct Test7: Test2 {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test2' in 'no_thunks::Test7' (1 entry).
-  // CHECK-NEXT: 0 | void A::f()
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test2' in 'no_thunks::Test7' (2 entries).
-  // CHECK-NEXT: 0 | void no_thunks::Test7::g()
-  // CHECK-NEXT: 1 | void B::h()
+struct Empty { };  // Doesn't have a vftable!
 
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test7' (1 entry).
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 0 | void no_thunks::Test7::g()
+// Only the right base has a vftable, so it's laid out before the left one!
+struct X : Empty, A {
+  // CHECK-LABEL: VFTable for 'test4::A' in 'test4::X' (1 entry)
+  // CHECK-NEXT:   0 | void test4::X::f()
 
-  // Overrides both no_thunks::Test2::g and B::g.
-  virtual void g();
-};
+  // CHECK-LABEL: VFTable indices for 'test4::X' (1 entry).
+  // CHECK-NEXT:   0 | void test4::X::f()
 
-Test7 t7;
-void use(Test7 *obj) { obj->g(); }
+  // MANGLING-DAG: @"\01??_7X at test4@@6B@"
 
-struct Test8: Test3 {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test3' in 'no_thunks::Test8' (2 entries).
-  // CHECK-NEXT: 0 | void A::f()
-  // CHECK-NEXT: 1 | void no_thunks::Test3::i()
+  virtual void f();
+} x;
 
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test3' in 'no_thunks::Test8' (2 entries).
-  // CHECK-NEXT: 0 | void no_thunks::Test8::g()
-  // CHECK-NEXT: 1 | void B::h()
+void build_vftable(X *obj) { obj->f(); }
+}
 
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test8' (1 entry).
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 0 | void no_thunks::Test8::g()
+namespace test5 {
+struct A {
+  virtual void f();
+};
 
-  // Overrides grandparent's B::g.
+struct B {
   virtual void g();
+  virtual void h();
 };
 
-Test8 t8;
-void use(Test8 *obj) { obj->g(); }
-
-struct D : A {
-  virtual void g();
+struct C : A, B {
+  virtual void f();
 };
 
-// Repeating subobject.
-struct Test9: A, D {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test9' (2 entries).
-  // CHECK-NEXT: 0 | void A::f()
-  // CHECK-NEXT: 1 | void no_thunks::Test9::h()
+struct X : C {
+  // CHECK-LABEL: VFTable for 'test5::A' in 'test5::C' in 'test5::X' (1 entry).
+  // CHECK-NEXT:   0 | void test5::X::f()
 
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::D' in 'no_thunks::Test9' (2 entries).
-  // CHECK-NEXT: 0 | void A::f()
-  // CHECK-NEXT: 1 | void no_thunks::D::g()
+  // CHECK-LABEL: VFTable for 'test5::B' in 'test5::C' in 'test5::X' (2 entries).
+  // CHECK-NEXT:   0 | void test5::B::g()
+  // CHECK-NEXT:   1 | void test5::B::h()
 
-  // CHECK-LABEL: VFTable indices for 'no_thunks::Test9' (1 entry).
-  // CHECK-NEXT: 1 | void no_thunks::Test9::h()
+  // CHECK-LABEL: VFTable indices for 'test5::X' (1 entry).
+  // CHECK-NEXT:   0 | void test5::X::f()
 
-  // MANGLING-DAG: @"\01??_7Test9 at no_thunks@@6BA@@@"
-  // MANGLING-DAG: @"\01??_7Test9 at no_thunks@@6BD at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test5@@6BA at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test5@@6BB at 1@@"
 
-  virtual void h();
-};
+  // Overrides both C::f and A::f.
+  virtual void f();
+} x;
 
-Test9 t9;
-void use(Test9 *obj) { obj->h(); }
+void build_vftable(X *obj) { obj->f(); }
 }
 
-namespace pure_virtual {
-struct D {
-  virtual void g() = 0;
-  virtual void h();
+namespace test6 {
+struct A {
+  virtual void f();
 };
 
-
-struct Test1: A, D {
-  // CHECK: VFTable for 'A' in 'pure_virtual::Test1' (1 entry)
-  // CHECK-NEXT: 0 | void A::f()
-
-  // CHECK: VFTable for 'pure_virtual::D' in 'pure_virtual::Test1' (2 entries)
-  // CHECK-NEXT: 0 | void pure_virtual::Test1::g()
-  // CHECK-NEXT: 1 | void pure_virtual::D::h()
-
-  // CHECK: VFTable indices for 'pure_virtual::Test1' (1 entry).
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 0 | void pure_virtual::Test1::g()
-
-  // MANGLING-DAG: @"\01??_7Test1 at pure_virtual@@6BA@@@"
-  // MANGLING-DAG: @"\01??_7Test1 at pure_virtual@@6BD at 1@@"
-
-  // Overrides only the right child's method (pure_virtual::D::g), needs this adjustment but
-  // not thunks.
+struct B {
   virtual void g();
+  virtual void h();
 };
 
-Test1 t1;
-void use(Test1 *obj) { obj->g(); }
-}
-
-namespace this_adjustment {
-
-// Overrides methods of two bases at the same time, thus needing thunks.
-struct Test1 : B, C {
-  // CHECK-LABEL: VFTable for 'B' in 'this_adjustment::Test1' (2 entries).
-  // CHECK-NEXT: 0 | void this_adjustment::Test1::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable for 'C' in 'this_adjustment::Test1' (1 entry).
-  // CHECK-NEXT: 0 | void this_adjustment::Test1::g()
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'void this_adjustment::Test1::g()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'this_adjustment::Test1' (1 entry).
-  // CHECK-NEXT: 0 | void this_adjustment::Test1::g()
-
-  // MANGLING-DAG: @"\01??_7Test1 at this_adjustment@@6BB@@@"
-  // MANGLING-DAG: @"\01??_7Test1 at this_adjustment@@6BC@@@"
-
+struct C : A, B {
   virtual void g();
 };
 
-Test1 t1;
-void use(Test1 *obj) { obj->g(); }
-
-struct Test2 : A, B, C {
-  // CHECK-LABEL: VFTable for 'A' in 'this_adjustment::Test2' (1 entry).
-  // CHECK-NEXT: 0 | void A::f()
-
-  // CHECK-LABEL: VFTable for 'B' in 'this_adjustment::Test2' (2 entries).
-  // CHECK-NEXT: 0 | void this_adjustment::Test2::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable for 'C' in 'this_adjustment::Test2' (1 entry).
-  // CHECK-NEXT: 0 | void this_adjustment::Test2::g()
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'void this_adjustment::Test2::g()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'this_adjustment::Test2' (1 entry).
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 0 | void this_adjustment::Test2::g()
-
-  // MANGLING-DAG: @"\01??_7Test2 at this_adjustment@@6BA@@@"
-  // MANGLING-DAG: @"\01??_7Test2 at this_adjustment@@6BB@@@"
-  // MANGLING-DAG: @"\01??_7Test2 at this_adjustment@@6BC@@@"
+struct X : C {
+  // CHECK-LABEL: VFTable for 'test6::A' in 'test6::C' in 'test6::X' (1 entry).
+  // CHECK-NEXT:   0 | void test6::A::f()
+
+  // CHECK-LABEL: VFTable for 'test6::B' in 'test6::C' in 'test6::X' (2 entries).
+  // CHECK-NEXT:   0 | void test6::X::g()
+  // CHECK-NEXT:   1 | void test6::B::h()
+
+  // CHECK-LABEL: VFTable indices for 'test6::X' (1 entry).
+  // CHECK-NEXT:   via vfptr at offset 4
+  // CHECK-NEXT:   0 | void test6::X::g()
 
+  // Overrides both C::g and B::g.
   virtual void g();
 };
 
-Test2 t2;
-void use(Test2 *obj) { obj->g(); }
-
-// Overrides methods of two bases at the same time, thus needing thunks.
-struct Test3: no_thunks::Test1, no_thunks::Test2 {
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test1' in 'this_adjustment::Test3' (1 entry).
-  // CHECK-NEXT: 0 | void this_adjustment::Test3::f()
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test1' in 'this_adjustment::Test3' (2 entries).
-  // CHECK-NEXT: 0 | void this_adjustment::Test3::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable for 'A' in 'no_thunks::Test2' in 'this_adjustment::Test3' (1 entry).
-  // CHECK-NEXT: 0 | void this_adjustment::Test3::f()
-  // CHECK-NEXT:     [this adjustment: -8 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'void this_adjustment::Test3::f()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -8 non-virtual]
-
-  // CHECK-LABEL: VFTable for 'B' in 'no_thunks::Test2' in 'this_adjustment::Test3' (2 entries).
-  // CHECK-NEXT: 0 | void this_adjustment::Test3::g()
-  // CHECK-NEXT:     [this adjustment: -8 non-virtual]
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: Thunks for 'void this_adjustment::Test3::g()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -8 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'this_adjustment::Test3' (2 entries).
-  // CHECK-NEXT: via vfptr at offset 0
-  // CHECK-NEXT: 0 | void this_adjustment::Test3::f()
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 0 | void this_adjustment::Test3::g()
-
-  virtual void f();
-  virtual void g();
-};
-
-Test3 t3;
-void use(Test3 *obj) { obj->g(); }
+void build_vftable(X *obj) { obj->g(); }
 }
 
-namespace vdtor {
-struct Test1 {
-  virtual ~Test1();
-  virtual void z1();
-};
-
-struct Test2 {
-  virtual ~Test2();
-};
-
-struct Test3 : Test1, Test2 {
-  // CHECK-LABEL: VFTable for 'vdtor::Test1' in 'vdtor::Test3' (2 entries).
-  // CHECK-NEXT: 0 | vdtor::Test3::~Test3() [scalar deleting]
-  // CHECK-NEXT: 1 | void vdtor::Test1::z1()
-
-  // CHECK-LABEL: VFTable for 'vdtor::Test2' in 'vdtor::Test3' (1 entry).
-  // CHECK-NEXT: 0 | vdtor::Test3::~Test3() [scalar deleting]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'vdtor::Test3::~Test3()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'vdtor::Test3' (1 entry).
-  // CHECK-NEXT: 0 | vdtor::Test3::~Test3() [scalar deleting]
-  virtual ~Test3();
-};
-
-Test3 t3;
-void use(Test3 *obj) { delete obj; }
-
-struct Test4 {
-  // No virtual destructor here!
-  virtual void z4();
+namespace test7 {
+struct A {
+  virtual void f();
 };
 
-struct Test5 : Test4, Test2 {
-  // Implicit virtual dtor here!
-
-  // CHECK-LABEL: VFTable for 'vdtor::Test4' in 'vdtor::Test5' (1 entry).
-  // CHECK-NEXT: 0 | void vdtor::Test4::z4()
-
-  // CHECK-LABEL: VFTable for 'vdtor::Test2' in 'vdtor::Test5' (1 entry).
-  // CHECK-NEXT: 0 | vdtor::Test5::~Test5() [scalar deleting]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'vdtor::Test5::~Test5()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'vdtor::Test5' (1 entry).
-  // CHECK-NEXT: -- accessible via vfptr at offset 4 --
-  // CHECK-NEXT: 0 | vdtor::Test5::~Test5() [scalar deleting]
+struct B {
+  virtual void g();
+  virtual void h();
 };
 
-Test5 t5;
-void use(Test5 *obj) { delete obj; }
-
-struct Test6 : Test4, Test2 {
-  // Implicit virtual dtor here!
-
-  // CHECK-LABEL: VFTable for 'vdtor::Test4' in 'vdtor::Test6' (1 entry).
-  // CHECK-NEXT: 0 | void vdtor::Test4::z4()
-
-  // CHECK-LABEL: VFTable for 'vdtor::Test2' in 'vdtor::Test6' (1 entry).
-  // CHECK-NEXT: 0 | vdtor::Test6::~Test6() [scalar deleting]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'vdtor::Test6::~Test6()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'vdtor::Test6' (1 entry).
-  // CHECK-NEXT: -- accessible via vfptr at offset 4 --
-  // CHECK-NEXT: 0 | vdtor::Test6::~Test6() [scalar deleting]
+struct C : A, B {
+  // Only adds a new method.
+  virtual void i();
 };
 
-Test6 t6;
-void use(Test6 *obj) { delete obj; }
-
-struct Test7 : Test5 {
-  // CHECK-LABEL: VFTable for 'vdtor::Test4' in 'vdtor::Test5' in 'vdtor::Test7' (1 entry).
-  // CHECK-NEXT: 0 | void vdtor::Test4::z4()
+struct X : C {
+  // CHECK-LABEL: VFTable for 'test7::A' in 'test7::C' in 'test7::X' (2 entries).
+  // CHECK-NEXT:   0 | void test7::A::f()
+  // CHECK-NEXT:   1 | void test7::C::i()
+
+  // CHECK-LABEL: VFTable for 'test7::B' in 'test7::C' in 'test7::X' (2 entries).
+  // CHECK-NEXT:   0 | void test7::X::g()
+  // CHECK-NEXT:   1 | void test7::B::h()
+
+  // CHECK-LABEL: VFTable indices for 'test7::X' (1 entry).
+  // CHECK-NEXT:   via vfptr at offset 4
+  // CHECK-NEXT:   0 | void test7::X::g()
 
-  // CHECK-LABEL: VFTable for 'vdtor::Test2' in 'vdtor::Test5' in 'vdtor::Test7' (1 entry).
-  // CHECK-NEXT: 0 | vdtor::Test7::~Test7() [scalar deleting]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'vdtor::Test7::~Test7()' (1 entry).
-  // CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'vdtor::Test7' (1 entry).
-  // CHECK-NEXT: -- accessible via vfptr at offset 4 --
-  // CHECK-NEXT: 0 | vdtor::Test7::~Test7() [scalar deleting]
-  virtual ~Test7();
+  // Overrides grandparent's B::g.
+  virtual void g();
 };
 
-Test7 t7;
-void use(Test7 *obj) { delete obj; }
-
+void build_vftable(X *obj) { obj->g(); }
 }
 
-namespace return_adjustment {
-
-struct Ret1 {
-  virtual C* foo();
-  virtual void z();
+namespace test8 {
+struct A {
+  virtual void f();
 };
 
-struct Test1 : Ret1 {
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in 'return_adjustment::Test1' (3 entries).
-  // CHECK-NEXT: 0 | this_adjustment::Test1 *return_adjustment::Test1::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 4 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | this_adjustment::Test1 *return_adjustment::Test1::foo()
-
-  // CHECK-LABEL: Thunks for 'this_adjustment::Test1 *return_adjustment::Test1::foo()' (1 entry).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct C *'): 4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'return_adjustment::Test1' (1 entry).
-  // CHECK-NEXT: 2 | this_adjustment::Test1 *return_adjustment::Test1::foo()
-
-  // MANGLING-DAG: @"\01??_7Test1 at return_adjustment@@6B@"
-
-  virtual this_adjustment::Test1* foo();
+struct B : A {
+  virtual void g();
 };
 
-Test1 t1;
-void use(Test1 *obj) { obj->foo(); }
+// There are two 'A' subobjects in this class.
+struct X : A, B {
+  // CHECK-LABEL: VFTable for 'test8::A' in 'test8::X' (2 entries).
+  // CHECK-NEXT:   0 | void test8::A::f()
+  // CHECK-NEXT:   1 | void test8::X::h()
+
+  // CHECK-LABEL: VFTable for 'test8::A' in 'test8::B' in 'test8::X' (2 entries).
+  // CHECK-NEXT:   0 | void test8::A::f()
+  // CHECK-NEXT:   1 | void test8::B::g()
 
-struct Ret2 : B, this_adjustment::Test1 { };
+  // CHECK-LABEL: VFTable indices for 'test8::X' (1 entry).
+  // CHECK-NEXT:   1 | void test8::X::h()
 
-struct Test2 : Test1 {
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in 'return_adjustment::Test1' in 'return_adjustment::Test2' (4 entries).
-  // CHECK-NEXT: 0 | return_adjustment::Ret2 *return_adjustment::Test2::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 8 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | return_adjustment::Ret2 *return_adjustment::Test2::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct this_adjustment::Test1 *'): 4 non-virtual]
-  // CHECK-NEXT: 3 | return_adjustment::Ret2 *return_adjustment::Test2::foo()
+  // MANGLING-DAG: @"\01??_7X at test8@@6BA at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test8@@6BB at 1@@"
 
-  // CHECK-LABEL: Thunks for 'return_adjustment::Ret2 *return_adjustment::Test2::foo()' (2 entries).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct this_adjustment::Test1 *'): 4 non-virtual]
-  // CHECK-NEXT: 1 | [return adjustment (to type 'struct C *'): 8 non-virtual]
+  virtual void h();
+} x;
 
-  // CHECK-LABEL: VFTable indices for 'return_adjustment::Test2' (1 entry).
-  // CHECK-NEXT: 3 | return_adjustment::Ret2 *return_adjustment::Test2::foo()
+void build_vftable(X *obj) { obj->h(); }
+}
 
-  virtual Ret2* foo();
+namespace test9 {
+struct A {
+  virtual void f();
 };
 
-Test2 t2;
-void use(Test2 *obj) { obj->foo(); }
-
-struct Test3: B, Ret1 {
-  // CHECK-LABEL: VFTable for 'B' in 'return_adjustment::Test3' (2 entries).
-  // CHECK-NEXT: 0 | void B::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in 'return_adjustment::Test3' (3 entries).
-  // CHECK-NEXT: 0 | this_adjustment::Test1 *return_adjustment::Test3::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 4 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | this_adjustment::Test1 *return_adjustment::Test3::foo()
-
-  // CHECK-LABEL: Thunks for 'this_adjustment::Test1 *return_adjustment::Test3::foo()' (1 entry).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct C *'): 4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'return_adjustment::Test3' (1 entry).
-  // CHECK-NEXT: via vfptr at offset 4
-  // CHECK-NEXT: 2 | this_adjustment::Test1 *return_adjustment::Test3::foo()
-
-  virtual this_adjustment::Test1* foo();
+struct B {
+  virtual void g();
+  virtual void h();
 };
 
-Test3 t3;
-void use(Test3 *obj) { obj->foo(); }
-
-struct Test4 : Test3 {
-  // CHECK-LABEL: VFTable for 'B' in 'return_adjustment::Test3' in 'return_adjustment::Test4' (2 entries).
-  // CHECK-NEXT: 0 | void B::g()
-  // CHECK-NEXT: 1 | void B::h()
-
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in 'return_adjustment::Test3' in 'return_adjustment::Test4' (4 entries).
-  // CHECK-NEXT: 0 | return_adjustment::Ret2 *return_adjustment::Test4::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 8 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | return_adjustment::Ret2 *return_adjustment::Test4::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct this_adjustment::Test1 *'): 4 non-virtual]
-  // CHECK-NEXT: 3 | return_adjustment::Ret2 *return_adjustment::Test4::foo()
-
-  // CHECK-LABEL: Thunks for 'return_adjustment::Ret2 *return_adjustment::Test4::foo()' (2 entries).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct this_adjustment::Test1 *'): 4 non-virtual]
-  // CHECK-NEXT: 1 | [return adjustment (to type 'struct C *'): 8 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'return_adjustment::Test4' (1 entry).
-  // CHECK-NEXT: -- accessible via vfptr at offset 4 --
-  // CHECK-NEXT: 3 | return_adjustment::Ret2 *return_adjustment::Test4::foo()
-
-  virtual Ret2* foo();
+struct C : A, B {
+  // Overrides only the left child's method (A::f).
+  virtual void f();
 };
 
-Test4 t4;
-void use(Test4 *obj) { obj->foo(); }
-
-struct Test5 : Ret1, Test1 {
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in 'return_adjustment::Test5' (3 entries).
-  // CHECK-NEXT: 0 | return_adjustment::Ret2 *return_adjustment::Test5::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 8 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | return_adjustment::Ret2 *return_adjustment::Test5::foo()
-
-  // CHECK-LABEL: Thunks for 'return_adjustment::Ret2 *return_adjustment::Test5::foo()' (1 entry).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct C *'): 8 non-virtual]
-
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in  'return_adjustment::Test1' in 'return_adjustment::Test5' (4 entries).
-  // CHECK-NEXT: 0 | return_adjustment::Ret2 *return_adjustment::Test5::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 8 non-virtual]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | return_adjustment::Ret2 *return_adjustment::Test5::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct this_adjustment::Test1 *'): 4 non-virtual]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-  // CHECK-NEXT: 3 | return_adjustment::Ret2 *return_adjustment::Test5::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct return_adjustment::Ret2 *'): 0 non-virtual]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: Thunks for 'return_adjustment::Ret2 *return_adjustment::Test5::foo()' (3 entries).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct return_adjustment::Ret2 *'): 0 non-virtual]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-  // CHECK-NEXT: 1 | [return adjustment (to type 'struct this_adjustment::Test1 *'): 4 non-virtual]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-  // CHECK-NEXT: 2 | [return adjustment (to type 'struct C *'): 8 non-virtual]
-  // CHECK-NEXT:     [this adjustment: -4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'return_adjustment::Test5' (1 entry).
-  // CHECK-NEXT: 2 | return_adjustment::Ret2 *return_adjustment::Test5::foo()
-
-  virtual Ret2* foo();
+struct D : A, B {
+  // Overrides only the right child's method (B::g).
+  virtual void g();
 };
 
-Test5 t5;
-void use(Test5 *obj) { obj->foo(); }
-
-struct Ret3 : this_adjustment::Test1 { };
-
-struct Test6 : Test1 {
-  virtual Ret3* foo();
-  // CHECK-LABEL: VFTable for 'return_adjustment::Ret1' in 'return_adjustment::Test1' in 'return_adjustment::Test6' (4 entries).
-  // CHECK-NEXT: 0 | return_adjustment::Ret3 *return_adjustment::Test6::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct C *'): 4 non-virtual]
-  // CHECK-NEXT: 1 | void return_adjustment::Ret1::z()
-  // CHECK-NEXT: 2 | return_adjustment::Ret3 *return_adjustment::Test6::foo()
-  // CHECK-NEXT:     [return adjustment (to type 'struct this_adjustment::Test1 *'): 0 non-virtual]
-  // CHECK-NEXT: 3 | return_adjustment::Ret3 *return_adjustment::Test6::foo()
-
-  // CHECK-LABEL: Thunks for 'return_adjustment::Ret3 *return_adjustment::Test6::foo()' (2 entries).
-  // CHECK-NEXT: 0 | [return adjustment (to type 'struct this_adjustment::Test1 *'): 0 non-virtual]
-  // CHECK-NEXT: 1 | [return adjustment (to type 'struct C *'): 4 non-virtual]
-
-  // CHECK-LABEL: VFTable indices for 'return_adjustment::Test6' (1 entry).
-  // CHECK-NEXT: 3 | return_adjustment::Ret3 *return_adjustment::Test6::foo()
-};
+// 2-level structure with repeating subobject types, but no thunks needed.
+struct X : C, D {
+  // CHECK-LABEL: VFTable for 'test9::A' in 'test9::C' in 'test9::X' (2 entries)
+  // CHECK-NEXT:   0 | void test9::C::f()
+  // CHECK-NEXT:   1 | void test9::X::z()
+
+  // CHECK-LABEL: VFTable for 'test9::B' in 'test9::C' in 'test9::X' (2 entries)
+  // CHECK-NEXT:   0 | void test9::B::g()
+  // CHECK-NEXT:   1 | void test9::B::h()
+
+  // CHECK-LABEL: VFTable for 'test9::A' in 'test9::D' in 'test9::X' (1 entry)
+  // CHECK-NEXT:   0 | void test9::A::f()
+
+  // CHECK-LABEL: VFTable for 'test9::B' in 'test9::D' in 'test9::X' (2 entries)
+  // CHECK-NEXT:   0 | void test9::D::g()
+  // CHECK-NEXT:   1 | void test9::B::h()
+
+  // CHECK-LABEL: VFTable indices for 'test9::X' (1 entry).
+  // CHECK-NEXT:   1 | void test9::X::z()
+
+  // MANGLING-DAG: @"\01??_7X at test9@@6BA at 1@C at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test9@@6BA at 1@D at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test9@@6BB at 1@C at 1@@"
+  // MANGLING-DAG: @"\01??_7X at test9@@6BB at 1@D at 1@@"
 
-Test6 t6;
-void use(Test6 *obj) { obj->foo(); }
+  virtual void z();
+} x;
 
+void build_vftable(test9::X *obj) { obj->z(); }
 }





More information about the cfe-commits mailing list