xref: /llvm-project/clang/test/Profile/cxx-structors.cpp (revision c4ad41385374cfbd89bd1b4f2b0198029f472c4d)
13a561459SSerge Pavlov // Tests for instrumentation of C++ constructors and destructors.
23a561459SSerge Pavlov //
354e06823SVedant Kumar // RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o %t -emit-llvm -fprofile-instrument=clang
454e06823SVedant Kumar // RUN: FileCheck %s -input-file=%t -check-prefix=INSTR
554e06823SVedant Kumar // RUN: FileCheck %s -input-file=%t -check-prefix=NOINSTR
63a561459SSerge Pavlov 
73a561459SSerge Pavlov struct Foo {
FooFoo83a561459SSerge Pavlov   Foo() {}
FooFoo93a561459SSerge Pavlov   Foo(int) {}
~FooFoo103a561459SSerge Pavlov   ~Foo() {}
113a561459SSerge Pavlov };
123a561459SSerge Pavlov 
133a561459SSerge Pavlov struct Bar : public Foo {
BarBar143a561459SSerge Pavlov   Bar() {}
BarBar153a561459SSerge Pavlov   Bar(int x) : Foo(x) {}
163a561459SSerge Pavlov   ~Bar();
173a561459SSerge Pavlov };
183a561459SSerge Pavlov 
197f809b2fSVedant Kumar struct Baz : virtual public Foo {
BazBaz207f809b2fSVedant Kumar   Baz() {}
BazBaz217f809b2fSVedant Kumar   Baz(int x) : Foo(x) {}
227f809b2fSVedant Kumar   ~Baz();
237f809b2fSVedant Kumar };
247f809b2fSVedant Kumar 
257f809b2fSVedant Kumar struct Quux : public Foo {
QuuxQuux267f809b2fSVedant Kumar   Quux(const char *y, ...) : Foo(0) {}
277f809b2fSVedant Kumar };
287f809b2fSVedant Kumar 
293a561459SSerge Pavlov Foo foo;
303a561459SSerge Pavlov Foo foo2(1);
313a561459SSerge Pavlov Bar bar;
327f809b2fSVedant Kumar Baz baz;
337f809b2fSVedant Kumar Baz baz2(1);
347f809b2fSVedant Kumar Quux qux("fi", "fo", "fum");
353a561459SSerge Pavlov 
36*c4ad4138SVedant Kumar // Profile data for complete constructors and destructors must be absent.
373a561459SSerge Pavlov 
387f809b2fSVedant Kumar // INSTR: @__profc__ZN3BazC1Ev =
397f809b2fSVedant Kumar // INSTR: @__profc__ZN3BazC1Ei =
407f809b2fSVedant Kumar // INSTR: @__profc__ZN4QuuxC1EPKcz =
4154e06823SVedant Kumar // INSTR: @__profc_main =
4254e06823SVedant Kumar // INSTR: @__profc__ZN3FooC2Ev =
4354e06823SVedant Kumar // INSTR: @__profc__ZN3FooD2Ev =
4454e06823SVedant Kumar // INSTR: @__profc__ZN3FooC2Ei =
4554e06823SVedant Kumar // INSTR: @__profc__ZN3BarC2Ev =
4654e06823SVedant Kumar 
4754e06823SVedant Kumar // NOINSTR-NOT: @__profc__ZN3FooC1Ev
4854e06823SVedant Kumar // NOINSTR-NOT: @__profc__ZN3FooC1Ei
4954e06823SVedant Kumar // NOINSTR-NOT: @__profc__ZN3FooD1Ev
5054e06823SVedant Kumar // NOINSTR-NOT: @__profc__ZN3BarC1Ev
5154e06823SVedant Kumar // NOINSTR-NOT: @__profc__ZN3BarD1Ev
5254e06823SVedant Kumar // NOINSTR-NOT: @__profc__ZN3FooD1Ev
533a561459SSerge Pavlov 
main()543a561459SSerge Pavlov int main() {
553a561459SSerge Pavlov }
56