xref: /llvm-project/clang/test/Profile/def-assignop.cpp (revision dd1ea9de2e3e3ac80a620f71411a9a36449f2697)
1a951e8ecSXinliang David 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
2a951e8ecSXinliang David 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
3a951e8ecSXinliang David Li 
4a951e8ecSXinliang David Li struct B {
5a951e8ecSXinliang David Li   B& operator=(const B &b);
6a951e8ecSXinliang David Li   B& operator=(const B &&b);
7a951e8ecSXinliang David Li };
8a951e8ecSXinliang David Li 
9a951e8ecSXinliang David Li struct A {
10a951e8ecSXinliang David Li   A &operator=(const A &) = default;
11a951e8ecSXinliang David Li   // PGOGEN: define {{.*}}@_ZN1AaSERKS_(
12a951e8ecSXinliang David Li   // PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSERKS_
13a951e8ecSXinliang David Li   // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
14a951e8ecSXinliang David Li   // PGOGEN: store{{.*}}@__profc__ZN1AaSERKS_
15a951e8ecSXinliang David Li   A &operator=(A &&) = default;
16a951e8ecSXinliang David Li   // PGOGEN: define {{.*}}@_ZN1AaSEOS_
17a951e8ecSXinliang David Li   // PGOGEN: %pgocount = load {{.*}} @__profc__ZN1AaSEOS_
18a951e8ecSXinliang David Li   // PGOGEN: {{.*}}add{{.*}}%pgocount, 1
19a951e8ecSXinliang David Li   // PGOGEN: store{{.*}}@__profc__ZN1AaSEOS_
20a951e8ecSXinliang David Li 
21*dd1ea9deSVedant Kumar   // Check that coverage mapping includes 3 function records including the
22a951e8ecSXinliang David Li   // defaulted copy and move operators: A::operator=
23*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
24*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
25*dd1ea9deSVedant Kumar   // COVMAP: section "__llvm_covfun", comdat
26*dd1ea9deSVedant Kumar   // COVMAP: @__llvm_coverage_mapping = {{.*}} { { i32, i32, i32, i32 }
27a951e8ecSXinliang David Li   B b;
28a951e8ecSXinliang David Li };
29a951e8ecSXinliang David Li 
30a951e8ecSXinliang David Li A a1, a2;
foo()3113cf09dcSXinliang David Li void foo() {
32a951e8ecSXinliang David Li   a1 = a2;
33a951e8ecSXinliang David Li   a2 = static_cast<A &&>(a1);
34a951e8ecSXinliang David Li }
35