about summary refs log tree commit diff
path: root/tests/codegen-llvm/debug-accessibility
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-07-21 14:34:12 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-07-22 14:28:48 +0200
commita27f3e3fd1e4d16160f8885b6b06665b5319f56c (patch)
treeb033935392cbadf6f85d2dbddf433a88e323aeeb /tests/codegen-llvm/debug-accessibility
parented93c1783b404d728d4809973a0550eb33cd293f (diff)
downloadrust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.tar.gz
rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.zip
Rename `tests/codegen` into `tests/codegen-llvm`
Diffstat (limited to 'tests/codegen-llvm/debug-accessibility')
-rw-r--r--tests/codegen-llvm/debug-accessibility/crate-enum.rs28
-rw-r--r--tests/codegen-llvm/debug-accessibility/crate-struct.rs23
-rw-r--r--tests/codegen-llvm/debug-accessibility/private-enum.rs22
-rw-r--r--tests/codegen-llvm/debug-accessibility/private-struct.rs17
-rw-r--r--tests/codegen-llvm/debug-accessibility/public-enum.rs23
-rw-r--r--tests/codegen-llvm/debug-accessibility/public-struct.rs17
-rw-r--r--tests/codegen-llvm/debug-accessibility/struct-fields.rs30
-rw-r--r--tests/codegen-llvm/debug-accessibility/super-enum.rs28
-rw-r--r--tests/codegen-llvm/debug-accessibility/super-struct.rs23
-rw-r--r--tests/codegen-llvm/debug-accessibility/tuple-fields.rs24
10 files changed, 235 insertions, 0 deletions
diff --git a/tests/codegen-llvm/debug-accessibility/crate-enum.rs b/tests/codegen-llvm/debug-accessibility/crate-enum.rs
new file mode 100644
index 00000000000..9ad5a6fd0ff
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/crate-enum.rs
@@ -0,0 +1,28 @@
+// ignore-tidy-linelength
+//! Checks that visibility information is present in the debuginfo for crate-visibility enums.
+
+//@ revisions: MSVC NONMSVC
+//@[MSVC] only-msvc
+//@[NONMSVC] ignore-msvc
+
+//@ compile-flags: -C debuginfo=2
+
+mod module {
+    use std::hint::black_box;
+
+    pub(crate) enum CrateFooEnum {
+        A,
+        B(u32),
+        C { x: u32 },
+    }
+
+    // NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "CrateFooEnum"{{.*}}flags: DIFlagProtected{{.*}})
+    // MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<crate_enum::module::CrateFooEnum>"{{.*}}flags: DIFlagProtected{{.*}})
+    pub fn use_everything() {
+        black_box(CrateFooEnum::A);
+    }
+}
+
+fn main() {
+    module::use_everything();
+}
diff --git a/tests/codegen-llvm/debug-accessibility/crate-struct.rs b/tests/codegen-llvm/debug-accessibility/crate-struct.rs
new file mode 100644
index 00000000000..73a8ce852ed
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/crate-struct.rs
@@ -0,0 +1,23 @@
+//@ compile-flags: -C debuginfo=2
+
+#![allow(dead_code)]
+
+// Checks that visibility information is present in the debuginfo for crate-visibility structs.
+
+mod module {
+    use std::hint::black_box;
+
+    pub(crate) struct CrateFooStruct {
+        x: u32,
+    }
+
+    // CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "CrateFooStruct"{{.*}}flags: DIFlagProtected{{.*}})
+
+    pub fn use_everything() {
+        black_box(CrateFooStruct { x: 2 });
+    }
+}
+
+fn main() {
+    module::use_everything();
+}
diff --git a/tests/codegen-llvm/debug-accessibility/private-enum.rs b/tests/codegen-llvm/debug-accessibility/private-enum.rs
new file mode 100644
index 00000000000..002336c03b3
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/private-enum.rs
@@ -0,0 +1,22 @@
+// ignore-tidy-linelength
+//! Checks that visibility information is present in the debuginfo for private enums.
+
+//@ revisions: MSVC NONMSVC
+//@[MSVC] only-msvc
+//@[NONMSVC] ignore-msvc
+//@ compile-flags: -C debuginfo=2
+
+use std::hint::black_box;
+
+enum PrivateFooEnum {
+    A,
+    B(u32),
+    C { x: u32 },
+}
+
+// NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PrivateFooEnum"{{.*}}flags: DIFlagPrivate{{.*}})
+// MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<private_enum::PrivateFooEnum>"{{.*}}flags: DIFlagPrivate{{.*}})
+
+fn main() {
+    black_box(PrivateFooEnum::A);
+}
diff --git a/tests/codegen-llvm/debug-accessibility/private-struct.rs b/tests/codegen-llvm/debug-accessibility/private-struct.rs
new file mode 100644
index 00000000000..488a680e81c
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/private-struct.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: -C debuginfo=2
+
+#![allow(dead_code)]
+
+// Checks that visibility information is present in the debuginfo for private structs.
+
+use std::hint::black_box;
+
+struct PrivateFooStruct {
+    x: u32,
+}
+
+// CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PrivateFooStruct"{{.*}}flags: DIFlagPrivate{{.*}})
+
+fn main() {
+    black_box(PrivateFooStruct { x: 1 });
+}
diff --git a/tests/codegen-llvm/debug-accessibility/public-enum.rs b/tests/codegen-llvm/debug-accessibility/public-enum.rs
new file mode 100644
index 00000000000..e5cd1ab7350
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/public-enum.rs
@@ -0,0 +1,23 @@
+// ignore-tidy-linelength
+//! Checks that visibility information is present in the debuginfo for types and their fields.
+
+//@ revisions: MSVC NONMSVC
+//@[MSVC] only-msvc
+//@[NONMSVC] ignore-msvc
+
+//@ compile-flags: -C debuginfo=2
+
+use std::hint::black_box;
+
+pub enum PublicFooEnum {
+    A,
+    B(u32),
+    C { x: u32 },
+}
+
+// NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PublicFooEnum"{{.*}}flags: DIFlagPublic{{.*}})
+// MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<public_enum::PublicFooEnum>"{{.*}}flags: DIFlagPublic{{.*}})
+
+fn main() {
+    black_box(PublicFooEnum::A);
+}
diff --git a/tests/codegen-llvm/debug-accessibility/public-struct.rs b/tests/codegen-llvm/debug-accessibility/public-struct.rs
new file mode 100644
index 00000000000..8b2a53f993c
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/public-struct.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: -C debuginfo=2
+
+#![allow(dead_code)]
+
+// Checks that visibility information is present in the debuginfo for public structs.
+
+use std::hint::black_box;
+
+pub struct PublicFooStruct {
+    x: u32,
+}
+
+// CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PublicFooStruct"{{.*}}flags: DIFlagPublic{{.*}})
+
+fn main() {
+    black_box(PublicFooStruct { x: 4 });
+}
diff --git a/tests/codegen-llvm/debug-accessibility/struct-fields.rs b/tests/codegen-llvm/debug-accessibility/struct-fields.rs
new file mode 100644
index 00000000000..f68bb3438be
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/struct-fields.rs
@@ -0,0 +1,30 @@
+//@ compile-flags: -C debuginfo=2
+
+#![allow(dead_code)]
+
+// Checks that visibility information is present in the debuginfo for struct fields.
+
+mod module {
+    use std::hint::black_box;
+
+    struct StructFields {
+        a: u32,
+        pub(crate) b: u32,
+        pub(super) c: u32,
+        pub d: u32,
+    }
+
+    // CHECK: [[StructFields:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "StructFields"{{.*}}flags: DIFlagPrivate{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: [[StructFields]]{{.*}}flags: DIFlagPrivate{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: [[StructFields]]{{.*}}flags: DIFlagProtected{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: [[StructFields]]{{.*}}flags: DIFlagProtected{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: [[StructFields]]{{.*}}flags: DIFlagPublic{{.*}})
+
+    pub fn use_everything() {
+        black_box(StructFields { a: 1, b: 2, c: 3, d: 4 });
+    }
+}
+
+fn main() {
+    module::use_everything();
+}
diff --git a/tests/codegen-llvm/debug-accessibility/super-enum.rs b/tests/codegen-llvm/debug-accessibility/super-enum.rs
new file mode 100644
index 00000000000..8e34d8be01f
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/super-enum.rs
@@ -0,0 +1,28 @@
+// ignore-tidy-linelength
+//! Checks that visibility information is present in the debuginfo for super-visibility enums.
+
+//@ revisions: MSVC NONMSVC
+//@[MSVC] only-msvc
+//@[NONMSVC] ignore-msvc
+//@ compile-flags: -C debuginfo=2
+
+mod module {
+    use std::hint::black_box;
+
+    pub(super) enum SuperFooEnum {
+        A,
+        B(u32),
+        C { x: u32 },
+    }
+
+    // NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "SuperFooEnum"{{.*}}flags: DIFlagProtected{{.*}})
+    // MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<super_enum::module::SuperFooEnum>"{{.*}}flags: DIFlagProtected{{.*}})
+
+    pub fn use_everything() {
+        black_box(SuperFooEnum::A);
+    }
+}
+
+fn main() {
+    module::use_everything();
+}
diff --git a/tests/codegen-llvm/debug-accessibility/super-struct.rs b/tests/codegen-llvm/debug-accessibility/super-struct.rs
new file mode 100644
index 00000000000..63954bfb203
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/super-struct.rs
@@ -0,0 +1,23 @@
+//@ compile-flags: -C debuginfo=2
+
+#![allow(dead_code)]
+
+// Checks that visibility information is present in the debuginfo for super-visibility structs.
+
+mod module {
+    use std::hint::black_box;
+
+    pub(super) struct SuperFooStruct {
+        x: u32,
+    }
+
+    // CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "SuperFooStruct"{{.*}}flags: DIFlagProtected{{.*}})
+
+    pub fn use_everything() {
+        black_box(SuperFooStruct { x: 3 });
+    }
+}
+
+fn main() {
+    module::use_everything();
+}
diff --git a/tests/codegen-llvm/debug-accessibility/tuple-fields.rs b/tests/codegen-llvm/debug-accessibility/tuple-fields.rs
new file mode 100644
index 00000000000..feec6e9eb41
--- /dev/null
+++ b/tests/codegen-llvm/debug-accessibility/tuple-fields.rs
@@ -0,0 +1,24 @@
+//@ compile-flags: -C debuginfo=2
+
+#![allow(dead_code)]
+
+// Checks that visibility information is present in the debuginfo for tuple struct fields.
+
+mod module {
+    use std::hint::black_box;
+
+    struct TupleFields(u32, pub(crate) u32, pub(super) u32, pub u32);
+
+    // CHECK: [[TupleFields:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "TupleFields"{{.*}}flags: DIFlagPrivate{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: [[TupleFields]]{{.*}}flags: DIFlagPrivate{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__1", scope: [[TupleFields]]{{.*}}flags: DIFlagProtected{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__2", scope: [[TupleFields]]{{.*}}flags: DIFlagProtected{{.*}})
+    // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__3", scope: [[TupleFields]]{{.*}}flags: DIFlagPublic{{.*}})
+    pub fn use_everything() {
+        black_box(TupleFields(1, 2, 3, 4));
+    }
+}
+
+fn main() {
+    module::use_everything();
+}