@@ -94,7 +94,8 @@ impl Builder {
94
94
}
95
95
96
96
// REVIEW: Doesn't GEP work on array too?
97
- pub fn build_gep ( & self , ptr : & PointerValue , ordered_indexes : & [ IntValue ] , name : & str ) -> PointerValue {
97
+ /// GEP is very likely to segfault if indexes are used incorrectly, and is therefore an unsafe function. Maybe we can change this in the future.
98
+ pub unsafe fn build_gep ( & self , ptr : & PointerValue , ordered_indexes : & [ IntValue ] , name : & str ) -> PointerValue {
98
99
let c_string = CString :: new ( name) . expect ( "Conversion to CString failed unexpectedly" ) ;
99
100
100
101
let mut index_values: Vec < LLVMValueRef > = ordered_indexes. iter ( )
@@ -108,7 +109,8 @@ impl Builder {
108
109
}
109
110
110
111
// REVIEW: Doesn't GEP work on array too?
111
- pub fn build_in_bounds_gep ( & self , ptr : & PointerValue , ordered_indexes : & [ IntValue ] , name : & str ) -> PointerValue {
112
+ /// GEP is very likely to segfault if indexes are used incorrectly, and is therefore an unsafe function. Maybe we can change this in the future.
113
+ pub unsafe fn build_in_bounds_gep ( & self , ptr : & PointerValue , ordered_indexes : & [ IntValue ] , name : & str ) -> PointerValue {
112
114
let c_string = CString :: new ( name) . expect ( "Conversion to CString failed unexpectedly" ) ;
113
115
114
116
let mut index_values: Vec < LLVMValueRef > = ordered_indexes. iter ( )
@@ -122,7 +124,8 @@ impl Builder {
122
124
}
123
125
124
126
// REVIEW: Shouldn't this take a StructValue? Or does it still need to be PointerValue<StructValue>?
125
- pub fn build_struct_gep ( & self , ptr : & PointerValue , index : u32 , name : & str ) -> PointerValue {
127
+ /// GEP is very likely to segfault if indexes are used incorrectly, and is therefore an unsafe function. Maybe we can change this in the future.
128
+ pub unsafe fn build_struct_gep ( & self , ptr : & PointerValue , index : u32 , name : & str ) -> PointerValue {
126
129
let c_string = CString :: new ( name) . expect ( "Conversion to CString failed unexpectedly" ) ;
127
130
128
131
let value = unsafe {
0 commit comments