Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 1 | // RUN: %clang_cc1 -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 2 | // PR19864 |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 3 | extern int v[2]; |
| 4 | int a = 0, b = 0; |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 5 | int main() { |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 6 | #line 100 |
| 7 | for (int x : v) |
| 8 | if (x) |
| 9 | ++b; // CHECK: add nsw{{.*}}, 1 |
| 10 | else |
| 11 | ++a; // CHECK: add nsw{{.*}}, 1 |
| 12 | // The continuation block if the if statement should not share the |
| 13 | // location of the ++a statement. The branch back to the start of the loop |
| 14 | // should be attributed to the loop header line. |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 15 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 16 | // CHECK: br label |
| 17 | // CHECK: br label |
| 18 | // CHECK: br label {{.*}}, !dbg [[DBG1:!.*]] |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 19 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 20 | #line 200 |
| 21 | while (a) |
| 22 | if (b) |
| 23 | ++b; // CHECK: add nsw{{.*}}, 1 |
| 24 | else |
| 25 | ++a; // CHECK: add nsw{{.*}}, 1 |
| 26 | |
| 27 | // CHECK: br label |
| 28 | // CHECK: br label {{.*}}, !dbg [[DBG2:!.*]] |
| 29 | |
| 30 | #line 300 |
| 31 | for (; a; ) |
| 32 | if (b) |
| 33 | ++b; // CHECK: add nsw{{.*}}, 1 |
| 34 | else |
| 35 | ++a; // CHECK: add nsw{{.*}}, 1 |
| 36 | |
| 37 | // CHECK: br label |
| 38 | // CHECK: br label {{.*}}, !dbg [[DBG3:!.*]] |
| 39 | |
| 40 | #line 400 |
| 41 | int x[] = {1, 2}; |
| 42 | for (int y : x) |
| 43 | if (b) |
| 44 | ++b; // CHECK: add nsw{{.*}}, 1 |
| 45 | else |
| 46 | ++a; // CHECK: add nsw{{.*}}, 1 |
| 47 | |
| 48 | // CHECK: br label |
| 49 | // CHECK: br label {{.*}}, !dbg [[DBG4:!.*]] |
| 50 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 51 | // CHECK: [[DBG1]] = !MDLocation(line: 100, scope: !{{.*}}) |
| 52 | // CHECK: [[DBG2]] = !MDLocation(line: 200, scope: !{{.*}}) |
| 53 | // CHECK: [[DBG3]] = !MDLocation(line: 300, scope: !{{.*}}) |
| 54 | // CHECK: [[DBG4]] = !MDLocation(line: 401, scope: !{{.*}}) |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 55 | } |