YouCompleteMe/cpp/llvm/tools/clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
Strahinja Val Markovic 1f51a89d39 Adding more llvm/clang files
These were ignored by git accidentally. We want ALL OF THEM since they all came
in the llvm/clang source distribution.
2012-07-05 17:55:45 -07:00

56 lines
761 B
C++

// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
struct A {
virtual void f();
virtual void f_const() const;
A h();
};
A g();
void f(A a, A *ap, A& ar) {
// This should not be a virtual function call.
// CHECK: call void @_ZN1A1fEv(%struct.A* %a)
a.f();
// CHECK: call void %
ap->f();
// CHECK: call void %
ar.f();
// CHECK: call void @_ZN1A1fEv
A().f();
// CHECK: call void @_ZN1A1fEv
g().f();
// CHECK: call void @_ZN1A1fEv
a.h().f();
// CHECK: call void @_ZNK1A7f_constEv
a.f_const();
// CHECK: call void @_ZN1A1fEv
(a).f();
}
struct B {
virtual void f();
~B();
B h();
};
void f() {
// CHECK: call void @_ZN1B1fEv
B().f();
// CHECK: call void @_ZN1B1fEv
B().h().f();
}