From 88eb380cc38daee251c66535c44d6f244689eb2d Mon Sep 17 00:00:00 2001 From: Qianyi Shu Date: Thu, 17 Sep 2020 05:58:30 -0700 Subject: [PATCH] [cost] fix objc block name comparison Summary: Following the previous diff, the reason we mistakingly introduced new block as complexity increases is because when we are computing the hash of block, we return the string `block` to compute the hash for all block. This diff fixes this case by returning the non-verbose name of the block when returning hashable name. Reviewed By: ezgicicek Differential Revision: D23729710 fbshipit-source-id: a345d3045 --- infer/src/IR/Procname.ml | 3 +++ .../differential_of_costs_report_objc/introduced.exp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml index 9c0ec6808..2a8b3602e 100644 --- a/infer/src/IR/Procname.ml +++ b/infer/src/IR/Procname.ml @@ -637,6 +637,9 @@ let hashable_name proc_name = before the first colon is used for the bug hash *) let name = F.asprintf "%a" (pp_simplified_string ~withclass:true) proc_name in List.hd_exn (String.split name ~on:':') + | Block bsig -> + let name = F.asprintf "%a" (Block.pp Non_verbose) bsig in + List.hd_exn (String.split name ~on:':') | _ -> (* Other cases for C and C++ method names *) F.asprintf "%a" (pp_simplified_string ~withclass:true) proc_name diff --git a/infer/tests/build_systems/differential_of_costs_report_objc/introduced.exp b/infer/tests/build_systems/differential_of_costs_report_objc/introduced.exp index a2c944f4a..e69de29bb 100644 --- a/infer/tests/build_systems/differential_of_costs_report_objc/introduced.exp +++ b/infer/tests/build_systems/differential_of_costs_report_objc/introduced.exp @@ -1 +0,0 @@ -EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffBlock.m, objc_blockHandler.create_block_here:array:call:_2, 0, [Previous Cost of objc_blockHandler.func_linear_1 is 22 (degree is 0),Updated Cost of objc_blockHandler.create_block_here:array:call:_2 is 5 + 5 ⋅ array->elements.length + 4 ⋅ (array->elements.length + 1) (degree is 1),{array->elements.length + 1},Loop]