Vedant Kumar | f9a0d44 | 2017-11-09 02:33:40 +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 -I %S/Inputs %s | FileCheck %s |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 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 | |
Vedant Kumar | ef8e05f | 2017-09-19 00:29:46 +0000 | [diff] [blame] | 31 | // CHECK-LABEL: _Z3mazv: |
| 32 | void maz() { |
| 33 | if (true) |
Vedant Kumar | 341bf42 | 2017-10-17 07:47:39 +0000 | [diff] [blame] | 34 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | ef8e05f | 2017-09-19 00:29:46 +0000 | [diff] [blame] | 35 | |
| 36 | return; // CHECK-NOT: Gap |
| 37 | } |
| 38 | |
Vedant Kumar | 341bf42 | 2017-10-17 07:47:39 +0000 | [diff] [blame] | 39 | // CHECK-LABEL: _Z4maazv: |
| 40 | void maaz() { |
| 41 | if (true) |
| 42 | return; // CHECK: Gap,File 0, [[@LINE]]:11 |
| 43 | else |
| 44 | return; // CHECK-NOT: Gap,File 0, [[@LINE]] |
| 45 | } |
| 46 | |
| 47 | // CHECK-LABEL: _Z5maaazv: |
| 48 | void maaaz() { |
| 49 | if (true) { |
| 50 | return; |
| 51 | } else { // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE]]:10 |
| 52 | return; // CHECK-NOT: Gap,File 0, [[@LINE]] |
| 53 | } |
| 54 | } |
| 55 | |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 56 | // CHECK-LABEL: _Z3bari: |
| 57 | void bar(int x) { |
| 58 | IF (x) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 59 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 60 | |
| 61 | IF (!x) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 62 | 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] | 63 | |
| 64 | foo(x); |
| 65 | } |
| 66 | |
| 67 | // CHECK-LABEL: _Z4quuxi: |
| 68 | // Deferred regions are not emitted within macro expansions. |
| 69 | void quux(int x) { |
| 70 | STMT( |
| 71 | if (x == 0) |
| 72 | return;) |
| 73 | |
| 74 | // CHECK-NOT: [[@LINE-2]]:{{.*}} -> [[@LINE+2]] |
| 75 | |
| 76 | if (x == 1) |
| 77 | STMT(return;) |
| 78 | |
| 79 | // CHECK-NOT: [[@LINE-2]]:{{.*}} -> [[@LINE+3]] |
| 80 | |
| 81 | STMT( |
| 82 | if (x == 2) |
| 83 | return; |
| 84 | |
| 85 | // CHECK-NOT: [[@LINE-2]]:{{.*}} -> [[@LINE+2]] |
| 86 | |
| 87 | if (x == 3) |
| 88 | return; |
| 89 | ) |
| 90 | } |
| 91 | |
| 92 | // CHECK-LABEL: _Z8weird_ifv: |
| 93 | void weird_if() { |
| 94 | int i = 0; |
| 95 | |
| 96 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 97 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 98 | |
| 99 | if (false) |
| 100 | i++; |
| 101 | |
| 102 | if (i + 100 > 0) { // CHECK: [[@LINE]]:20 -> [[@LINE+6]]:4 = #3 |
| 103 | if (false) // CHECK: [[@LINE+1]]:7 -> [[@LINE+1]]:13 = #4 |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 104 | return; // CHECK: Gap,File 0, [[@LINE]]:13 -> [[@LINE+2]]:5 = (#3 - #4) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 105 | // CHECK: [[@LINE+1]]:5 -> [[@LINE+3]]:4 = (#3 - #4) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 106 | 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] | 107 | |
| 108 | } |
| 109 | |
| 110 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 111 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+1]]:2 |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | // CHECK-LABEL: _Z8for_loopv: |
| 115 | void for_loop() { |
| 116 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 117 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 118 | |
| 119 | for (int i = 0; i < 10; ++i) { |
| 120 | if (i % 2 == 0) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 121 | continue; // CHECK: Gap,File 0, [[@LINE]]:15 -> [[@LINE+2]]:5 = (#2 - #3) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 122 | |
| 123 | if (i % 5 == 0) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 124 | 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] | 125 | |
| 126 | int x = i; // CHECK: [[@LINE]]:5 -> [[@LINE+3]]:4 = ((#2 - #3) - #4) |
| 127 | return; // CHECK-NOT: [[@LINE]]:11 -> [[@LINE+2]] |
| 128 | |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | struct Error {}; |
| 133 | |
| 134 | // CHECK-LABEL: _Z10while_loopv: |
| 135 | void while_loop() { |
| 136 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 137 | return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 138 | |
| 139 | int x = 0; |
| 140 | while (++x < 10) { |
| 141 | if (x == 1) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 142 | continue; // CHECK: Gap,File 0, [[@LINE]]:15 -> [[@LINE+2]]:5 = (#2 - #3) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 143 | |
| 144 | while (++x < 4) { |
| 145 | if (x == 3) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 146 | break; // CHECK: Gap,File 0, [[@LINE]]:14 -> [[@LINE+2]]:7 = (#4 - #5) |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 147 | |
| 148 | while (++x < 5) {} |
| 149 | } |
| 150 | |
| 151 | if (x == 0) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 152 | 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] | 153 | |
| 154 | while (++x < 9) { |
| 155 | if (x == 0) |
| 156 | break; // CHECK-NOT: [[@LINE]]:14 -> [[@LINE+2]] |
| 157 | |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // CHECK-LABEL: _Z5gotosv: |
| 163 | void gotos() { |
| 164 | if (false) |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 165 | 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] | 166 | |
| 167 | return; // CHECK: [[@LINE]]:3 -> [[@LINE+4]]:2 = (#0 - #1) |
| 168 | |
| 169 | out: |
Vedant Kumar | a1c4deb | 2017-09-18 23:37:30 +0000 | [diff] [blame] | 170 | return; // CHECK: Gap,File 0, [[@LINE]]:8 -> [[@LINE+1]]:2 = 0 |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Vedant Kumar | f9a0d44 | 2017-11-09 02:33:40 +0000 | [diff] [blame] | 173 | #include "deferred-region-helper.h" |
| 174 | // CHECK-LABEL: _Z13included_funcv: |
| 175 | // CHECK: Gap,File 0, 2:13 -> 3:5 = #1 |
| 176 | // CHECK: Gap,File 0, 3:11 -> 4:3 = (#0 - #1) |
| 177 | |
| 178 | // CHECK-LABEL: _Z7includev: |
| 179 | void include() { |
| 180 | included_func(); |
| 181 | } |
| 182 | |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 183 | int main() { |
| 184 | foo(0); |
| 185 | foo(1); |
| 186 | fooo(0); |
| 187 | fooo(1); |
Vedant Kumar | 341bf42 | 2017-10-17 07:47:39 +0000 | [diff] [blame] | 188 | maz(); |
| 189 | maaz(); |
| 190 | maaaz(); |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 191 | baz(); |
| 192 | bar(0); |
| 193 | bar(1); |
| 194 | quux(0); |
| 195 | quux(1); |
| 196 | quux(2); |
| 197 | quux(3); |
| 198 | weird_if(); |
| 199 | for_loop(); |
| 200 | while_loop(); |
| 201 | gotos(); |
Vedant Kumar | f9a0d44 | 2017-11-09 02:33:40 +0000 | [diff] [blame] | 202 | include(); |
Vedant Kumar | 747b0e2 | 2017-09-08 18:44:56 +0000 | [diff] [blame] | 203 | return 0; |
| 204 | } |