From a19e6ce51cd0f81a91998e51c3d60d7bc213bce1 Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Fri, 1 Nov 2024 10:08:44 -0700 Subject: [PATCH] [param-not-null-checked] Add a test that shows a false positive around block parameters Reviewed By: geralt-encore Differential Revision: D65340454 fbshipit-source-id: 2c90033951f74bb668c00b3dfb112766257fd26a --- .../Blocks_as_parameters.m | 12 ++++++++++++ .../objc/parameter-not-null-checked/issues.exp | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/infer/tests/codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m b/infer/tests/codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m index 591c49c8a9..ab74fd2ca4 100644 --- a/infer/tests/codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m +++ b/infer/tests/codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m @@ -6,6 +6,18 @@ */ #import +typedef void (^NewAnnotateBlock1)(const char* _Nullable key, + id _Nullable value); +typedef void (^_Nullable NewAnnotateSyncBlock1)(NewAnnotateBlock1 annotate); + +void MarkerAnnotateSync1(NS_NOESCAPE _Nullable NewAnnotateSyncBlock1 block) {} + +void testAnnotateOk_FP(NSString* composerSessionID) { + MarkerAnnotateSync1(^(NewAnnotateBlock1 annotate) { + annotate("composer_session_id", composerSessionID); + }); +} + typedef void (^MyBlock)(); typedef void (^MyBlock1)(int x); diff --git a/infer/tests/codetoanalyze/objc/parameter-not-null-checked/issues.exp b/infer/tests/codetoanalyze/objc/parameter-not-null-checked/issues.exp index 20c226411c..06eaf809d9 100644 --- a/infer/tests/codetoanalyze/objc/parameter-not-null-checked/issues.exp +++ b/infer/tests/codetoanalyze/objc/parameter-not-null-checked/issues.exp @@ -1,8 +1,10 @@ -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.blockNotCheckedBad:and:, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of Blocks_as_parameters.blockNotCheckedBad:and:,Executing `block`], "block("=>"BLOCK_CALL_SAFE(block"@20:3 -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.blockNotCheckedBad1:and:, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of Blocks_as_parameters.blockNotCheckedBad1:and:,Executing `block`], "block("=>"BLOCK_CALL_SAFE(block, "@24:3 -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:, 2, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block1` of Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:,Executing `block1`], "block1("=>"BLOCK_CALL_SAFE(block1"@41:5 -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:, 3, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block2` of Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:,Executing `block2`], "block2("=>"BLOCK_CALL_SAFE(block2"@42:5 -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.nonnullBlockTwoBlocksBad:and:and:, 4, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block2` of Blocks_as_parameters.nonnullBlockTwoBlocksBad:and:and:,Executing `block2`], "block2("=>"BLOCK_CALL_SAFE(block2"@70:3 -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.blockCheckedAssignNULLBad:and:, 3, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of Blocks_as_parameters.blockCheckedAssignNULLBad:and:,Checking `block` for nil,Assigned,Executing `block`], "block("=>"BLOCK_CALL_SAFE(block"@76:5 -codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, objc_block_Blocks_as_parameters.m:109, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `completion` of Blocks_as_parameters.uploadTaskWithRequestBad:fromFile:delegate:delegateQueue:completion:,Executing `completion`], "completion("=>"BLOCK_CALL_SAFE(completion"@110:5 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, objc_block_Blocks_as_parameters.m:16, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `annotate` of objc_block_Blocks_as_parameters.m:16,Executing `annotate`], "annotate("=>"BLOCK_CALL_SAFE(annotate, "@17:5 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.blockNotCheckedBad:and:, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of Blocks_as_parameters.blockNotCheckedBad:and:,Executing `block`], "block("=>"BLOCK_CALL_SAFE(block"@32:3 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.blockNotCheckedBad1:and:, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of Blocks_as_parameters.blockNotCheckedBad1:and:,Executing `block`], "block("=>"BLOCK_CALL_SAFE(block, "@36:3 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:, 2, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block1` of Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:,Executing `block1`], "block1("=>"BLOCK_CALL_SAFE(block1"@53:5 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:, 3, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block2` of Blocks_as_parameters.twoBlocksNotCheckedBad:and:and:,Executing `block2`], "block2("=>"BLOCK_CALL_SAFE(block2"@54:5 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.nonnullBlockTwoBlocksBad:and:and:, 4, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block2` of Blocks_as_parameters.nonnullBlockTwoBlocksBad:and:and:,Executing `block2`], "block2("=>"BLOCK_CALL_SAFE(block2"@82:3 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_parameters.blockCheckedAssignNULLBad:and:, 3, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of Blocks_as_parameters.blockCheckedAssignNULLBad:and:,Checking `block` for nil,Assigned,Executing `block`], "block("=>"BLOCK_CALL_SAFE(block"@88:5 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, objc_block_Blocks_as_parameters.m:121, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `completion` of Blocks_as_parameters.uploadTaskWithRequestBad:fromFile:delegate:delegateQueue:completion:,Executing `completion`], "completion("=>"BLOCK_CALL_SAFE(completion"@122:5 +codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, objc_block_Blocks_as_parameters.m:213, 1, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `annotate` of objc_block_Blocks_as_parameters.m:213,Executing `annotate`], "annotate("=>"BLOCK_CALL_SAFE(annotate, "@214:5 codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, blockNotCheckedBadNoAutofix, 0, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of blockNotCheckedBadNoAutofix,Executing `block`]