// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll
// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s
struct B {
virtual void bar1();
virtual void bar2();
int b;
};
void B::bar1() { }
void B::bar2() { }
struct C {
virtual void bee1();
virtual void bee2();
};
void C::bee1() { }
void C::bee2() { }
struct D {
virtual void boo();
};
void D::boo() { }
struct D1 {
virtual void bar();
virtual void bar2();
virtual void bar3();
virtual void bar4();
virtual void bar5();
void *d1;
};
void D1::bar() { }
class F : virtual public D1, virtual public D {
public:
virtual void foo();
void *f;
};
void F::foo() { }
int j;
void *vp;
void test2() {
F f;
static int sz = (char *)(&f.f) - (char *)(&f);
vp = &sz;
j = sz;
// FIXME: These should result in a frontend constant a la fold, no run time
// initializer
// CHECK-LPLL64: define void @_Z5test2v()
// CHECK-LPLL64: = getelementptr inbounds %class.F* %f, i32 0, i32 1
}
static_assert(sizeof(F) == sizeof(void*)*4, "invalid vbase size");
struct E {
int e;
};
static_assert (sizeof (C) == (sizeof(void *)), "vtable pointer layout");
class A : public E, public B, public C {
public:
virtual void foo1();
virtual void foo2();
A() { }
int a;
} *ap;
void A::foo1() { }
void A::foo2() { }
int main() {
A a;
B b;
ap->e = 1;
ap->b = 2;
}
// CHECK-LP64: main:
// CHECK-LP64: movl $1, 12(%rax)
// CHECK-LP64: movl $2, 8(%rax)
struct test12_A {
virtual void foo0() { }
virtual void foo();
} *test12_pa;
struct test12_B : public test12_A {
virtual void foo() { }
} *test12_pb;
struct test12_D : public test12_B {
} *test12_pd;
void test12_foo() {
test12_pa->foo0();
test12_pb->foo0();
test12_pd->foo0();
test12_pa->foo();
test12_pb->foo();
test12_pd->foo();
test12_pa->test12_A::foo();
}
// CHECK-LPLL64:define void @_Z10test12_foov() nounwind {
// CHECK-LPLL64: call void %2(%class.test14* %tmp)
// CHECK-LPLL64: call void %5(%class.test14* %tmp1)
// CHECK-LPLL64: call void %8(%class.test14* %tmp3)
// CHECK-LPLL64: call void %11(%class.test14* %tmp5)
// CHECK-LPLL64: call void %14(%class.test14* %tmp7)
// CHECK-LPLL64: call void %17(%class.test14* %tmp9)
// CHECK-LPLL64: call void @_ZN8test12_A3fooEv(%class.test14* %tmp11)
struct test6_B2 { virtual void funcB2(); char b[1000]; };
struct test6_B1 : virtual test6_B2 { virtual void funcB1(); };
struct test6_D : test6_B2, virtual test6_B1 {
};
// CHECK-LP64: .zerofill __DATA, __common, _d6, 2024, 4
struct test7_B2 { virtual void funcB2(); };
struct test7_B1 : virtual test7_B2 { virtual void funcB1(); };
struct test7_D : test7_B2, virtual test7_B1 {
};
// CHECK-LP64: .zerofill __DATA, __common, _d7, 16, 3
struct test3_B3 { virtual void funcB3(); };
struct test3_B2 : virtual test3_B3 { virtual void funcB2(); };
struct test3_B1 : virtual test3_B