forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#115165 - davidtwco:issue-9228-describe-item-m…
…ember-visibility, r=wesleywiser codegen_llvm: set `DW_AT_accessibility` Fixes rust-lang#9228. Based on rust-lang#74778. Sets the accessibility of types and fields in DWARF using `DW_AT_accessibility` attribute. `DW_AT_accessibility` (public/protected/private) isn't exactly right for Rust, but neither is `DW_AT_visibility` (local/exported/qualified), and there's no way to set `DW_AT_visbility` in LLVM's API. Debuggers will special-case the handling of these per-language anyway. r? `@wesleywiser` (visited in wg-debugging triage)
- Loading branch information
Showing
14 changed files
with
276 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// compile-flags: -C debuginfo=2 | ||
// ignore-tidy-linelength | ||
|
||
#![allow(dead_code)] | ||
|
||
// Checks that visibility information is present in the debuginfo for crate-visibility enums. | ||
|
||
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// compile-flags: -C debuginfo=2 | ||
// ignore-tidy-linelength | ||
|
||
#![allow(dead_code)] | ||
|
||
// Checks that visibility information is present in the debuginfo for private enums. | ||
|
||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// compile-flags: -C debuginfo=2 | ||
// ignore-tidy-linelength | ||
|
||
#![allow(dead_code)] | ||
|
||
// Checks that visibility information is present in the debuginfo for types and their fields. | ||
|
||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
Oops, something went wrong.