Skip to content

Commit e7c49a7

Browse files
committed
Add more enum debug info tests
Rename the previous enum debug info test, and add more tests to cover c-like enums and tagged (ordinary) enums.
1 parent d8b0eb7 commit e7c49a7

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/test/codegen/enum-debug-clike.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This test depends on a patch that was committed to upstream LLVM
12+
// before 7.0, then backported to the Rust LLVM fork. It tests that
13+
// debug info for "c-like" enums is properly emitted.
14+
15+
// ignore-tidy-linelength
16+
// ignore-windows
17+
// min-system-llvm-version 7.0
18+
19+
// compile-flags: -g -C no-prepopulate-passes
20+
21+
// CHECK-LABEL: @main
22+
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: DIFlagFixedEnum,{{.*}}
23+
// CHECK: {{.*}}DIEnumerator{{.*}}name: "A",{{.*}}value: {{[0-9].*}}
24+
// CHECK: {{.*}}DIEnumerator{{.*}}name: "B",{{.*}}value: {{[0-9].*}}
25+
// CHECK: {{.*}}DIEnumerator{{.*}}name: "C",{{.*}}value: {{[0-9].*}}
26+
27+
#![allow(dead_code)]
28+
#![allow(unused_variables)]
29+
#![allow(unused_assignments)]
30+
31+
enum E { A, B, C }
32+
33+
pub fn main() {
34+
let e = E::C;
35+
}
File renamed without changes.

src/test/codegen/enum-debug-tagged.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This test depends on a patch that was committed to upstream LLVM
12+
// before 7.0, then backported to the Rust LLVM fork. It tests that
13+
// debug info for tagged (ordinary) enums is properly emitted.
14+
15+
// ignore-tidy-linelength
16+
// ignore-windows
17+
// min-system-llvm-version 7.0
18+
19+
// compile-flags: -g -C no-prepopulate-passes
20+
21+
// CHECK-LABEL: @main
22+
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "E",{{.*}}
23+
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}}
24+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}}
25+
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}}
26+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}}
27+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}}
28+
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}}
29+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}}
30+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}}
31+
32+
#![allow(dead_code)]
33+
#![allow(unused_variables)]
34+
#![allow(unused_assignments)]
35+
36+
enum E { A(u32), B(u32) }
37+
38+
pub fn main() {
39+
let e = E::A(23);
40+
}

0 commit comments

Comments
 (0)