Skip to content

Commit b61ab57

Browse files
committed
CHB:delegate trusted-os-cmd-fmt-arg-string
1 parent 8c9d747 commit b61ab57

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

‎CodeHawk/CHB/bchlib/bCHFunctionPODischarge.ml‎

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ let buffer_writer_callsite
147147
~msg:(p2s loc#toPretty)
148148
__FILE__ __LINE__
149149
["xpr: " ^ (x2s xpr);
150-
"memvar: " ^ (p2s memvar#toPretty)];
150+
"memvar: " ^ (p2s memvar#toPretty);
151+
"stackslot: " ^ (slot#name ^ "@" ^ (string_of_int slot#offset))];
151152
None
152153
end
153154
| _ ->
@@ -373,7 +374,8 @@ let discharge_trusted_os_cmd_fmt_string
373374
~tag:"discharge_trusted_os_cmd_fmt_string"
374375
~msg:(p2s loc#toPretty)
375376
__FILE__ __LINE__
376-
["x: " ^ (x2s x)];
377+
["x: " ^ (x2s x);
378+
"fmtarg count: " ^ (string_of_int (List.length fmtargs))];
377379
status
378380
end
379381
| _ ->
@@ -400,7 +402,7 @@ let trusted_os_cmd_fmt_arg_string_return_value_postcondition
400402
(_quotes: quote_status_t)
401403
(_optlen: int option): po_status_t =
402404
match x with
403-
| XVar v when finfo#env#is_return_value v ->
405+
| XVar v when finfo#env#is_return_value v || finfo#env#is_sideeffect_value v ->
404406
TR.tfold
405407
~ok:(fun callsite ->
406408
let ctinfo = finfo#get_call_target callsite in
@@ -425,12 +427,31 @@ let trusted_os_cmd_fmt_arg_string_return_value_postcondition
425427

426428

427429
let trusted_os_cmd_fmt_arg_string_delegate_local
428-
(_finfo: function_info_int)
429-
(_loc: location_int)
430-
(_x: xpr_t)
431-
(_quotes: quote_status_t)
432-
(_optlen: int option): po_status_t =
433-
Open
430+
(finfo: function_info_int)
431+
(loc: location_int)
432+
(xpr: xpr_t)
433+
(quotes: quote_status_t)
434+
(optlen: int option): po_status_t =
435+
match buffer_writer_callsite finfo loc xpr with
436+
| None ->
437+
begin
438+
log_diagnostics_result
439+
~tag:"trusted_os_cmd_fmt_arg_string_delegate_local:open"
440+
~msg:(p2s loc#toPretty)
441+
__FILE__ __LINE__
442+
["finfo: " ^ finfo#get_name; "xpr: " ^ (x2s xpr)];
443+
Open
444+
end
445+
| Some defloc ->
446+
let deffloc = BCHFloc.get_finfo_floc finfo defloc in
447+
if call_writes_to_buffer deffloc xpr then
448+
begin
449+
let new_xpo = XPOTrustedOsCmdFmtArgString (xpr, quotes, optlen) in
450+
finfo#proofobligations#add_proofobligation defloc#ci new_xpo Open;
451+
DelegatedLocal (defloc#ci, new_xpo)
452+
end
453+
else
454+
Open
434455

435456

436457
let discharge_trusted_os_cmd_fmt_arg_string

0 commit comments

Comments
 (0)