From 93e42a5a25d5a2d635ccb6173e3359997b47bdeb Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Mon, 27 Aug 2018 11:16:16 -0700 Subject: [PATCH] [eradicate] fix the Ambiguous or-pattern variables under guard warning Summary: The pattern matching could previously be missing some valid cases (in theory). Reviewed By: mbouaziz, jberdine Differential Revision: D9491441 fbshipit-source-id: 2bc1fc1aa --- infer/src/eradicate/typeCheck.ml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/infer/src/eradicate/typeCheck.ml b/infer/src/eradicate/typeCheck.ml index f0c6d62e7..a6d1a331d 100644 --- a/infer/src/eradicate/typeCheck.ml +++ b/infer/src/eradicate/typeCheck.ml @@ -640,20 +640,24 @@ let typecheck_instr tenv calls_this checks (node: Procdesc.Node.t) idenv curr_pn res_typestate := pvar_apply loc (handle_pvar ann b) !res_typestate pvar in let handle_negated_condition cond_node = - let do_instr = function[@warning "-57"] - | Sil.Prune (Exp.BinOp (Binop.Eq, cond_e_, Exp.Const (Const.Cint i)), _, _, _) + let do_instr instr = + let set_flag expression = + let cond_e = Idenv.expand_expr_temps idenv cond_node expression in + match convert_complex_exp_to_pvar cond_node false cond_e typestate' loc with + | Exp.Lvar pvar', _ -> + set_flag pvar' AnnotatedSignature.Nullable false + | _ -> + () + in + match instr with | Sil.Prune (Exp.BinOp (Binop.Eq, Exp.Const (Const.Cint i), cond_e_), _, _, _) - when IntLit.iszero i - -> ( - let cond_e = Idenv.expand_expr_temps idenv cond_node cond_e_ in - match convert_complex_exp_to_pvar cond_node false cond_e typestate' loc with - | Exp.Lvar pvar', _ -> - set_flag pvar' AnnotatedSignature.Nullable false - | _ -> - () ) + when IntLit.iszero i -> + set_flag cond_e_ + | Sil.Prune (Exp.BinOp (Binop.Eq, cond_e_, Exp.Const (Const.Cint i)), _, _, _) + when IntLit.iszero i -> + set_flag cond_e_ | _ -> () - (* FIXME: silenced warning may be legit *) in Instrs.iter ~f:do_instr (Procdesc.Node.get_instrs cond_node) in