[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Profile / def-dtors.cpp
blobdc87508fe7c2877675a5603e1a112da4f42ce270
1 // RUN: %clang_cc1 -x c++ -std=c++11 %s -triple x86_64-unknown-linux-gnu -main-file-name def-dtors.cpp -o - -emit-llvm -fprofile-instrument=clang | FileCheck --check-prefix=PGOGEN %s
3 // RUN: %clang_cc1 -x c++ -std=c++11 %s -triple x86_64-unknown-linux-gnu -main-file-name def-dtors.cpp -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping | FileCheck --check-prefix=COVMAP %s
5 struct Base {
6 int B;
7 Base(int B_) : B(B_) {}
8 ~Base() {}
9 };
11 struct Derived : public Base {
12 Derived(int K) : Base(K) {}
13 ~Derived() = default;
14 // PGOGEN-LABEL: define {{.*}}@_ZN7DerivedD2Ev
15 // PGOGEN: %pgocount = load {{.*}} @__profc__ZN7DerivedD2Ev
16 // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
17 // PGOGEN: store{{.*}}@__profc__ZN7DerivedD2Ev
19 // Check that coverage mapping has 5 function records including
20 // the default destructor in the derived class.
21 // COVMAP: section "__llvm_covfun", comdat
22 // COVMAP: section "__llvm_covfun", comdat
23 // COVMAP: section "__llvm_covfun", comdat
24 // COVMAP: section "__llvm_covfun", comdat
25 // COVMAP: section "__llvm_covfun", comdat
26 // COVMAP: @__llvm_coverage_mapping = {{.*}} { { i32, i32, i32, i32 }
29 int main() {
30 Derived dd2(10);
31 if (dd2.B != 10)
32 return 1;
33 return 0;