[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / invariant.group-for-vptrs.cpp
blob2126aeb3adaaff094b6886c8dcc8d75c4b2d41d3
1 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s -fstrict-vtable-pointers -O1 -o - -disable-llvm-passes | FileCheck %s
3 struct A {
4 virtual void foo();
5 };
7 struct D : A {
8 void foo();
9 };
11 // CHECK-LABEL: define{{.*}} void @_Z21testExternallyVisiblev()
12 void testExternallyVisible() {
13 A *a = new A;
15 // CHECK: load {{.*}} !invariant.group ![[MD:[0-9]+]]
16 a->foo();
18 D *d = new D;
19 // CHECK: call void @_ZN1DC1Ev(
20 // CHECK: load {{.*}} !invariant.group ![[MD]]
21 d->foo();
22 A *a2 = d;
23 // CHECK: load {{.*}} !invariant.group ![[MD]]
24 a2->foo();
26 // CHECK-LABEL: {{^}}}
28 namespace {
30 struct B {
31 virtual void bar();
34 struct C : B {
35 void bar();
40 // CHECK-LABEL: define{{.*}} void @_Z21testInternallyVisibleb(
41 void testInternallyVisible(bool p) {
42 B *b = new B;
43 // CHECK: = load {{.*}}, !invariant.group ![[MD]]
44 b->bar();
46 // CHECK: call void @_ZN12_GLOBAL__N_11CC1Ev(
47 C *c = new C;
48 // CHECK: = load {{.*}}, !invariant.group ![[MD]]
49 c->bar();
52 // Checking A::A()
53 // CHECK-LABEL: define linkonce_odr void @_ZN1AC2Ev(
54 // CHECK: store {{.*}}, !invariant.group ![[MD]]
55 // CHECK-LABEL: {{^}}}
57 // Checking D::D()
58 // CHECK-LABEL: define linkonce_odr void @_ZN1DC2Ev(
59 // CHECK: = call ptr @llvm.launder.invariant.group.p0(ptr
60 // CHECK: call void @_ZN1AC2Ev(ptr
61 // CHECK: store {{.*}} !invariant.group ![[MD]]
63 // Checking B::B()
64 // CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11BC2Ev(
65 // CHECK: store {{.*}}, !invariant.group ![[MD]]
67 // Checking C::C()
68 // CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11CC2Ev(
69 // CHECK: store {{.*}}, !invariant.group ![[MD]]
71 // CHECK: ![[MD]] = !{}