blob: 58195e3778257b48c93f1230fe2a9ec9d4f58eb0 [file] [log] [blame]
Adrian Prantl0ffce6e2013-06-08 00:16:55 +00001// RUN: %clang_cc1 -g -emit-llvm %s -o -| FileCheck %s
2//
3// Two variables with the same name in subsequent if staments need to be in separate scopes.
4//
5// rdar://problem/14024005
Adrian Prantl0ffce6e2013-06-08 00:16:55 +00006
David Blaikie93be0b22014-08-22 21:37:04 +00007int src();
Adrian Prantl0ffce6e2013-06-08 00:16:55 +00008
David Blaikie93be0b22014-08-22 21:37:04 +00009void f();
Adrian Prantl0ffce6e2013-06-08 00:16:55 +000010
David Blaikie93be0b22014-08-22 21:37:04 +000011void func() {
12 // CHECK: = metadata !{i32 786688, metadata [[IF1:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
13 // CHECK: [[IF1]] = metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
14 if (int i = src())
15 f();
16
17 // CHECK: = metadata !{i32 786688, metadata [[IF2:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
18 // CHECK: [[IF2]] = metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
19 if (int i = src()) {
20 f();
21 } else
22 f();
23
24 // CHECK: = metadata !{i32 786688, metadata [[FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
25 // CHECK: [[FOR]] = metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
26 for (int i = 0;
27 // CHECK: = metadata !{i32 786688, metadata [[FOR_BODY:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+6]]]
28 // The scope could be located at 'bool b', but LLVM drops line information for
29 // scopes anyway, so it's not terribly important.
30 // FIXME: change the debug info schema to not include locations of scopes,
31 // since they're not used.
32 // CHECK: [[FOR_BODY]] = metadata !{i32 {{.*}}, metadata [[FOR]], i32 [[@LINE-6]], {{.*}}} ; [ DW_TAG_lexical_block ]
33 bool b = i != 10; ++i)
34 f();
35
36 // CHECK: = metadata !{i32 786688, metadata [[FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
37 // CHECK: [[FOR]] = metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
38 for (int i = 0; i != 10; ++i) {
39 // FIXME: Do not include scopes that have only other scopes (and no variables
40 // or using declarations) as direct children, they just waste
41 // space/relocations/etc.
42 // CHECK: [[FOR_BODY:![0-9]*]] = metadata !{i32 {{.*}}, metadata [[FOR]], i32 [[@LINE-4]], {{.*}}} ; [ DW_TAG_lexical_block ]
43 // CHECK: = metadata !{i32 786688, metadata [[FOR_COMPOUND:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+2]]]
44 // CHECK: [[FOR_COMPOUND]] = metadata !{i32 {{.*}}, metadata [[FOR_BODY]], i32 [[@LINE-6]], {{.*}}} ; [ DW_TAG_lexical_block ]
45 bool b = i % 2;
Adrian Prantl0ffce6e2013-06-08 00:16:55 +000046 }
Adrian Prantl0ffce6e2013-06-08 00:16:55 +000047}