@ -246,11 +246,11 @@ let collect_preconditions pname tenv proc_name : Prop.normal Specs.Jprop.t list
(* =============== START of symbolic execution =============== *)
(* =============== START of symbolic execution =============== *)
(* propagate a set of results to the given node *)
(* propagate a set of results to the given node *)
let propagate p roc_desc is_exception ( pset : Paths . PathSet . t ) ( curr_node : Cfg . node ) =
let propagate p name is_exception ( pset : Paths . PathSet . t ) ( curr_node : Cfg . node ) =
let edgeset_todo =
let edgeset_todo =
let f prop path edgeset_curr = (* * prop must be a renamed prop by the invariant preserved by PropSet *)
let f prop path edgeset_curr = (* * prop must be a renamed prop by the invariant preserved by PropSet *)
let exn_opt =
let exn_opt =
if is_exception then Some ( Tabulation . prop_get_exn_name p roc_desc prop )
if is_exception then Some ( Tabulation . prop_get_exn_name p name prop )
else None in
else None in
Paths . PathSet . add_renamed_prop prop ( Paths . Path . extend curr_node exn_opt ( State . get_session () ) path ) edgeset_curr in
Paths . PathSet . add_renamed_prop prop ( Paths . Path . extend curr_node exn_opt ( State . get_session () ) path ) edgeset_curr in
Paths . PathSet . fold f pset Paths . PathSet . empty in
Paths . PathSet . fold f pset Paths . PathSet . empty in
@ -263,7 +263,7 @@ let propagate_nodes_divergence
( path : Paths . Path . t ) ( kind_curr_node : Cfg . Node . nodekind ) ( _ succ_nodes : Cfg . node list )
( path : Paths . Path . t ) ( kind_curr_node : Cfg . Node . nodekind ) ( _ succ_nodes : Cfg . node list )
( exn_nodes : Cfg . node list ) =
( exn_nodes : Cfg . node list ) =
let pname = Cfg . Procdesc . get_proc_name pdesc in
let pname = Cfg . Procdesc . get_proc_name pdesc in
let pset_exn , pset_ok = Paths . PathSet . partition ( Tabulation . prop_is_exn p desc ) pset in
let pset_exn , pset_ok = Paths . PathSet . partition ( Tabulation . prop_is_exn p name ) pset in
let succ_nodes = match State . get_goto_node () with (* handle Sil.Goto_node target, if any *)
let succ_nodes = match State . get_goto_node () with (* handle Sil.Goto_node target, if any *)
| Some node_id ->
| Some node_id ->
list_filter ( fun n -> Cfg . Node . get_id n = node_id ) _ succ_nodes
list_filter ( fun n -> Cfg . Node . get_id n = node_id ) _ succ_nodes
@ -281,17 +281,17 @@ let propagate_nodes_divergence
Paths . PathSet . map mk_incons diverging_states in
Paths . PathSet . map mk_incons diverging_states in
( L . d_strln_color Orange ) " Propagating Divergence -- diverging states: " ;
( L . d_strln_color Orange ) " Propagating Divergence -- diverging states: " ;
Propgraph . d_proplist Prop . prop_emp ( Paths . PathSet . to_proplist prop_incons ) ; L . d_ln () ;
Propgraph . d_proplist Prop . prop_emp ( Paths . PathSet . to_proplist prop_incons ) ; L . d_ln () ;
propagate p desc false prop_incons exit_node
propagate p name false prop_incons exit_node
end ;
end ;
list_iter ( propagate p desc false pset_ok ) succ_nodes ;
list_iter ( propagate p name false pset_ok ) succ_nodes ;
list_iter ( propagate p desc true pset_exn ) exn_nodes
list_iter ( propagate p name true pset_exn ) exn_nodes
(* ===================== END of symbolic execution ===================== *)
(* ===================== END of symbolic execution ===================== *)
(* =============== START of forward_tabulate =============== *)
(* =============== START of forward_tabulate =============== *)
(* * Symbolic execution for a Join node *)
(* * Symbolic execution for a Join node *)
let do_symexec_join p roc_desc tenv curr_node ( edgeset_todo : Paths . PathSet . t ) =
let do_symexec_join p name tenv curr_node ( edgeset_todo : Paths . PathSet . t ) =
let curr_pdesc = Cfg . Node . get_proc_desc curr_node in
let curr_pdesc = Cfg . Node . get_proc_desc curr_node in
let curr_pname = Cfg . Procdesc . get_proc_name curr_pdesc in
let curr_pname = Cfg . Procdesc . get_proc_name curr_pdesc in
let curr_id = Cfg . Node . get_id curr_node in
let curr_id = Cfg . Node . get_id curr_node in
@ -303,7 +303,7 @@ let do_symexec_join proc_desc tenv curr_node (edgeset_todo : Paths.PathSet.t) =
list_iter ( fun node ->
list_iter ( fun node ->
Paths . PathSet . iter ( fun prop path ->
Paths . PathSet . iter ( fun prop path ->
State . set_path path None ;
State . set_path path None ;
propagate p roc_desc false ( Paths . PathSet . from_renamed_list [ ( prop , path ) ] ) node )
propagate p name false ( Paths . PathSet . from_renamed_list [ ( prop , path ) ] ) node )
new_dset' ) succ_nodes
new_dset' ) succ_nodes
let prop_max_size = ref ( 0 , Prop . prop_emp )
let prop_max_size = ref ( 0 , Prop . prop_emp )
@ -549,7 +549,7 @@ let forward_tabulate cfg tenv =
L . d_ln () ; L . d_ln () ;
L . d_ln () ; L . d_ln () ;
match kind_curr_node with
match kind_curr_node with
| Cfg . Node . Join_node -> do_symexec_join proc_ desc tenv curr_node pathset_todo
| Cfg . Node . Join_node -> do_symexec_join proc_ name tenv curr_node pathset_todo
| Cfg . Node . Stmt_node _
| Cfg . Node . Stmt_node _
| Cfg . Node . Prune_node _
| Cfg . Node . Prune_node _
| Cfg . Node . Exit_node _
| Cfg . Node . Exit_node _
@ -940,10 +940,10 @@ let reset_global_counters cfg proc_name proc_desc =
set_current_language cfg proc_desc
set_current_language cfg proc_desc
(* Collect all pairs of the kind ( precondition, exception ) from a summary *)
(* Collect all pairs of the kind ( precondition, exception ) from a summary *)
let exception_preconditions tenv p desc summary =
let exception_preconditions tenv p name summary =
let collect_exceptions pre exns ( prop , path ) =
let collect_exceptions pre exns ( prop , path ) =
if Tabulation . prop_is_exn p desc prop then
if Tabulation . prop_is_exn p name prop then
let exn_name = Tabulation . prop_get_exn_name p desc prop in
let exn_name = Tabulation . prop_get_exn_name p name prop in
if AndroidFramework . is_runtime_exception tenv exn_name then
if AndroidFramework . is_runtime_exception tenv exn_name then
( pre , exn_name ) :: exns
( pre , exn_name ) :: exns
else exns
else exns
@ -984,19 +984,19 @@ let remove_this_not_null prop =
(* * Detects if there are specs of the form {precondition} proc {runtime exception} and report
(* * Detects if there are specs of the form {precondition} proc {runtime exception} and report
an error in that case , generating the trace that lead to the runtime exception if the method is
an error in that case , generating the trace that lead to the runtime exception if the method is
called in the context { precondition } * )
called in the context { precondition } * )
let report_runtime_exceptions tenv cfg p roc_ desc summary =
let report_runtime_exceptions tenv cfg p desc summary =
let p roc_ name = Specs . get_proc_name summary in
let p name = Specs . get_proc_name summary in
let is_public_method =
let is_public_method =
( Specs . get_attributes summary ) . Sil . access = Sil . Public in
( Specs . get_attributes summary ) . Sil . access = Sil . Public in
let is_main =
let is_main =
is_public_method
is_public_method
(* TODO ( #4559939 ) : add check for static method *)
(* TODO ( #4559939 ) : add check for static method *)
&& Procname . is_java p roc_ name
&& Procname . is_java p name
&& ( Procname . java_get_method p roc_ name) = " main " in
&& ( Procname . java_get_method p name) = " main " in
let is_annotated =
let is_annotated =
let annotated_signature =
let annotated_signature =
Annotations . get_annotated_signature
Annotations . get_annotated_signature
Specs . proc_get_method_annotation p roc_ desc p roc_ name in
Specs . proc_get_method_annotation p desc p name in
let ret_annotation , _ = annotated_signature . Annotations . ret in
let ret_annotation , _ = annotated_signature . Annotations . ret in
Annotations . ia_is_verify ret_annotation in
Annotations . ia_is_verify ret_annotation in
let is_unavoidable pre =
let is_unavoidable pre =
@ -1011,10 +1011,10 @@ let report_runtime_exceptions tenv cfg proc_desc summary =
if should_report pre then
if should_report pre then
let pre_str =
let pre_str =
Utils . pp_to_string ( Prop . pp_prop pe_text ) ( Specs . Jprop . to_prop pre ) in
Utils . pp_to_string ( Prop . pp_prop pe_text ) ( Specs . Jprop . to_prop pre ) in
let exn_desc = Localise . java_unchecked_exn_desc p roc_ name runtime_exception pre_str in
let exn_desc = Localise . java_unchecked_exn_desc p name runtime_exception pre_str in
let exn = Exceptions . Java_runtime_exception ( runtime_exception , pre_str , exn_desc ) in
let exn = Exceptions . Java_runtime_exception ( runtime_exception , pre_str , exn_desc ) in
Reporting . log_error p roc_ name ~ pre : ( Some ( Specs . Jprop . to_prop pre ) ) exn in
Reporting . log_error p name ~ pre : ( Some ( Specs . Jprop . to_prop pre ) ) exn in
list_iter report ( exception_preconditions tenv p roc_desc summary )
list_iter report ( exception_preconditions tenv p name summary )
(* * update a summary after analysing a procedure *)
(* * update a summary after analysing a procedure *)