2015-10-08 12:24:12 +08:00
|
|
|
// RUN: %clang_cc1 -debug-info-kind=limited -std=c++11 -emit-llvm %s -o -| FileCheck %s
|
2013-06-08 08:16:55 +08:00
|
|
|
//
|
|
|
|
// Two variables with the same name in subsequent if staments need to be in separate scopes.
|
|
|
|
//
|
|
|
|
// rdar://problem/14024005
|
|
|
|
|
2014-08-23 05:37:04 +08:00
|
|
|
int src();
|
2013-06-08 08:16:55 +08:00
|
|
|
|
2014-08-23 05:37:04 +08:00
|
|
|
void f();
|
2013-06-08 08:16:55 +08:00
|
|
|
|
2014-08-23 05:37:04 +08:00
|
|
|
void func() {
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "i"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[IF1:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE+2]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[IF1]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])
|
2014-08-23 05:37:04 +08:00
|
|
|
if (int i = src())
|
|
|
|
f();
|
2013-06-08 08:16:55 +08:00
|
|
|
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "i"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[IF2:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE+2]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[IF2]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])
|
2014-08-23 05:37:04 +08:00
|
|
|
if (int i = src()) {
|
|
|
|
f();
|
|
|
|
} else
|
|
|
|
f();
|
|
|
|
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "i"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[FOR:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE+2]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[FOR]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])
|
2014-08-23 05:37:04 +08:00
|
|
|
for (int i = 0;
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "b"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[FOR_BODY:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE+6]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[FOR_BODY]] = distinct !DILexicalBlock({{.*}}line: [[@LINE-4]])
|
2014-08-23 05:37:04 +08:00
|
|
|
// The scope could be located at 'bool b', but LLVM drops line information for
|
|
|
|
// scopes anyway, so it's not terribly important.
|
|
|
|
// FIXME: change the debug info schema to not include locations of scopes,
|
|
|
|
// since they're not used.
|
|
|
|
bool b = i != 10; ++i)
|
|
|
|
f();
|
|
|
|
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "i"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[FOR:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE+2]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[FOR]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])
|
2014-08-23 05:37:04 +08:00
|
|
|
for (int i = 0; i != 10; ++i) {
|
2015-01-14 15:38:27 +08:00
|
|
|
// FIXME: Do not include scopes that have only other scopes (and no variables
|
|
|
|
// or using declarations) as direct children, they just waste
|
|
|
|
// space/relocations/etc.
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[FOR_LOOP_INCLUDING_COND:!.*]] = distinct !DILexicalBlock(scope: [[FOR]],{{.*}} line: [[@LINE-4]])
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "b"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[FOR_COMPOUND:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE+2]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[FOR_COMPOUND]] = distinct !DILexicalBlock(scope: [[FOR_LOOP_INCLUDING_COND]],{{.*}} line: [[@LINE-8]])
|
2014-08-23 05:37:04 +08:00
|
|
|
bool b = i % 2;
|
|
|
|
}
|
2014-08-23 05:54:29 +08:00
|
|
|
|
|
|
|
int x[] = {1, 2};
|
2018-02-15 05:22:11 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "__range1"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[RANGE_FOR:![0-9]*]]
|
|
|
|
// CHECK-NOT: line:
|
|
|
|
// CHECK-SAME: ){{$}}
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[RANGE_FOR]] = distinct !DILexicalBlock({{.*}}, line: [[@LINE+1]])
|
2014-08-23 05:54:29 +08:00
|
|
|
for (int i : x) {
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: = !DILocalVariable(name: "i"
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[RANGE_FOR_BODY:![0-9]*]]
|
|
|
|
// CHECK-SAME: line: [[@LINE-3]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[RANGE_FOR_BODY]] = distinct !DILexicalBlock(scope: [[RANGE_FOR]],{{.*}} line: [[@LINE-4]])
|
2014-08-23 05:54:29 +08:00
|
|
|
}
|
2013-06-08 08:16:55 +08:00
|
|
|
}
|