From f303c9fa8769b951f5d2f8335d7a3ccb2c9e79dd Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Thu, 7 Nov 2019 07:20:35 -0800 Subject: [PATCH] [self in block] Fix error in choosing variables fmor the domain for reporting Reviewed By: ngorogiannis Differential Revision: D18353619 fbshipit-source-id: c4f996269 --- infer/src/checkers/SelfInBlock.ml | 6 ++++-- infer/tests/codetoanalyze/objc/self-in-block/StrongSelf.m | 1 + infer/tests/codetoanalyze/objc/self-in-block/issues.exp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/infer/src/checkers/SelfInBlock.ml b/infer/src/checkers/SelfInBlock.ml index 0b10e1f42..528c675f7 100644 --- a/infer/src/checkers/SelfInBlock.ml +++ b/infer/src/checkers/SelfInBlock.ml @@ -80,10 +80,12 @@ let make_trace_elements domain = let report_issues summary domain = let weakSelf_opt = - TransferFunctions.Domain.find_first_opt (fun {kind} -> DomainData.is_weak_self kind) domain + TransferFunctions.Domain.filter (fun {kind} -> DomainData.is_weak_self kind) domain + |> TransferFunctions.Domain.choose_opt in let self_opt = - TransferFunctions.Domain.find_first_opt (fun {kind} -> DomainData.is_self kind) domain + TransferFunctions.Domain.filter (fun {kind} -> DomainData.is_self kind) domain + |> TransferFunctions.Domain.choose_opt in match (weakSelf_opt, self_opt) with | Some {pvar= weakSelf; loc= weakLoc}, Some {pvar= self; loc= selfLoc} -> diff --git a/infer/tests/codetoanalyze/objc/self-in-block/StrongSelf.m b/infer/tests/codetoanalyze/objc/self-in-block/StrongSelf.m index f104efce7..86779d855 100644 --- a/infer/tests/codetoanalyze/objc/self-in-block/StrongSelf.m +++ b/infer/tests/codetoanalyze/objc/self-in-block/StrongSelf.m @@ -27,6 +27,7 @@ if (strongSelf) { [strongSelf foo]; int x = self->x; // bug here + [self foo]; } return 0; }; diff --git a/infer/tests/codetoanalyze/objc/self-in-block/issues.exp b/infer/tests/codetoanalyze/objc/self-in-block/issues.exp index b3407516b..e27ae9926 100644 --- a/infer/tests/codetoanalyze/objc/self-in-block/issues.exp +++ b/infer/tests/codetoanalyze/objc/self-in-block/issues.exp @@ -1 +1 @@ -codetoanalyze/objc/self-in-block/StrongSelf.m, objc_blockSelfInBlockTest::mixSelfWeakSelf_bad_1, 4, MIXED_SELF_WEAKSELF, no_bucket, ERROR, [Using &weakSelf,Using &self] +codetoanalyze/objc/self-in-block/StrongSelf.m, objc_blockSelfInBlockTest::mixSelfWeakSelf_bad_1, 4, MIXED_SELF_WEAKSELF, no_bucket, ERROR, [Using &weakSelf,Using &self,Using &self]