Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -debug-info-kind=limited -std=c++11 -S -emit-llvm %s -o - | FileCheck %s
      2 // PR19864
      3 extern int v[2];
      4 int a = 0, b = 0;
      5 int main() {
      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.
     15 
     16   // CHECK: br label
     17   // CHECK: br label
     18   // CHECK: br label {{.*}}, !dbg [[DBG1:![0-9]*]], !llvm.loop [[L1:![0-9]*]]
     19 
     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:![0-9]*]], !llvm.loop [[L2:![0-9]*]]
     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:![0-9]*]], !llvm.loop [[L3:![0-9]*]]
     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:![0-9]*]], !llvm.loop [[L4:![0-9]*]]
     50 
     51   // CHECK-DAG: [[DBG1]] = !DILocation(line: 100, scope: !{{.*}})
     52   // CHECK-DAG: [[DBG2]] = !DILocation(line: 200, scope: !{{.*}})
     53   // CHECK-DAG: [[DBG3]] = !DILocation(line: 300, scope: !{{.*}})
     54   // CHECK-DAG: [[DBG4]] = !DILocation(line: 401, scope: !{{.*}})
     55 
     56   // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[LDBG1:![0-9]*]]}
     57   // CHECK-DAG: [[LDBG1]] = !DILocation(line: 100, scope: !{{.*}})
     58 
     59   // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[LDBG2:![0-9]*]]}
     60   // CHECK-DAG: [[LDBG2]] = !DILocation(line: 200, scope: !{{.*}})
     61 
     62   // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[LDBG3:![0-9]*]]}
     63   // CHECK-DAG: [[LDBG3]] = !DILocation(line: 300, scope: !{{.*}})
     64 
     65   // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[LDBG4:![0-9]*]]}
     66   // CHECK-DAG: [[LDBG4]] = !DILocation(line: 401, scope: !{{.*}})
     67 }
     68