Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fexceptions -fcxx-exceptions -emit-llvm-only -triple %itanium_abi_triple -main-file-name deferred-region.cpp %s | FileCheck %s |
| 2 | |
| 3 | #define IF if |
| 4 | #define STMT(S) S |
| 5 | |
| 6 | // CHECK-LABEL: _Z3fooi: |
| 7 | void foo(int x) { |
| 8 | if (x == 0) { |
| 9 | return; |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 10 | } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:2 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 11 | |
| 12 | } |
| 13 | |
| 14 | // CHECK-NEXT: _Z4foooi: |
| 15 | void fooo(int x) { |
| 16 | if (x == 0) { |
| 17 | return; |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 18 | } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 19 | |
| 20 | if (x == 1) { |
| 21 | return; |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 22 | } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:2 = ((#0 - #1) - #2) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 23 | |
| 24 | } |
| 25 | |
| 26 | // CHECK-LABEL: _Z3bazv: |
| 27 | void baz() { // CHECK: [[@LINE]]:12 -> [[@LINE+2]]:2 |
| 28 | return; // CHECK-NOT: File |
| 29 | } |
| 30 | |
| 31 | // CHECK-LABEL: _Z3bari: |
| 32 | void bar(int x) { |
| 33 | IF (x) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 34 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 35 | |
| 36 | IF (!x) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 37 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = ((#0 - #1) - #2) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 38 | |
| 39 | foo(x); |
| 40 | } |
| 41 | |
| 42 | // CHECK-LABEL: _Z4quuxi: |
| 43 | // Deferred regions are not emitted within macro expansions. |
| 44 | void quux(int x) { |
| 45 | STMT( |
| 46 | if (x == 0) |
| 47 | return;) |
| 48 | |
| 49 | // CHECK-NOT: [[@LINE-2]]:{{.*}} -> [[@LINE+2]] |
| 50 | |
| 51 | if (x == 1) |
| 52 | STMT(return;) |
| 53 | |
| 54 | // CHECK-NOT: [[@LINE-2]]:{{.*}} -> [[@LINE+3]] |
| 55 | |
| 56 | STMT( |
| 57 | if (x == 2) |
| 58 | return; |
| 59 | |
| 60 | // CHECK-NOT: [[@LINE-2]]:{{.*}} -> [[@LINE+2]] |
| 61 | |
| 62 | if (x == 3) |
| 63 | return; |
| 64 | ) |
| 65 | } |
| 66 | |
| 67 | // CHECK-LABEL: _Z8weird_ifv: |
| 68 | void weird_if() { |
| 69 | int i = 0; |
| 70 | |
| 71 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 72 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 73 | |
| 74 | if (false) |
| 75 | i++; |
| 76 | |
| 77 | if (i + 100 > 0) { // CHECK: [[@LINE]]:20 -> [[@LINE+6]]:4 = #3 |
| 78 | if (false) // CHECK: [[@LINE+1]]:7 -> [[@LINE+1]]:13 = #4 |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 79 | return; // CHECK: Gap,File 0, [[@LINE]]:13 -> [[@LINE+2]]:5 = (#3 - #4) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 80 | // CHECK: [[@LINE+1]]:5 -> [[@LINE+3]]:4 = (#3 - #4) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 81 | return; // CHECK: Gap,File 0, [[@LINE]]:5 -> [[@LINE+4]]:3 = ((#0 - #1) - #3) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 82 | |
| 83 | } |
| 84 | |
| 85 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 86 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+1]]:2 |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | // CHECK-LABEL: _Z8for_loopv: |
| 90 | void for_loop() { |
| 91 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 92 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 93 | |
| 94 | for (int i = 0; i < 10; ++i) { |
| 95 | if (i % 2 == 0) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 96 | continue; // CHECK: Gap,File 0, [[@LINE]]:15 -> [[@LINE+2]]:5 = (#2 - #3) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 97 | |
| 98 | if (i % 5 == 0) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 99 | break; // CHECK: Gap,File 0, [[@LINE]]:12 -> [[@LINE+2]]:5 = ((#2 - #3) - #4) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 100 | |
| 101 | int x = i; // CHECK: [[@LINE]]:5 -> [[@LINE+3]]:4 = ((#2 - #3) - #4) |
| 102 | return; // CHECK-NOT: [[@LINE]]:11 -> [[@LINE+2]] |
| 103 | |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | struct Error {}; |
| 108 | |
| 109 | // CHECK-LABEL: _Z10while_loopv: |
| 110 | void while_loop() { |
| 111 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 112 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 113 | |
| 114 | int x = 0; |
| 115 | while (++x < 10) { |
| 116 | if (x == 1) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 117 | continue; // CHECK: Gap,File 0, [[@LINE]]:15 -> [[@LINE+2]]:5 = (#2 - #3) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 118 | |
| 119 | while (++x < 4) { |
| 120 | if (x == 3) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 121 | break; // CHECK: Gap,File 0, [[@LINE]]:14 -> [[@LINE+2]]:7 = (#4 - #5) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 122 | |
| 123 | while (++x < 5) {} |
| 124 | } |
| 125 | |
| 126 | if (x == 0) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 127 | throw Error(); // CHECK: Gap,File 0, [[@LINE]]:20 -> [[@LINE+2]]:5 = ((#2 - #3) - #7) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 128 | |
| 129 | while (++x < 9) { |
| 130 | if (x == 0) |
| 131 | break; // CHECK-NOT: [[@LINE]]:14 -> [[@LINE+2]] |
| 132 | |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // CHECK-LABEL: _Z5gotosv: |
| 138 | void gotos() { |
| 139 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 140 | goto out; // CHECK: Gap,File 0, [[@LINE]]:13 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 141 | |
| 142 | return; // CHECK: [[@LINE]]:3 -> [[@LINE+4]]:2 = (#0 - #1) |
| 143 | |
| 144 | out: |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame^] | 145 | return; // CHECK: Gap,File 0, [[@LINE]]:8 -> [[@LINE+1]]:2 = 0 |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | int main() { |
| 149 | foo(0); |
| 150 | foo(1); |
| 151 | fooo(0); |
| 152 | fooo(1); |
| 153 | baz(); |
| 154 | bar(0); |
| 155 | bar(1); |
| 156 | quux(0); |
| 157 | quux(1); |
| 158 | quux(2); |
| 159 | quux(3); |
| 160 | weird_if(); |
| 161 | for_loop(); |
| 162 | while_loop(); |
| 163 | gotos(); |
| 164 | return 0; |
| 165 | } |