@@ -9,10 +9,10 @@ use crate::esbmc::ESBMCParseResult;
99use crate :: irep:: Irept ;
1010use log:: trace;
1111
12- pub fn cbmc2esbmc ( entrypoint : & str , input : & str , output : & str ) {
12+ pub fn cbmc2esbmc ( input : & str , output : & str ) {
1313 trace ! ( "cbmc2esbmc mode, {} {}" , input, output) ;
1414
15- let result = crate :: cbmc:: process_cbmc_file ( input, entrypoint ) ;
15+ let result = crate :: cbmc:: process_cbmc_file ( input) ;
1616 std:: fs:: remove_file ( output) . ok ( ) ;
1717
1818 let converted = ESBMCParseResult :: from ( result) ;
@@ -22,7 +22,7 @@ pub fn cbmc2esbmc(entrypoint: &str, input: &str, output: &str) {
2222}
2323
2424trait IrepAdapter {
25- fn to_esbmc_irep ( self , entrypoint : & str ) -> Irept ;
25+ fn to_esbmc_irep ( self ) -> Irept ;
2626}
2727
2828pub fn irep_contains ( irep : & Irept , id : & str ) -> bool {
@@ -57,7 +57,6 @@ impl From<CBMCParseResult> for ESBMCParseResult {
5757 symbols_irep : Vec :: with_capacity ( data. symbols_irep . len ( ) ) ,
5858 functions_irep : Vec :: with_capacity ( data. functions_irep . len ( ) ) ,
5959 } ;
60- let entrypoint = & data. entrypoint ;
6160
6261 // First, we need to walk through the symbols and map all the
6362 // ref-types into concrete types
@@ -70,7 +69,6 @@ impl From<CBMCParseResult> for ESBMCParseResult {
7069 sym. stype . fix_type ( & type_cache) ;
7170 type_cache. insert ( tagname, sym. stype . clone ( ) ) ;
7271 }
73- adapted. symbols_irep . push ( sym. to_esbmc_irep ( entrypoint) ) ;
7472 }
7573
7674 // A symbol might have been defined later, we need to check everything again
@@ -103,8 +101,8 @@ impl From<CBMCParseResult> for ESBMCParseResult {
103101 }
104102 }
105103
106- let function_name = esbmcfixes:: fix_name ( & foo. name , entrypoint ) ;
107- let mut function_irep = foo. to_esbmc_irep ( entrypoint ) ;
104+ let function_name = esbmcfixes:: fix_name ( & foo. name ) ;
105+ let mut function_irep = foo. to_esbmc_irep ( ) ;
108106 function_irep. fix_type ( & type_cache) ;
109107 adapted. functions_irep . push ( ( function_name, function_irep) ) ;
110108 }
@@ -116,10 +114,7 @@ impl From<CBMCParseResult> for ESBMCParseResult {
116114mod esbmcfixes {
117115 use super :: HashSet ;
118116 use super :: Irept ;
119- pub fn fix_name ( name : & str , entry : & str ) -> String {
120- if name == entry {
121- return "__ESBMC_main" . to_string ( ) ;
122- }
117+ pub fn fix_name ( name : & str ) -> String {
123118 return String :: from ( name) ;
124119 }
125120
@@ -210,7 +205,7 @@ mod esbmcfixes {
210205 "bitand" ,
211206 "struct" ,
212207 "return" ,
213- "r_ok"
208+ "r_ok" ,
214209 ]
215210 . map ( |x| x. to_string ( ) ) ,
216211 ) ;
@@ -248,7 +243,7 @@ mod esbmcfixes {
248243}
249244
250245impl IrepAdapter for CBMCInstruction {
251- fn to_esbmc_irep ( self , entrypoint : & str ) -> Irept {
246+ fn to_esbmc_irep ( self ) -> Irept {
252247 let mut result = Irept :: default ( ) ;
253248 assert_ne ! ( self . instr_type, 19 ) ;
254249
@@ -301,19 +296,19 @@ impl IrepAdapter for CBMCInstruction {
301296}
302297
303298impl IrepAdapter for CBMCFunction {
304- fn to_esbmc_irep ( self , entrypoint : & str ) -> Irept {
299+ fn to_esbmc_irep ( self ) -> Irept {
305300 let mut result = Irept :: from ( "goto-program" ) ;
306301 for instr in self . instructions {
307302 if instr. code . id == "nil" || instr. code . named_subt [ "statement" ] . id != "output" {
308- result. subt . push ( instr. to_esbmc_irep ( entrypoint ) ) ;
303+ result. subt . push ( instr. to_esbmc_irep ( ) ) ;
309304 }
310305 }
311306 result
312307 }
313308}
314309
315310impl IrepAdapter for CBMCSymbol {
316- fn to_esbmc_irep ( self , entrypoint : & str ) -> Irept {
311+ fn to_esbmc_irep ( self ) -> Irept {
317312 let mut result = Irept :: default ( ) ;
318313 result. named_subt . insert ( "type" . to_string ( ) , self . stype ) ;
319314 result. named_subt . insert ( "symvalue" . to_string ( ) , self . value ) ;
@@ -330,8 +325,8 @@ impl IrepAdapter for CBMCSymbol {
330325 . named_subt
331326 . insert ( "mode" . to_string ( ) , Irept :: from ( & self . mode ) ) ;
332327
333- let name = esbmcfixes:: fix_name ( self . name . as_str ( ) , entrypoint ) ;
334- let basename = esbmcfixes:: fix_name ( self . base_name . as_str ( ) , entrypoint ) ;
328+ let name = esbmcfixes:: fix_name ( self . name . as_str ( ) ) ;
329+ let basename = esbmcfixes:: fix_name ( self . base_name . as_str ( ) ) ;
335330
336331 assert_ne ! ( basename, "num::verify::checked_unchecked_add_i8" ) ;
337332
@@ -765,6 +760,8 @@ mod tests {
765760 Err ( err) => panic ! ( "Could not get ESBMC bin. {}" , err) ,
766761 } ;
767762 let output = Command :: new ( esbmc)
763+ . arg ( "--function" )
764+ . arg ( "__CPROVER__start" )
768765 . arg ( "--binary" )
769766 . arg ( input_gbf)
770767 . args ( args)
@@ -785,9 +782,9 @@ mod tests {
785782 assert_eq ! ( status, output. status. code( ) . unwrap( ) ) ;
786783 }
787784
788- use crate :: ByteWriter ;
789785 use crate :: cbmc;
790786 use crate :: cbmc2esbmc;
787+ use crate :: ByteWriter ;
791788
792789 fn run_test ( input_c : & str , args : & [ & str ] , expected : i32 ) {
793790 let cargo_dir = match std:: env:: var ( "CARGO_MANIFEST_DIR" ) {
@@ -800,8 +797,7 @@ mod tests {
800797 let esbmc_gbf = format ! ( "{}.esbmc.goto" , input_c) ;
801798
802799 generate_cbmc_gbf ( test_path. to_str ( ) . unwrap ( ) , cbmc_gbf. as_str ( ) ) ;
803-
804- cbmc2esbmc ( "__CPROVER__start" , cbmc_gbf. as_str ( ) , esbmc_gbf. as_str ( ) ) ;
800+ cbmc2esbmc ( cbmc_gbf. as_str ( ) , esbmc_gbf. as_str ( ) ) ;
805801 run_esbmc_gbf ( & esbmc_gbf, args, expected) ;
806802 std:: fs:: remove_file ( & cbmc_gbf) . ok ( ) ;
807803 std:: fs:: remove_file ( & esbmc_gbf) . ok ( ) ;
@@ -816,11 +812,7 @@ mod tests {
816812 std:: path:: Path :: new ( & cargo_dir) . join ( format ! ( "resources/test/{}" , input_goto) ) ;
817813
818814 let esbmc_gbf = format ! ( "{}.goto" , input_goto) ; // TODO: generate UUID!
819- cbmc2esbmc (
820- "__CPROVER__start" ,
821- test_path. to_str ( ) . unwrap ( ) ,
822- esbmc_gbf. as_str ( ) ,
823- ) ;
815+ cbmc2esbmc ( test_path. to_str ( ) . unwrap ( ) , esbmc_gbf. as_str ( ) ) ;
824816 run_esbmc_gbf ( & esbmc_gbf, args, expected) ;
825817 std:: fs:: remove_file ( & esbmc_gbf) . ok ( ) ;
826818 }
0 commit comments