xref: /aosp_15_r20/external/clang/test/Profile/def-assignop.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // 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*67e74705SXin Li // 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
3*67e74705SXin Li 
4*67e74705SXin Li struct B {
5*67e74705SXin Li   B& operator=(const B &b);
6*67e74705SXin Li   B& operator=(const B &&b);
7*67e74705SXin Li };
8*67e74705SXin Li 
9*67e74705SXin Li struct A {
10*67e74705SXin Li   A &operator=(const A &) = default;
11*67e74705SXin Li   // PGOGEN: define {{.*}}@_ZN1AaSERKS_(
12*67e74705SXin Li   // PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSERKS_
13*67e74705SXin Li   // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
14*67e74705SXin Li   // PGOGEN: store{{.*}}@__profc__ZN1AaSERKS_
15*67e74705SXin Li   A &operator=(A &&) = default;
16*67e74705SXin Li   // PGOGEN: define {{.*}}@_ZN1AaSEOS_
17*67e74705SXin Li   // PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSEOS_
18*67e74705SXin Li   // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
19*67e74705SXin Li   // PGOGEN: store{{.*}}@__profc__ZN1AaSEOS_
20*67e74705SXin Li 
21*67e74705SXin Li   // Check that coverage mapping includes 6 function records including the
22*67e74705SXin Li   // defaulted copy and move operators: A::operator=
23*67e74705SXin Li   // COVMAP: @__llvm_coverage_mapping = {{.*}} { { i32, i32, i32, i32 }, [3 x <{{.*}}>],
24*67e74705SXin Li   B b;
25*67e74705SXin Li };
26*67e74705SXin Li 
27*67e74705SXin Li A a1, a2;
foo()28*67e74705SXin Li void foo() {
29*67e74705SXin Li   a1 = a2;
30*67e74705SXin Li   a2 = static_cast<A &&>(a1);
31*67e74705SXin Li }
32