let tmp_to_const iosh sid vi fd nofrm =
if nofrm || check_forms vi.vname forms then
match RD.iosh_lookup iosh vi with
None -> None
| Some(ios) ->
let defido =
try RD.IOS.choose ios
with Not_found -> None in
match defido with None -> None | Some defid ->
match time "getDefRhs" getDefRhs defid with
None -> None
| Some(RD.RDExp({enode = Const c}), _, defiosh) ->
(match RD.getDefIdStmt defid with
None -> (Cilmsg.fatal "tmp_to_const: defid has no statement")
| Some(stm) ->
if ok_to_replace vi iosh sid defiosh stm.sid fd
(RD.RDExp(dummy_exp (Const c)))
then
let same = RD.IOS.for_all (fun defido ->
match defido with None -> false | Some defid ->
match time "getDefRhs" getDefRhs defid with
None -> false
| Some(RD.RDExp({enode = Const c'}),_,defiosh) ->
if Cilutil.equals c c' then
match RD.getDefIdStmt defid with
None -> (Cilmsg.fatal "tmp_to_const: defid has no statement")
| Some(stm) ->
ok_to_replace vi iosh sid defiosh stm.sid fd
(RD.RDExp(dummy_exp (Const c')))
else false
| _ -> false) ios
in
if same
then (tmp_to_const_change := true; Some(new_exp (Const c)))
else None
else None)
| _ -> None
else None