xref: /llvm-project/clang/test/Profile/def-ctors.cpp (revision dd1ea9de2e3e3ac80a620f71411a9a36449f2697)
16962659aSXinliang David Li // RUN: %clang_cc1 -x c++ -std=c++11 %s -triple x86_64-unknown-linux-gnu  -main-file-name def-ctors.cpp -o - -emit-llvm -fprofile-instrument=clang |  FileCheck --check-prefix=PGOGEN %s
24e1aa2deSXinliang David Li 
36962659aSXinliang David Li // RUN: %clang_cc1 -x c++ -std=c++11 %s -triple x86_64-unknown-linux-gnu -main-file-name def-ctors.cpp -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping | FileCheck --check-prefix=COVMAP %s
44e1aa2deSXinliang David Li 
54e1aa2deSXinliang David Li struct Base {
64e1aa2deSXinliang David Li   int B;
BaseBase74e1aa2deSXinliang David Li   Base() : B(2) {}
BaseBase864581393SXinliang David Li   Base(const struct Base &b2) {}
94e1aa2deSXinliang David Li };
104e1aa2deSXinliang David Li 
114e1aa2deSXinliang David Li struct Derived : public Base {
124e1aa2deSXinliang David Li   Derived(const Derived &) = default;
134e1aa2deSXinliang David Li   // PGOGEN-DAG: define {{.*}}@_ZN7DerivedC2ERKS_
144e1aa2deSXinliang David Li   // PGOGEN-DAG: %pgocount = load {{.*}} @__profc__ZN7DerivedC2ERKS_
154e1aa2deSXinliang David Li   // PGOGEN-DAG: {{.*}}add{{.*}}%pgocount, 1
164e1aa2deSXinliang David Li   // PGOGEN-DAG: store{{.*}}@__profc__ZN7DerivedC2ERKS_
174e1aa2deSXinliang David Li   Derived() = default;
184e1aa2deSXinliang David Li   // PGOGEN-DAG: define {{.*}}@_ZN7DerivedC2Ev
194e1aa2deSXinliang David Li   // PGOGEN-DAG: %pgocount = load {{.*}} @__profc__ZN7DerivedC2Ev
204e1aa2deSXinliang David Li   // PGOGEN-DAG: {{.*}}add{{.*}}%pgocount, 1
214e1aa2deSXinliang David Li   // PGOGEN-DAG: store{{.*}}@__profc__ZN7DerivedC2Ev
224e1aa2deSXinliang David Li 
23*dd1ea9deSVedant Kumar   // Check that coverage mapping has 5 function records including
244e1aa2deSXinliang David Li   // the defaulted Derived::Derived(const Derived), and Derived::Derived()
254e1aa2deSXinliang David Li   // methds.
26*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
27*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
28*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
29*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
30*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
31*dd1ea9deSVedant Kumar   // COVMAP: @__llvm_coverage_mapping = {{.*}} { { i32, i32, i32, i32 }
324e1aa2deSXinliang David Li };
334e1aa2deSXinliang David Li 
344e1aa2deSXinliang David Li Derived dd;
354e1aa2deSXinliang David Li int g;
main()364e1aa2deSXinliang David Li int main() {
374e1aa2deSXinliang David Li   Derived dd2(dd);
3864581393SXinliang David Li   g = dd2.B;
394e1aa2deSXinliang David Li   return 0;
404e1aa2deSXinliang David Li }
41