@@ -18,9 +18,9 @@ use libc::{c_uint, c_char};
1818use rustc:: ty:: TyCtxt ;
1919use rustc:: ty:: layout:: { Align , Size } ;
2020use rustc:: session:: { config, Session } ;
21+ use rustc_data_structures:: small_c_str:: SmallCStr ;
2122
2223use std:: borrow:: Cow ;
23- use std:: ffi:: CString ;
2424use std:: ops:: Range ;
2525use std:: ptr;
2626
@@ -58,7 +58,7 @@ impl Builder<'a, 'll, 'tcx> {
5858 pub fn new_block < ' b > ( cx : & ' a CodegenCx < ' ll , ' tcx > , llfn : & ' ll Value , name : & ' b str ) -> Self {
5959 let bx = Builder :: with_cx ( cx) ;
6060 let llbb = unsafe {
61- let name = CString :: new ( name) . unwrap ( ) ;
61+ let name = SmallCStr :: new ( name) ;
6262 llvm:: LLVMAppendBasicBlockInContext (
6363 cx. llcx ,
6464 llfn,
@@ -118,7 +118,7 @@ impl Builder<'a, 'll, 'tcx> {
118118 }
119119
120120 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) ;
122122 unsafe {
123123 llvm:: LLVMSetValueName ( value, cname. as_ptr ( ) ) ;
124124 }
@@ -436,7 +436,7 @@ impl Builder<'a, 'll, 'tcx> {
436436 let alloca = if name. is_empty ( ) {
437437 llvm:: LLVMBuildAlloca ( self . llbuilder , ty, noname ( ) )
438438 } else {
439- let name = CString :: new ( name) . unwrap ( ) ;
439+ let name = SmallCStr :: new ( name) ;
440440 llvm:: LLVMBuildAlloca ( self . llbuilder , ty,
441441 name. as_ptr ( ) )
442442 } ;
@@ -975,7 +975,7 @@ impl Builder<'a, 'll, 'tcx> {
975975 parent : Option < & ' ll Value > ,
976976 args : & [ & ' ll Value ] ) -> & ' ll Value {
977977 self . count_insn ( "cleanuppad" ) ;
978- let name = CString :: new ( "cleanuppad" ) . unwrap ( ) ;
978+ let name = const_cstr ! ( "cleanuppad" ) ;
979979 let ret = unsafe {
980980 llvm:: LLVMRustBuildCleanupPad ( self . llbuilder ,
981981 parent,
@@ -1001,7 +1001,7 @@ impl Builder<'a, 'll, 'tcx> {
10011001 parent : & ' ll Value ,
10021002 args : & [ & ' ll Value ] ) -> & ' ll Value {
10031003 self . count_insn ( "catchpad" ) ;
1004- let name = CString :: new ( "catchpad" ) . unwrap ( ) ;
1004+ let name = const_cstr ! ( "catchpad" ) ;
10051005 let ret = unsafe {
10061006 llvm:: LLVMRustBuildCatchPad ( self . llbuilder , parent,
10071007 args. len ( ) as c_uint , args. as_ptr ( ) ,
@@ -1025,7 +1025,7 @@ impl Builder<'a, 'll, 'tcx> {
10251025 num_handlers : usize ,
10261026 ) -> & ' ll Value {
10271027 self . count_insn ( "catchswitch" ) ;
1028- let name = CString :: new ( "catchswitch" ) . unwrap ( ) ;
1028+ let name = const_cstr ! ( "catchswitch" ) ;
10291029 let ret = unsafe {
10301030 llvm:: LLVMRustBuildCatchSwitch ( self . llbuilder , parent, unwind,
10311031 num_handlers as c_uint ,
0 commit comments