@ -11,11 +11,12 @@
open ! IStd
(* * mutate the cfg/cg to add dynamic dispatch handling *)
let add_dispatch_calls pdesc cg tenv ~ handle_dynamic_dispatch =
let add_dispatch_calls pdesc cg tenv policy =
let sound_dynamic_dispatch = policy = ` Sound in
let node_add_dispatch_calls caller_pname node =
let call_flags_is_dispatch call_flags =
(* if sound dispatch is turned off, only consider dispatch for interface calls *)
( handle _dynamic_dispatch && call_flags . CallFlags . cf_virtual ) | |
( sound _dynamic_dispatch && call_flags . CallFlags . cf_virtual ) | |
call_flags . CallFlags . cf_interface in
let instr_is_dispatch_call = function
| Sil . Call ( _ , _ , _ , _ , call_flags ) -> call_flags_is_dispatch call_flags
@ -39,7 +40,7 @@ let add_dispatch_calls pdesc cg tenv ~handle_dynamic_dispatch =
( match sorted_overrides with
| ( ( _ , target_pname ) :: _ ) as all_targets ->
let targets_to_add =
if handle _dynamic_dispatch then
if sound _dynamic_dispatch then
IList . map snd all_targets
else
(* if sound dispatch is turned off, consider only the first target. we do this
@ -302,19 +303,17 @@ let do_copy_propagation pdesc tenv =
let do_liveness pdesc tenv =
let liveness_proc_cfg = BackwardCfg . from_pdesc pdesc in
LivenessAnalysis . exec_cfg liveness_proc_cfg ( ProcData . make_default pdesc tenv )
let doit ? ( handle_dynamic_dispatch = ( Config . dynamic_dispatch = ` Sound ) ) pdesc cg tenv =
if not ( Procdesc . did_preanalysis pdesc )
then
begin
Procdesc . signal_did_preanalysis pdesc ;
let liveness_inv_map =
LivenessAnalysis . exec_cfg liveness_proc_cfg ( ProcData . make_default pdesc tenv ) in
if Config . copy_propagation then do_copy_propagation pdesc tenv ;
let liveness_inv_map = do_liveness pdesc tenv in
if Config . dynamic_dispatch < > ` Lazy && Config . copy_propagation
then remove_dead_frontend_stores pdesc liveness_inv_map ;
add_nullify_instrs pdesc tenv liveness_inv_map ;
if Config . dynamic_dispatch < > ` Lazy
then add_dispatch_calls ~ handle_dynamic_dispatch pdesc cg tenv ;
Procdesc . signal_did_preanalysis pdesc
let do_abstraction pdesc =
add_abstraction_instructions pdesc ;
end
Procdesc . signal_did_preanalysis pdesc
let do_dynamic_dispatch pdesc cg tenv policy =
if policy < > ` Lazy
then add_dispatch_calls pdesc cg tenv policy ;
Procdesc . signal_did_preanalysis pdesc