[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Profile / def-assignop.cpp
blobd17654f31428b56cc61bbfbf35fbe1cac01313f6
1 // RUN: %clang_cc1 -x c++ -std=c++11 %s -triple x86_64-unknown-linux-gnu -main-file-name def-assignop.cpp -o - -emit-llvm -fprofile-instrument=clang | FileCheck --check-prefix=PGOGEN %s
2 // RUN: %clang_cc1 -x c++ -std=c++11 %s -triple x86_64-unknown-linux-gnu -main-file-name def-assignop.cpp -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping | FileCheck --check-prefix=COVMAP %s
4 struct B {
5 B& operator=(const B &b);
6 B& operator=(const B &&b);
7 };
9 struct A {
10 A &operator=(const A &) = default;
11 // PGOGEN: define {{.*}}@_ZN1AaSERKS_(
12 // PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSERKS_
13 // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
14 // PGOGEN: store{{.*}}@__profc__ZN1AaSERKS_
15 A &operator=(A &&) = default;
16 // PGOGEN: define {{.*}}@_ZN1AaSEOS_
17 // PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSEOS_
18 // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
19 // PGOGEN: store{{.*}}@__profc__ZN1AaSEOS_
21 // Check that coverage mapping includes 3 function records including the
22 // defaulted copy and move operators: A::operator=
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 }
27 B b;
30 A a1, a2;
31 void foo() {
32 a1 = a2;
33 a2 = static_cast<A &&>(a1);