From 163f3c687dce9fef1ca3797d7b9e0131e9202b0c Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 27 May 2020 08:24:07 -0700 Subject: [PATCH] kill Exceptions.Dummy_exception Summary: I think `Analysis_stops` ought to achieve roughly the same thing (except that weird filtering logic which I removed). Reviewed By: dulmarod Differential Revision: D21686562 fbshipit-source-id: 53d40729f --- infer/src/IR/Errlog.ml | 10 ++-------- infer/src/IR/Exceptions.ml | 8 -------- infer/src/IR/Exceptions.mli | 2 -- infer/src/biabduction/RetainCycles.ml | 2 +- .../tests/codetoanalyze/objc/biabduction/issues.exp | 12 ++++++++++++ .../codetoanalyze/objcpp/biabduction/issues.exp | 1 + .../codetoanalyze/objcpp/retain-cycles/issues.exp | 1 + 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index 6885c1a91..55de29530 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -222,16 +222,10 @@ let log_issue severity err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_u | _ -> false in - let report_developer_exn exn = - match exn with Exceptions.Dummy_exception _ -> false | _ -> true - in - let exn_developer = - Exceptions.equal_visibility error.visibility Exceptions.Exn_developer - && report_developer_exn exn - in let should_report = Exceptions.equal_visibility error.visibility Exceptions.Exn_user - || (Config.developer_mode && exn_developer) + || Config.developer_mode + && Exceptions.equal_visibility error.visibility Exceptions.Exn_developer in if should_report && (not hide_java_loc_zero) && not hide_memory_error then let added = diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index 8c6043ab2..21ab496cf 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -48,8 +48,6 @@ exception Condition_always_true_false of Localise.error_desc * bool * L.ocaml_po exception Custom_error of string * Localise.error_desc -exception Dummy_exception of Localise.error_desc - exception Dangling_pointer_dereference of bool (* is it user visible? *) * Localise.error_desc * L.ocaml_pos @@ -206,12 +204,6 @@ let recognize_exception exn = ; ocaml_pos= None ; visibility= Exn_user ; severity= None } - | Dummy_exception desc -> - { issue_type= IssueType.biabduction_analysis_stops - ; description= desc - ; ocaml_pos= None - ; visibility= Exn_developer - ; severity= Some Info } | Dangling_pointer_dereference (user_visible, desc, ocaml_pos) -> let issue_type, visibility = if user_visible then (IssueType.dangling_pointer_dereference, Exn_user) diff --git a/infer/src/IR/Exceptions.mli b/infer/src/IR/Exceptions.mli index ac2f420bf..8a36646e4 100644 --- a/infer/src/IR/Exceptions.mli +++ b/infer/src/IR/Exceptions.mli @@ -48,8 +48,6 @@ exception Condition_always_true_false of Localise.error_desc * bool * Logging.oc exception Custom_error of string * Localise.error_desc -exception Dummy_exception of Localise.error_desc - exception Dangling_pointer_dereference of bool (* is it user visible? *) * Localise.error_desc * Logging.ocaml_pos diff --git a/infer/src/biabduction/RetainCycles.ml b/infer/src/biabduction/RetainCycles.ml index afcf11e9f..b527c161f 100644 --- a/infer/src/biabduction/RetainCycles.ml +++ b/infer/src/biabduction/RetainCycles.ml @@ -248,4 +248,4 @@ let report_cycle {InterproceduralAnalysis.proc_desc; tenv; err_log} prop = BiabductionReporting.log_error_using_state proc_desc err_log exn ) cycles ; (* we report the retain cycles above but need to raise an exception as well to stop the analysis *) - raise (Exceptions.Dummy_exception (Localise.verbatim_desc "retain cycle found")) ) + raise (Exceptions.Analysis_stops (Localise.verbatim_desc "retain cycle found", Some __POS__)) ) diff --git a/infer/tests/codetoanalyze/objc/biabduction/issues.exp b/infer/tests/codetoanalyze/objc/biabduction/issues.exp index bf29ad700..873e65566 100644 --- a/infer/tests/codetoanalyze/objc/biabduction/issues.exp +++ b/infer/tests/codetoanalyze/objc/biabduction/issues.exp @@ -1,7 +1,9 @@ +codetoanalyze/objc/biabduction/field_superclass/field.c, field_superclass_main, 3, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure field_superclass_main()] codetoanalyze/objc/biabduction/field_superclass/field.c, field_superclass_main, 3, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure field_superclass_main()] codetoanalyze/objc/biabduction/global_const/global_const.m, SimpleRoot.doSomethingBadWithDict:andString:, 3, NULL_DEREFERENCE, B2, ERROR, [start of procedure doSomethingBadWithDict:andString:,Message stringByAppendingString: with receiver nil returns nil.] codetoanalyze/objc/biabduction/global_const/global_const.m, SimpleRoot.doSomethingOkWithDict:andString:, 3, NULL_DEREFERENCE, B2, ERROR, [start of procedure doSomethingOkWithDict:andString:,Message stringByAppendingString: with receiver nil returns nil.] codetoanalyze/objc/biabduction/initialization/compound_literal.c, init_with_compound_literal, 2, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure init_with_compound_literal()] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleStaticVar.m, RetainCSV.foo, 13, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure foo,Executing synthesized setter setHandler:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleStaticVar.m, RetainCSV.foo, 13, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure foo,Executing synthesized setter setHandler:] codetoanalyze/objc/biabduction/npe/null_returned_by_method.m, NullReturnedByMethodA.test1, 1, NULL_DEREFERENCE, B5, ERROR, [start of procedure test1,start of procedure test,return from a call to NullReturnedByMethodA.test] codetoanalyze/objc/biabduction/procdescs/main.c, ProcdescMain, 3, MEMORY_LEAK, no_bucket, ERROR, [start of procedure ProcdescMain(),Skipping plusX:andY:: method has no implementation] @@ -28,14 +30,23 @@ codetoanalyze/objc/biabduction/field_superclass/SubtypingExample.m, subtyping_te codetoanalyze/objc/biabduction/initialization/struct_initlistexpr.c, field_set_correctly, 2, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure field_set_correctly()] codetoanalyze/objc/biabduction/initialization/struct_initlistexpr.c, implicit_expr_set_correctly, 3, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure implicit_expr_set_correctly()] codetoanalyze/objc/biabduction/initialization/struct_initlistexpr.c, point_coords_set_correctly, 2, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure point_coords_set_correctly()] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlockAsParameter.m, FBSomeDataManager.fetchNewData, 2, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure fetchNewData,start of procedure initWithCompletionBlock:,return from a call to Fetcher.initWithCompletionBlock:_objc_blockFBSomeDataManager.fetchNewData_1] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlockAsParameter.m, FBSomeDataManager.fetchNewData, 2, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure fetchNewData,start of procedure initWithCompletionBlock:,return from a call to Fetcher.initWithCompletionBlock:_objc_blockFBSomeDataManager.fetchNewData_1] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlockCapturedVar.m, LinkResolver.test_bad, 3, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure test_bad,Executing synthesized setter setDidFinishLoad:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlockCapturedVar.m, LinkResolver.test_bad, 3, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure test_bad,Executing synthesized setter setDidFinishLoad:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlocks.m, RCBlock.retain_self_in_block, 1, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure retain_self_in_block,Executing synthesized setter setHandler:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlocks.m, RCBlock.retain_self_in_block, 1, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure retain_self_in_block,Executing synthesized setter setHandler:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlocks.m, objc_blockretain_a_in_block_cycle_3, 1, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure block,Executing synthesized setter setChild:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlocks.m, objc_blockretain_a_in_block_cycle_3, 1, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure block,Executing synthesized setter setChild:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlocks.m, retain_a_in_block_cycle, 4, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure retain_a_in_block_cycle(),Executing synthesized setter setB:,Executing synthesized setter setA:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleBlocks.m, retain_a_in_block_cycle, 4, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure retain_a_in_block_cycle(),Executing synthesized setter setB:,Executing synthesized setter setA:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleDeduplication.m, CViewController.setCaptureInteractionController:, 4, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure setCaptureInteractionController:,Taking true branch,Executing synthesized setter setDelegate:,Executing synthesized setter setDelegate:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleDeduplication.m, CViewController.setCaptureInteractionController:, 4, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure setCaptureInteractionController:,Taking true branch,Executing synthesized setter setDelegate:,Executing synthesized setter setDelegate:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCyclePropertyInProtocol.m, MyCustomViewController.loadViewBad, 3, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure loadViewBad,Executing synthesized setter setView:,Executing synthesized setter setStrong_delegate:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCyclePropertyInProtocol.m, MyCustomViewController.loadViewBad, 3, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure loadViewBad,Executing synthesized setter setView:,Executing synthesized setter setStrong_delegate:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/retain_cycle.m, strongcycle, 6, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure strongcycle(),Executing synthesized setter setB:,Executing synthesized setter setA:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/retain_cycle.m, strongcycle, 6, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure strongcycle(),Executing synthesized setter setB:,Executing synthesized setter setA:] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/retain_cycle2.m, strongcycle2, 4, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure strongcycle2(),start of procedure init,return from a call to Parent.init,start of procedure init,return from a call to Child.init,start of procedure setChild:,return from a call to Parent.setChild:,start of procedure setParent:,return from a call to Child.setParent:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/retain_cycle2.m, strongcycle2, 4, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure strongcycle2(),start of procedure init,return from a call to Parent.init,start of procedure init,return from a call to Child.init,start of procedure setChild:,return from a call to Parent.setChild:,start of procedure setParent:,return from a call to Child.setParent:] codetoanalyze/objc/biabduction/npe/UpdateDict.m, add_nil_in_dict, 10, NULL_DEREFERENCE, B1, ERROR, [start of procedure add_nil_in_dict(),Skipping dictionaryWithObjectsAndKeys:: method has no implementation] codetoanalyze/objc/biabduction/npe/UpdateDict.m, add_nil_to_array, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure add_nil_to_array()] @@ -75,6 +86,7 @@ codetoanalyze/objc/shared/memory_leaks_benchmark/TollBridgeExample.m, TollBridge codetoanalyze/objc/biabduction/memory_leaks_benchmark/CoreVideoExample.m, CoreVideoExample.cvpixelbuffer_not_released_leak, 1, MEMORY_LEAK, no_bucket, ERROR, [start of procedure cvpixelbuffer_not_released_leak] codetoanalyze/objc/biabduction/memory_leaks_benchmark/NSData_models_tests.m, NSData_models_tests.macForIV:, 2, MEMORY_LEAK, no_bucket, ERROR, [start of procedure macForIV:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/NSString_models_tests.m, StringInitA.hexStringValue, 11, MEMORY_LEAK, no_bucket, ERROR, [start of procedure hexStringValue,Skipping CFStringCreateWithBytesNoCopy(): method has no implementation,Taking false branch] +codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleLength3.m, strongcycle, 6, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure strongcycle(),Executing synthesized setter setB:,Executing synthesized setter setC:,Executing synthesized setter setA:] codetoanalyze/objc/biabduction/memory_leaks_benchmark/RetainCycleLength3.m, strongcycle, 6, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure strongcycle(),Executing synthesized setter setB:,Executing synthesized setter setC:,Executing synthesized setter setA:] codetoanalyze/objc/biabduction/npe/Fraction.m, test_virtual_call, 7, NULL_DEREFERENCE, B1, ERROR, [start of procedure test_virtual_call(),start of procedure setNumerator:,return from a call to Fraction.setNumerator:,start of procedure getNumerator,return from a call to Fraction.getNumerator,Taking true branch] codetoanalyze/objc/biabduction/npe/Npe_with_equal_names.m, EqualNamesTest, 3, NULL_DEREFERENCE, B1, ERROR, [start of procedure EqualNamesTest(),start of procedure meth,return from a call to EqualNamesA.meth] diff --git a/infer/tests/codetoanalyze/objcpp/biabduction/issues.exp b/infer/tests/codetoanalyze/objcpp/biabduction/issues.exp index 543c5a17a..1f3c1797e 100644 --- a/infer/tests/codetoanalyze/objcpp/biabduction/issues.exp +++ b/infer/tests/codetoanalyze/objcpp/biabduction/issues.exp @@ -2,4 +2,5 @@ codetoanalyze/objcpp/biabduction/BlockLfield.mm, A.mOk, 1, PRECONDITION_NOT_FOUN codetoanalyze/objcpp/biabduction/BlockLfield.mm, CFunWithBlockOk, 2, PRECONDITION_NOT_MET, no_bucket, WARNING, [start of procedure CFunWithBlockOk()] codetoanalyze/objcpp/biabduction/BlockLfield.mm, CFunWithBlockOk_objc_blockA.mOk_1, 2, PRECONDITION_NOT_MET, no_bucket, WARNING, [start of procedure CFunWithBlockOk()] codetoanalyze/objcpp/biabduction/c_functions.mm, main, 4, NULL_DEREFERENCE, B5, ERROR, [start of procedure main(),start of procedure autoUpdating,return from a call to A.autoUpdating,start of procedure autoUpdating2,Skipping dispatch_once2(): method has no implementation,return from a call to A.autoUpdating2,Executing synthesized getter block,start of procedure block,return from a call to objc_blockobjc_blockA.autoUpdating_1_2,Message block with receiver nil returns nil.] +codetoanalyze/objcpp/biabduction/retain_cycles/RetainCycleWithStruct.mm, Animation.tracer, 2, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure tracer,start of procedure _State,return from a call to _State::_State,start of procedure initWithAnimation:,Taking true branch,return from a call to Tracer.initWithAnimation:] codetoanalyze/objcpp/biabduction/retain_cycles/RetainCycleWithStruct.mm, Animation.tracer, 2, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure tracer,start of procedure _State,return from a call to _State::_State,start of procedure initWithAnimation:,Taking true branch,return from a call to Tracer.initWithAnimation:] diff --git a/infer/tests/codetoanalyze/objcpp/retain-cycles/issues.exp b/infer/tests/codetoanalyze/objcpp/retain-cycles/issues.exp index 5d8978c27..f323f446c 100644 --- a/infer/tests/codetoanalyze/objcpp/retain-cycles/issues.exp +++ b/infer/tests/codetoanalyze/objcpp/retain-cycles/issues.exp @@ -1 +1,2 @@ +codetoanalyze/objcpp/retain-cycles/ObjCPPStruct.mm, A.aFnBad, 2, BIABDUCTION_ANALYSIS_STOPS, no_bucket, ERROR, [start of procedure aFnBad,start of procedure WeakHolder,return from a call to WeakHolder::WeakHolder] codetoanalyze/objcpp/retain-cycles/ObjCPPStruct.mm, A.aFnBad, 2, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure aFnBad,start of procedure WeakHolder,return from a call to WeakHolder::WeakHolder]