@ -64,6 +64,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
try Some ( IdAccessPathMapDomain . find id id_map )
with Not_found -> None
let is_constant = function
| Exp . Const _ -> true
| _ -> false
let is_owned access_path owned_set =
Domain . AccessPathSetDomain . mem access_path owned_set
@ -105,6 +109,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
is_thread_safe_write ( snd access_path ) tenv in
let f_resolve_id = resolve_id id_map in
if is_constant exp
then
path_state
else
IList . fold_left
( fun acc rawpath ->
if not ( is_owned ( truncate rawpath ) owned ) && not ( is_safe_write rawpath pname tenv )
@ -215,6 +223,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
the current state * )
let add_conditional_writes
( ( cond_writes , uncond_writes ) as acc ) index ( actual_exp , actual_typ ) =
if is_constant actual_exp
then
acc
else
try
let callee_cond_writes_for_index' =
let callee_cond_writes_for_index =
@ -361,7 +373,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
then AccessPathSetDomain . add lhs_access_path access_path_set
else AccessPathSetDomain . remove lhs_access_path access_path_set
| Some lhs_access_path , None ->
AccessPathSetDomain . remove lhs_access_path access_path_set
if is_constant rhs_exp
then AccessPathSetDomain . add lhs_access_path access_path_set
else AccessPathSetDomain . remove lhs_access_path access_path_set
| _ ->
access_path_set in
let owned = update_access_path_set astate . owned in
@ -387,6 +401,11 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
else access_path_set in
propagate_to_lhs astate . owned , propagate_to_lhs astate . functional
| _ ->
if is_constant rhs_exp
then
AccessPathSetDomain . add ( AccessPath . of_id lhs_id rhs_typ ) astate . owned ,
astate . functional
else
astate . owned , astate . functional in
{ astate with Domain . reads ; id_map ; owned ; functional ; }