| Xinliang David Li | 6962659a | 2016-02-07 07:13:18 +0000 | [diff] [blame] | 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 |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 2 | |
| Xinliang David Li | 6962659a | 2016-02-07 07:13:18 +0000 | [diff] [blame] | 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 |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 4 | |
| 5 | struct Base { |
| 6 | int B; |
| 7 | Base(int B_) : B(B_) {} |
| 8 | ~Base() {} |
| 9 | }; |
| 10 | |
| 11 | struct Derived : public Base { |
| Xinliang David Li | 6458139 | 2016-02-08 19:14:14 +0000 | [diff] [blame] | 12 | Derived(int K) : Base(K) {} |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 13 | ~Derived() = default; |
| 14 | // PGOGEN-LABEL: define {{.*}}@_ZN7DerivedD2Ev |
| 15 | // PGOGEN: %pgocount = load {{.*}} @__profc__ZN7DerivedD2Ev |
| 16 | // PGOGEN: {{.*}}add{{.*}}%pgocount, 1 |
| 17 | // PGOGEN: store{{.*}}@__profc__ZN7DerivedD2Ev |
| 18 | |
| 19 | // Check that coverage mapping has 6 function records including |
| 20 | // the default destructor in the derived class. |
| Xinliang David Li | 6458139 | 2016-02-08 19:14:14 +0000 | [diff] [blame] | 21 | // COVMAP: @__llvm_coverage_mapping = {{.*}} { { i32, i32, i32, i32 }, [5 x |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 22 | // <{{.*}}>], |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 25 | int main() { |
| Xinliang David Li | 6458139 | 2016-02-08 19:14:14 +0000 | [diff] [blame] | 26 | Derived dd2(10); |
| 27 | if (dd2.B != 10) |
| 28 | return 1; |
| Xinliang David Li | 4e1aa2d | 2016-02-07 06:57:29 +0000 | [diff] [blame] | 29 | return 0; |
| 30 | } |