[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Profile / cxx-structors.cpp
blob1af01babf3b12d8252685d472652e2610bb06494
1 // Tests for instrumentation of C++ constructors and destructors.
2 //
3 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o %t -emit-llvm -fprofile-instrument=clang
4 // RUN: FileCheck %s -input-file=%t -check-prefix=INSTR
5 // RUN: FileCheck %s -input-file=%t -check-prefix=NOINSTR
7 struct Foo {
8 Foo() {}
9 Foo(int) {}
10 ~Foo() {}
13 struct Bar : public Foo {
14 Bar() {}
15 Bar(int x) : Foo(x) {}
16 ~Bar();
19 struct Baz : virtual public Foo {
20 Baz() {}
21 Baz(int x) : Foo(x) {}
22 ~Baz();
25 struct Quux : public Foo {
26 Quux(const char *y, ...) : Foo(0) {}
29 Foo foo;
30 Foo foo2(1);
31 Bar bar;
32 Baz baz;
33 Baz baz2(1);
34 Quux qux("fi", "fo", "fum");
36 // Profile data for complete constructors and destructors must be absent.
38 // INSTR: @__profc__ZN3BazC1Ev =
39 // INSTR: @__profc__ZN3BazC1Ei =
40 // INSTR: @__profc__ZN4QuuxC1EPKcz =
41 // INSTR: @__profc_main =
42 // INSTR: @__profc__ZN3FooC2Ev =
43 // INSTR: @__profc__ZN3FooD2Ev =
44 // INSTR: @__profc__ZN3FooC2Ei =
45 // INSTR: @__profc__ZN3BarC2Ev =
47 // NOINSTR-NOT: @__profc__ZN3FooC1Ev
48 // NOINSTR-NOT: @__profc__ZN3FooC1Ei
49 // NOINSTR-NOT: @__profc__ZN3FooD1Ev
50 // NOINSTR-NOT: @__profc__ZN3BarC1Ev
51 // NOINSTR-NOT: @__profc__ZN3BarD1Ev
52 // NOINSTR-NOT: @__profc__ZN3FooD1Ev
54 int main() {