Skip to content

Commit

Permalink
[clang] Turn off the preanalyses for computing captured context
Browse files Browse the repository at this point in the history
Summary: This is because we suspect a perf regression from the preanalyses

Reviewed By: davidpichardie

Differential Revision: D65484949

fbshipit-source-id: a1e810e08018f8e82d628cea5b932b3c435890c7
  • Loading branch information
dulmarod authored and facebook-github-bot committed Nov 6, 2024
1 parent b7d77ec commit 667a6c7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions infer/man/man1/infer-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2636,6 +2636,10 @@ INTERNAL OPTIONS
--complete-capture-from-reset
Cancel the effect of --complete-capture-from.

--compute-captured-context
Activates: Compute context information for captured variables in
Objective-C blocks (Conversely: --no-compute-captured-context)

--config-impact-config-field-patterns +regex
Register known config fields that have a config value. The matched
name contains class and field names, without package names and
Expand Down
7 changes: 7 additions & 0 deletions infer/src/base/Config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,11 @@ and complete_capture_from =
code will be equal to the number of rows added to the capture database."


and compute_captured_context =
CLOpt.mk_bool ~long:"compute-captured-context" ~default:false
"Compute context information for captured variables in Objective-C blocks"


and config_impact_config_field_patterns =
CLOpt.mk_string_list ~long:"config-impact-config-field-patterns" ~meta:"regex"
"Register known config fields that have a config value. The matched name contains class and \
Expand Down Expand Up @@ -4058,6 +4063,8 @@ and compaction_minimum_interval_s = !compaction_minimum_interval_s

and complete_capture_from = !complete_capture_from

and compute_captured_context = !compute_captured_context

and config_impact_config_field_patterns =
RevList.rev_map !config_impact_config_field_patterns ~f:Str.regexp

Expand Down
2 changes: 2 additions & 0 deletions infer/src/base/Config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ val compaction_minimum_interval_s : int

val complete_capture_from : string option

val compute_captured_context : bool

val config_impact_config_field_patterns : Str.regexp list

val config_impact_config_function_patterns : Str.regexp list
Expand Down
12 changes: 7 additions & 5 deletions infer/src/clang/cFrontend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ let do_objc_preanalyses cfg tenv =
CAddImplicitGettersSetters.process cfg tenv ;
CReplaceDynamicDispatch.process cfg ;
CViewControllerLifecycle.process cfg tenv ;
if not Config.preanalysis_html then NodePrinter.print_html := false ;
Timer.time Preanalysis
~f:(fun () -> ComputeCapturedInfo.process cfg)
~on_timeout:(fun span ->
L.debug Capture Quiet "TIMEOUT in ComputeCapturedInfo.process after %fs of CPU time@\n" span )
if Config.compute_captured_context then (
if not Config.preanalysis_html then NodePrinter.print_html := false ;
Timer.time Preanalysis
~f:(fun () -> ComputeCapturedInfo.process cfg)
~on_timeout:(fun span ->
L.debug Capture Quiet "TIMEOUT in ComputeCapturedInfo.process after %fs of CPU time@\n" span )
)


let do_cpp_preanalyses cfg = CppLambdaCalls.process cfg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ codetoanalyze/objc/parameter-not-null-checked/Blocks_as_parameters.m, Blocks_as_
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, blockNotCheckedBadNoAutofix, 0, BLOCK_PARAMETER_NOT_NULL_CHECKED, no_bucket, WARNING, [Parameter `block` of blockNotCheckedBadNoAutofix,Executing `block`]
2 changes: 0 additions & 2 deletions infer/tests/codetoanalyze/objc/self-in-block/issues.exp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
codetoanalyze/objc/self-in-block/CStringUsingEncodingTest.m, objc_block_CStringUsingEncodingTest.m:18, 1, NSSTRING_INTERNAL_PTR_CAPTURED_IN_BLOCK, no_bucket, ERROR, [Captured variable &encoding defined here,Using captured &encoding]
codetoanalyze/objc/self-in-block/CStringUsingEncodingTest.m, objc_block_CStringUsingEncodingTest.m:34, 1, NSSTRING_INTERNAL_PTR_CAPTURED_IN_BLOCK, no_bucket, ERROR, [Captured variable &utf8string defined here,Using captured &utf8string]
codetoanalyze/objc/self-in-block/NoescapeBlock.m, objc_block_NoescapeBlock.m:35, 1, MULTIPLE_WEAKSELF, no_bucket, ERROR, [Using &weakSelf,Using &weakSelf]
codetoanalyze/objc/self-in-block/NoescapeBlock.m, objc_block_NoescapeBlock.m:35, 1, WEAK_SELF_IN_NO_ESCAPE_BLOCK, no_bucket, ERROR, [Using &weakSelf,Using &weakSelf]
codetoanalyze/objc/self-in-block/NoescapeBlock.m, objc_block_NoescapeBlock.m:35, 2, WEAK_SELF_IN_NO_ESCAPE_BLOCK, no_bucket, ERROR, [Using &weakSelf,Using &weakSelf]
Expand Down
1 change: 0 additions & 1 deletion infer/tests/codetoanalyze/objcpp/self-in-block/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ codetoanalyze/objcpp/self-in-block/CxxRefInBlock.mm, objc_block_CxxRefInBlock.mm
codetoanalyze/objcpp/self-in-block/CxxRefInBlock.mm, objc_block_CxxRefInBlock.mm:52, 1, CXX_REF_CAPTURED_IN_BLOCK, no_bucket, ERROR, [Captured variable &y defined here,Using captured &y]
codetoanalyze/objcpp/self-in-block/CxxRefInBlock.mm, objc_block_CxxRefInBlock.mm:114, 1, CXX_REF_CAPTURED_IN_BLOCK, no_bucket, ERROR, [Captured variable &y defined here,Using captured &y]
codetoanalyze/objcpp/self-in-block/CxxRefInBlock.mm, objc_block_CxxRefInBlock.mm:114, 2, CXX_REF_CAPTURED_IN_BLOCK, no_bucket, ERROR, [Captured variable &z defined here,Using captured &z]
codetoanalyze/objcpp/self-in-block/CxxStringInBlock.mm, objc_block_CxxStringInBlock.mm:27, 1, CXX_STRING_CAPTURED_IN_BLOCK, no_bucket, ERROR, [Captured variable &c defined here,Using captured &c]

0 comments on commit 667a6c7

Please sign in to comment.