1 // RUN: %clang_cc1 -std=c++98 %s -triple armv7-none-eabi -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c++11 %s -triple armv7-none-eabi -emit-llvm -o - | FileCheck %s
3 // RUN: %clang_cc1 -std=c++1z %s -triple armv7-none-eabi -emit-llvm -o - | FileCheck %s
7 virtual void f_const() const;
15 void f(A a
, A
*ap
, A
& ar
) {
16 // This should not be a virtual function call.
18 // CHECK: call void @_ZN1A1fEv(ptr {{[^,]*}} %a)
27 // CHECK: call void @_ZN1A1fEv
30 // CHECK: call void @_ZN1A1fEv
33 // CHECK: call void @_ZN1A1fEv
36 // CHECK: call void @_ZNK1A7f_constEv
39 // CHECK: call void @_ZN1A1fEv
43 struct D
: A
{ virtual void g(); };
48 void fd(D d
, XD xd
, D
*p
) {
49 // CHECK: call void @_ZN1A1fEv(ptr
52 // CHECK: call void @_ZN1D1gEv(ptr
55 // CHECK: call void @_ZN1A1fEv
58 // CHECK: call void @_ZN1D1gEv
61 // CHECK: call void @_ZN1A1fEv
64 // CHECK: call void @_ZNK1A7f_constEv
67 // CHECK: call void @_ZN1A1fEv
70 // CHECK: call void @_ZN1A1fEv
73 // CHECK: call void @_ZN1D1gEv
76 // CHECK: call void @_ZN1A1fEv
79 // CHECK: call void @_ZN1A1fEv
82 // CHECK: call void @_ZN1A1fEv
86 // CHECK: call void @_ZN1D1gEv
89 // Can't devirtualize this; we have no guarantee that p points to a D here,
90 // due to the "single object is considered to be an array of one element"
95 // FIXME: We can devirtualize this, by C++1z [expr.add]/6 (if the array
96 // element type and the pointee type are not similar, behavior is undefined).
110 // CHECK: call void @_ZN1B1fEv
113 // CHECK: call void @_ZN1B1fEv
123 struct bar
: public foo
{
129 // CHECK: call void @_ZN5test23foo1fEv
130 // CHECK: call noundef ptr @_ZN5test23fooD1Ev
137 // Test that we don't crash in this case.
140 struct D
: public B
{
143 // CHECK-LABEL: define{{.*}} void @_ZN5test31fENS_1DE
152 struct Fish
: Animal
{
160 // CHECK: call void @_ZN5test44Fish3eatEv
165 // Do not devirtualize to pure virtual function calls.
168 virtual void f() = 0;
171 // CHECK-LABEL: define {{.*}} @_ZN5test51f
172 void f(Y
&y
, X
Y::*p
) {
173 // CHECK-NOT: call {{.*}} @_ZN5test51X1fEv
174 // CHECK: call void %
179 virtual void f() = 0;
181 // CHECK-LABEL: define {{.*}} @_ZN5test51g
183 // CHECK-NOT: call {{.*}} @_ZN5test51Z1fEv
184 // CHECK: call void %
189 virtual void f() final
= 0;
191 // CHECK-LABEL: define {{.*}} @_ZN5test51h
193 // CHECK-NOT: call {{.*}} @_ZN5test51Q1fEv
194 // CHECK: call void %