From bd22999950ace855f4c76cd878d7ee41c3275d0b Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Wed, 5 Oct 2016 05:48:34 -0700 Subject: [PATCH] [clang] Disable the condition always true or false check for clang as it is too noisy. Reviewed By: jvillard Differential Revision: D3967565 fbshipit-source-id: b81ea0c --- infer/src/backend/symExec.ml | 40 +++++++++++++++++++----------------- infer/src/base/Config.ml | 2 ++ infer/src/base/Config.mli | 1 + 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index 8b6cf5f6b..16ef734ac 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -1039,25 +1039,27 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path | Sil.Prune (cond, loc, true_branch, ik) -> let prop__ = Attribute.nullify_exp_with_objc_null tenv prop_ cond in let check_condition_always_true_false () = - let report_condition_always_true_false i = - let skip_loop = match ik with - | Sil.Ik_while | Sil.Ik_for -> - not (IntLit.iszero i) (* skip wile(1) and for (;1;) *) - | Sil.Ik_dowhile -> - true (* skip do..while *) - | Sil.Ik_land_lor -> - true (* skip subpart of a condition obtained from compilation of && and || *) - | _ -> false in - true_branch && not skip_loop in - match Prop.exp_normalize_prop tenv Prop.prop_emp cond with - | Exp.Const (Const.Cint i) when report_condition_always_true_false i -> - let node = State.get_node () in - let desc = Errdesc.explain_condition_always_true_false tenv i cond node loc in - let exn = - Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__) in - let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop current_pname) in - Reporting.log_warning current_pname ?pre:pre_opt exn - | _ -> () in + if !Config.curr_language <> Config.Clang || + Config.report_condition_always_true_in_clang then + let report_condition_always_true_false i = + let skip_loop = match ik with + | Sil.Ik_while | Sil.Ik_for -> + not (IntLit.iszero i) (* skip wile(1) and for (;1;) *) + | Sil.Ik_dowhile -> + true (* skip do..while *) + | Sil.Ik_land_lor -> + true (* skip subpart of a condition obtained from compilation of && and || *) + | _ -> false in + true_branch && not skip_loop in + match Prop.exp_normalize_prop tenv Prop.prop_emp cond with + | Exp.Const (Const.Cint i) when report_condition_always_true_false i -> + let node = State.get_node () in + let desc = Errdesc.explain_condition_always_true_false tenv i cond node loc in + let exn = + Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__) in + let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop current_pname) in + Reporting.log_warning current_pname ?pre:pre_opt exn + | _ -> () in if not Config.report_runtime_exceptions then check_already_dereferenced tenv current_pname cond prop__; check_condition_always_true_false (); diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index fb79740f4..824518f3c 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -107,6 +107,8 @@ let checks_disabled_by_default = [ let clang_build_output_dir_name = "build_output" +let report_condition_always_true_in_clang = false + (** Experimental: if true do some specialized analysis of concurrent constructs. *) let csl_analysis = true diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index d34e4d2a2..2ca45db14 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -68,6 +68,7 @@ val buck_generated_folder : string val buck_infer_deps_file_name : string val captured_dir_name : string val checks_disabled_by_default : string list +val report_condition_always_true_in_clang : bool val clang_build_output_dir_name : string val cpp_models_dir : string val csl_analysis : bool