Summary: Filtering on the SQLite side was done to be more efficient, but these are debug options so it should be fine for them to be not very optimised. Filtering on the OCaml side will allow us to re-use these filtering options for other purposes, such as re-analysing certain procedures only. Reviewed By: mbouaziz Differential Revision: D8767691 fbshipit-source-id: e232660master
parent
5653839540
commit
be855d3589
@ -0,0 +1,43 @@
|
||||
(*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
open! IStd
|
||||
|
||||
let filter_of_regexp_opt ~to_string r =
|
||||
match r with
|
||||
| None ->
|
||||
fun _ -> true
|
||||
| Some regexp ->
|
||||
fun x -> Str.string_match regexp (to_string x) 0
|
||||
|
||||
|
||||
let ( &&& ) filter1 filter2 x1 x2 = filter1 x1 && filter2 x2
|
||||
|
||||
let mk_source_file_filter ~filter =
|
||||
let regexp_opt = Option.map ~f:Str.regexp filter in
|
||||
Staged.stage (filter_of_regexp_opt ~to_string:SourceFile.to_string regexp_opt)
|
||||
|
||||
|
||||
let mk_procedure_name_filter ~filter =
|
||||
let source_file_regexp, proc_name_regexp =
|
||||
match filter with
|
||||
| None ->
|
||||
(None, None)
|
||||
| Some filter_string ->
|
||||
match String.lsplit2 ~on:':' filter_string with
|
||||
| Some (source_file_filter, proc_name_filter) ->
|
||||
(Some (Str.regexp source_file_filter), Some (Str.regexp proc_name_filter))
|
||||
| None ->
|
||||
(* if only one filter is supplied assume it's for procedure names and the source files are
|
||||
a wildcard *)
|
||||
(None, Some (Str.regexp filter_string))
|
||||
in
|
||||
let source_file_filter =
|
||||
filter_of_regexp_opt ~to_string:SourceFile.to_string source_file_regexp
|
||||
in
|
||||
let proc_name_filter = filter_of_regexp_opt ~to_string:Typ.Procname.to_string proc_name_regexp in
|
||||
let filter = source_file_filter &&& proc_name_filter in
|
||||
Staged.stage filter
|
@ -0,0 +1,13 @@
|
||||
(*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val mk_source_file_filter : filter:string option -> (SourceFile.t -> bool) Staged.t
|
||||
|
||||
val mk_procedure_name_filter :
|
||||
filter:string option -> (SourceFile.t -> Typ.Procname.t -> bool) Staged.t
|
Loading…
Reference in new issue