-
Notifications
You must be signed in to change notification settings - Fork 13.2k
/
Copy pathdi_builder.rs
115 lines (108 loc) · 2.92 KB
/
di_builder.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! Safe wrappers for [`DIBuilder`] FFI functions.
use libc::c_uint;
use rustc_abi::{Align, Size};
use crate::llvm::debuginfo::{DIBuilder, DIFlags};
use crate::llvm::{self, Metadata};
impl<'ll> DIBuilder<'ll> {
pub(crate) fn create_subroutine_type(
&self,
parameter_types: &[Option<&'ll Metadata>],
flags: DIFlags,
) -> &'ll Metadata {
unsafe {
llvm::LLVMDIBuilderCreateSubroutineType(
self,
None, // ("File"; unused)
parameter_types.as_ptr(),
parameter_types.len() as c_uint,
flags,
)
}
}
pub(crate) fn create_union_type(
&self,
scope: Option<&'ll Metadata>,
name: &str,
file_metadata: &'ll Metadata,
line_number: c_uint,
size: Size,
align: Align,
flags: DIFlags,
elements: &[&'ll Metadata],
unique_id: &str,
) -> &'ll Metadata {
unsafe {
llvm::LLVMDIBuilderCreateUnionType(
self,
scope,
name.as_ptr(),
name.len(),
file_metadata,
line_number,
size.bits(),
align.bits() as u32,
flags,
elements.as_ptr(),
elements.len() as c_uint,
0, // ("Objective-C runtime version"; default is 0)
unique_id.as_ptr(),
unique_id.len(),
)
}
}
pub(crate) fn create_array_type(
&self,
size: Size,
align: Align,
element_type: &'ll Metadata,
subscripts: &[&'ll Metadata],
) -> &'ll Metadata {
unsafe {
llvm::LLVMDIBuilderCreateArrayType(
self,
size.bits(),
align.bits() as u32,
element_type,
subscripts.as_ptr(),
subscripts.len() as c_uint,
)
}
}
pub(crate) fn create_basic_type(
&self,
name: &str,
size: Size,
dwarf_type_encoding: u32,
flags: DIFlags,
) -> &'ll Metadata {
unsafe {
llvm::LLVMDIBuilderCreateBasicType(
self,
name.as_ptr(),
name.len(),
size.bits(),
dwarf_type_encoding,
flags,
)
}
}
pub(crate) fn create_pointer_type(
&self,
pointee_type: &'ll Metadata,
size: Size,
align: Align,
name: &str,
) -> &'ll Metadata {
unsafe {
llvm::LLVMDIBuilderCreatePointerType(
self,
pointee_type,
size.bits(),
align.bits() as u32,
0, // ("DWARF address space"; default is 0)
name.as_ptr(),
name.len(),
)
}
}
}