[bug hash] Location independent procname

Summary: In cpp, lambda's operator() name includes line and column numbers which were not ignore in proc name when computing bug hash.

Reviewed By: ngorogiannis

Differential Revision: D24890545

fbshipit-source-id: 95e6735f3
master
Daiva Naudziuniene 4 years ago committed by Facebook GitHub Bot
parent 0eb686aad4
commit 82778eedde

@ -28,23 +28,31 @@ let compute_key (bug_type : string) (proc_name : Procname.t) (filename : string)
String.concat ~sep:"|" [base_filename; simple_procedure_name; bug_type] String.concat ~sep:"|" [base_filename; simple_procedure_name; bug_type]
let compute_hash ~(severity : string) ~(bug_type : string) ~(proc_name : Procname.t) let compute_hash =
~(file : string) ~(qualifier : string) = let num_regexp = Re.Str.regexp "\\(:\\)[0-9]+" in
let base_filename = Filename.basename file in let qualifier_regexp = Re.Str.regexp "\\(line \\|column \\|:\\|parameter \\|\\$\\)[0-9]+" in
let hashable_procedure_name = Procname.hashable_name proc_name in fun ~(severity : string) ~(bug_type : string) ~(proc_name : Procname.t) ~(file : string)
let location_independent_qualifier = ~(qualifier : string) ->
(* Removing the line,column, line and column in lambda's name let base_filename = Filename.basename file in
(e.g. test::lambda.cpp:10:15::operator()), let hashable_procedure_name = Procname.hashable_name proc_name in
and infer temporary variable (e.g., n$67) information from the let location_independent_proc_name =
error message as well as the index of the annonymmous class to make the hash invariant Re.Str.global_replace num_regexp "$_" hashable_procedure_name
when moving the source code in the file *) in
Str.global_replace let location_independent_qualifier =
(Str.regexp "\\(line \\|column \\|:\\|parameter \\|\\$\\)[0-9]+") (* Removing the line,column, line and column in lambda's name
"$_" qualifier (e.g. test::lambda.cpp:10:15::operator()),
in and infer temporary variable (e.g., n$67) information from the
Utils.better_hash error message as well as the index of the annonymmous class to make the hash invariant
(severity, bug_type, hashable_procedure_name, base_filename, location_independent_qualifier) when moving the source code in the file *)
|> Caml.Digest.to_hex Re.Str.global_replace qualifier_regexp "$_" qualifier
in
Utils.better_hash
( severity
, bug_type
, location_independent_proc_name
, base_filename
, location_independent_qualifier )
|> Caml.Digest.to_hex
let loc_trace_to_jsonbug_record trace_list ekind = let loc_trace_to_jsonbug_record trace_list ekind =

Loading…
Cancel
Save