[clang] fix evaluation order bug discovered by building with OCaml 4.05.0

Summary:
The behaviour of infer was observed to be different in 4.04.2 vs (4.05.0 or
4.04.2+flambda). Investigating further, the behaviour is also different in byte
vs native versions of infer under 4.04.2. Looking at the Changelog of 4.05.0
(thanks mbouaziz), there are fixes for inconsistent behaviours between byte
and native relative to evaluation order.

Lots of debugging later, this 1 line patch is born. Also use `List.concat_map`
instead of re-implementing it.

Reviewed By: jberdine

Differential Revision: D5793809

fbshipit-source-id: 374fb4c
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 740e9973d6
commit 5b3c2c0901

@ -173,21 +173,18 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
(Exp.Var id, typ) (Exp.Var id, typ)
in in
let make_arg typ (id, _, _) = (id, typ) in let make_arg typ (id, _, _) = (id, typ) in
let rec f es = let f = function
match es with | Exp.Closure {name; captured_vars}, ({Typ.desc= Tptr ({Typ.desc= Tfun _}, _)} as t)
| [] -> let function_name = make_function_name t name in
-> [] let args = List.map ~f:(make_arg t) captured_vars in
| (Exp.Closure {name; captured_vars}, ({Typ.desc= Tptr ({Typ.desc= Tfun _}, _)} as t)) :: es' function_name :: args
-> let app = | e
let function_name = make_function_name t name in -> [e]
let args = List.map ~f:(make_arg t) captured_vars in in
function_name :: args (* evaluation order matters here *)
in let exps' = List.concat_map ~f exps in
app @ f es' let insts' = !insts in
| e :: es' (exps', insts')
-> e :: f es'
in
(f exps, !insts)
let collect_exprs res_trans_list = let collect_exprs res_trans_list =
List.concat_map ~f:(fun res_trans -> res_trans.exps) res_trans_list List.concat_map ~f:(fun res_trans -> res_trans.exps) res_trans_list

Loading…
Cancel
Save