@@ -18,9 +18,9 @@ use libc::{c_uint, c_char};
18
18
use rustc:: ty:: TyCtxt ;
19
19
use rustc:: ty:: layout:: { Align , Size } ;
20
20
use rustc:: session:: { config, Session } ;
21
+ use rustc_data_structures:: small_c_str:: SmallCStr ;
21
22
22
23
use std:: borrow:: Cow ;
23
- use std:: ffi:: CString ;
24
24
use std:: ops:: Range ;
25
25
use std:: ptr;
26
26
@@ -58,7 +58,7 @@ impl Builder<'a, 'll, 'tcx> {
58
58
pub fn new_block < ' b > ( cx : & ' a CodegenCx < ' ll , ' tcx > , llfn : & ' ll Value , name : & ' b str ) -> Self {
59
59
let bx = Builder :: with_cx ( cx) ;
60
60
let llbb = unsafe {
61
- let name = CString :: new ( name) . unwrap ( ) ;
61
+ let name = SmallCStr :: new ( name) ;
62
62
llvm:: LLVMAppendBasicBlockInContext (
63
63
cx. llcx ,
64
64
llfn,
@@ -118,7 +118,7 @@ impl Builder<'a, 'll, 'tcx> {
118
118
}
119
119
120
120
pub fn set_value_name ( & self , value : & ' ll Value , name : & str ) {
121
- let cname = CString :: new ( name. as_bytes ( ) ) . unwrap ( ) ;
121
+ let cname = SmallCStr :: new ( name) ;
122
122
unsafe {
123
123
llvm:: LLVMSetValueName ( value, cname. as_ptr ( ) ) ;
124
124
}
@@ -436,7 +436,7 @@ impl Builder<'a, 'll, 'tcx> {
436
436
let alloca = if name. is_empty ( ) {
437
437
llvm:: LLVMBuildAlloca ( self . llbuilder , ty, noname ( ) )
438
438
} else {
439
- let name = CString :: new ( name) . unwrap ( ) ;
439
+ let name = SmallCStr :: new ( name) ;
440
440
llvm:: LLVMBuildAlloca ( self . llbuilder , ty,
441
441
name. as_ptr ( ) )
442
442
} ;
@@ -975,7 +975,7 @@ impl Builder<'a, 'll, 'tcx> {
975
975
parent : Option < & ' ll Value > ,
976
976
args : & [ & ' ll Value ] ) -> & ' ll Value {
977
977
self . count_insn ( "cleanuppad" ) ;
978
- let name = CString :: new ( "cleanuppad" ) . unwrap ( ) ;
978
+ let name = const_cstr ! ( "cleanuppad" ) ;
979
979
let ret = unsafe {
980
980
llvm:: LLVMRustBuildCleanupPad ( self . llbuilder ,
981
981
parent,
@@ -1001,7 +1001,7 @@ impl Builder<'a, 'll, 'tcx> {
1001
1001
parent : & ' ll Value ,
1002
1002
args : & [ & ' ll Value ] ) -> & ' ll Value {
1003
1003
self . count_insn ( "catchpad" ) ;
1004
- let name = CString :: new ( "catchpad" ) . unwrap ( ) ;
1004
+ let name = const_cstr ! ( "catchpad" ) ;
1005
1005
let ret = unsafe {
1006
1006
llvm:: LLVMRustBuildCatchPad ( self . llbuilder , parent,
1007
1007
args. len ( ) as c_uint , args. as_ptr ( ) ,
@@ -1025,7 +1025,7 @@ impl Builder<'a, 'll, 'tcx> {
1025
1025
num_handlers : usize ,
1026
1026
) -> & ' ll Value {
1027
1027
self . count_insn ( "catchswitch" ) ;
1028
- let name = CString :: new ( "catchswitch" ) . unwrap ( ) ;
1028
+ let name = const_cstr ! ( "catchswitch" ) ;
1029
1029
let ret = unsafe {
1030
1030
llvm:: LLVMRustBuildCatchSwitch ( self . llbuilder , parent, unwind,
1031
1031
num_handlers as c_uint ,
0 commit comments