[liveness] Change the model of assert functions to include the handle failure function to avoid dead store fps

Reviewed By: sblackshear

Differential Revision: D6385289

fbshipit-source-id: 61ef0fd
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent a7c657da56
commit c0f250c45e

@ -61,13 +61,6 @@ end
module CFG = ProcCfg.OneInstrPerNode (ProcCfg.Backward (ProcCfg.Exceptional)) module CFG = ProcCfg.OneInstrPerNode (ProcCfg.Backward (ProcCfg.Exceptional))
module Analyzer = AbstractInterpreter.Make (CFG) (TransferFunctions) module Analyzer = AbstractInterpreter.Make (CFG) (TransferFunctions)
let is_whitelisted_var var =
let whitelisted_vars = ["__assert_file__"; "__assert_fn__"] in
List.exists
~f:(fun whitelisted_var -> String.equal whitelisted_var (Pvar.get_simplified_name var))
whitelisted_vars
let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary = let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary =
let cfg = CFG.from_pdesc proc_desc in let cfg = CFG.from_pdesc proc_desc in
let invariant_map = let invariant_map =
@ -89,7 +82,7 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary =
when not when not
( Pvar.is_frontend_tmp pvar || Pvar.is_return pvar || Pvar.is_global pvar ( Pvar.is_frontend_tmp pvar || Pvar.is_return pvar || Pvar.is_global pvar
|| Domain.mem (Var.of_pvar pvar) live_vars || Procdesc.is_captured_var proc_desc pvar || Domain.mem (Var.of_pvar pvar) live_vars || Procdesc.is_captured_var proc_desc pvar
|| is_whitelisted_var pvar || is_sentinel_exp rhs_exp ) -> || is_sentinel_exp rhs_exp ) ->
let issue_id = IssueType.dead_store.unique_id in let issue_id = IssueType.dead_store.unique_id in
let message = F.asprintf "The value written to %a is never used" (Pvar.pp Pp.text) pvar in let message = F.asprintf "The value written to %a is never used" (Pvar.pp Pp.text) pvar in
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in

@ -1192,9 +1192,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
in in
Some (new_or_alloc_trans trans_state_pri sil_loc si qual_type class_opt selector) Some (new_or_alloc_trans trans_state_pri sil_loc si qual_type class_opt selector)
| _ -> | _ ->
None (* assertions *) None
else if CTrans_models.is_handleFailureInMethod selector then
Some (CTrans_utils.trans_assertion trans_state sil_loc)
else None else None
@ -1265,7 +1263,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
in in
let selector = obj_c_message_expr_info.Clang_ast_t.omei_selector in let selector = obj_c_message_expr_info.Clang_ast_t.omei_selector in
let nname = "Message Call: " ^ selector in let nname = "Message Call: " ^ selector in
let all_res_trans = res_trans_subexpr_list @ [res_trans_call] in let assertion_trans_opt =
if CTrans_models.is_handleFailureInMethod selector then
CTrans_utils.trans_assertion trans_state sil_loc
else empty_res_trans
in
let all_res_trans = res_trans_subexpr_list @ [res_trans_call; assertion_trans_opt] in
let res_trans_to_parent = let res_trans_to_parent =
PriorityNode.compute_results_to_parent trans_state_pri sil_loc nname si all_res_trans PriorityNode.compute_results_to_parent trans_state_pri sil_loc nname si all_res_trans
in in

@ -21,11 +21,6 @@ codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorde
codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorder_FBAudioInputCallbackSimpleAliasing:, 3, PARAMETER_NOT_NULL_CHECKED, [start of procedure FBAudioInputCallbackSimpleAliasing:,Message recordState with receiver nil returns nil.] codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorder_FBAudioInputCallbackSimpleAliasing:, 3, PARAMETER_NOT_NULL_CHECKED, [start of procedure FBAudioInputCallbackSimpleAliasing:,Message recordState with receiver nil returns nil.]
codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorder_init, 2, NULL_DEREFERENCE, [start of procedure init] codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorder_init, 2, NULL_DEREFERENCE, [start of procedure init]
codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorder_test, 3, NULL_DEREFERENCE, [start of procedure test,Message recordState with receiver nil returns nil.] codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m, FBAudioRecorder_test, 3, NULL_DEREFERENCE, [start of procedure test,Message recordState with receiver nil returns nil.]
codetoanalyze/objc/shared/assertions/NSAssert_example.m, NSAssert_addTarget:, 1, MEMORY_LEAK, [start of procedure addTarget:,Condition is false,Condition is true,Condition is true]
codetoanalyze/objc/shared/assertions/NSAssert_example.m, NSAssert_initWithRequest:, 1, MEMORY_LEAK, [start of procedure initWithRequest:,Condition is false,Condition is true,Condition is true]
codetoanalyze/objc/shared/assertions/NSAssert_example.m, test1, 1, MEMORY_LEAK, [start of procedure test1(),Condition is false,Condition is true,Condition is true]
codetoanalyze/objc/shared/assertions/NSAssert_example.m, test1, 1, MEMORY_LEAK, [start of procedure test1(),Condition is false,Condition is true,Condition is true,Condition is true]
codetoanalyze/objc/shared/assertions/NSAssert_example.m, test2, 1, MEMORY_LEAK, [start of procedure test2(),Condition is false,Condition is true,Condition is true]
codetoanalyze/objc/shared/block/BlockVar.m, BlockVar_blockPostBad, 5, NULL_DEREFERENCE, [start of procedure blockPostBad,start of procedure block,return from a call to objc_blockBlockVar_blockPostBad_2] codetoanalyze/objc/shared/block/BlockVar.m, BlockVar_blockPostBad, 5, NULL_DEREFERENCE, [start of procedure blockPostBad,start of procedure block,return from a call to objc_blockBlockVar_blockPostBad_2]
codetoanalyze/objc/shared/block/BlockVar.m, BlockVar_capturedNullDeref, 5, NULL_DEREFERENCE, [start of procedure capturedNullDeref,start of procedure block] codetoanalyze/objc/shared/block/BlockVar.m, BlockVar_capturedNullDeref, 5, NULL_DEREFERENCE, [start of procedure capturedNullDeref,start of procedure block]
codetoanalyze/objc/shared/block/BlockVar.m, BlockVar_navigateToURLInBackground, 8, NULL_DEREFERENCE, [start of procedure navigateToURLInBackground,start of procedure block,start of procedure test,return from a call to BlockVar_test,return from a call to objc_blockBlockVar_navigateToURLInBackground_1,Condition is true] codetoanalyze/objc/shared/block/BlockVar.m, BlockVar_navigateToURLInBackground, 8, NULL_DEREFERENCE, [start of procedure navigateToURLInBackground,start of procedure block,start of procedure test,return from a call to BlockVar_test,return from a call to objc_blockBlockVar_navigateToURLInBackground_1,Condition is true]

Loading…
Cancel
Save