[SelfInBlock] Fixing bugs in checking nullable annotation when reporting strongSelfNotChecked

Summary: Fixing bugs in the report_unchecked_strongself_issues_on_args function: we were not recursing if the first arg wasn't a var, and we were not removing the annotations from self in instance methods. Here we fix those issues.

Reviewed By: ngorogiannis

Differential Revision: D19662886

fbshipit-source-id: 03820961e
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent 239a5302f6
commit af380708aa

@ -294,26 +294,33 @@ module TransferFunctions = struct
(F.sprintf "passed to %s" (Procname.to_simplified_string pname)) (F.sprintf "passed to %s" (Procname.to_simplified_string pname))
var var
in in
let rec report_on_non_nullable_arg ?(annots = []) args = let rec report_on_non_nullable_arg ?annotations args =
match (annots, args) with match (annotations, args) with
| annot :: annot_rest, (Exp.Var var, _) :: rest when not (Annotations.ia_is_nullable annot) -> | Some (annot :: annot_rest), (arg, _) :: rest ->
report_issue var ; ( match arg with
report_on_non_nullable_arg ~annots:annot_rest rest | Exp.Var var when not (Annotations.ia_is_nullable annot) ->
| [], (Exp.Var var, _) :: rest -> report_issue var
report_issue var ; report_on_non_nullable_arg rest | _ ->
() ) ;
report_on_non_nullable_arg ~annotations:annot_rest rest
| None, (arg, _) :: rest ->
(match arg with Exp.Var var -> report_issue var | _ -> ()) ;
report_on_non_nullable_arg rest
| _ -> | _ ->
() ()
in in
let proc_desc_opt = Ondemand.get_proc_desc pname in let proc_desc_opt = Ondemand.get_proc_desc pname in
let annotations = get_annotations proc_desc_opt in
let args = let args =
if is_objc_instance proc_desc_opt then match args with _ :: rest -> rest | [] -> [] if is_objc_instance proc_desc_opt then match args with _ :: rest -> rest | [] -> []
else args else args
in in
match get_annotations proc_desc_opt with let annotations =
| Some annotations -> if is_objc_instance proc_desc_opt then
report_on_non_nullable_arg ~annots:annotations args match annotations with Some (_ :: rest) -> Some rest | _ -> annotations
| None -> else annotations
report_on_non_nullable_arg args in
report_on_non_nullable_arg ?annotations args
let exec_instr (astate : Domain.t) {ProcData.summary} _cfg_node (instr : Sil.instr) = let exec_instr (astate : Domain.t) {ProcData.summary} _cfg_node (instr : Sil.instr) =

Loading…
Cancel
Save