[lock-consistency] Skip prefixes of blacklist entries

Summary:
When fuzzy-matching cpp names, allow to match only a prefix of
blacklist entries.

Reviewed By: da319

Differential Revision: D6233055

fbshipit-source-id: a3a4913
master
Josh Berdine 7 years ago committed by Facebook Github Bot
parent 979c476fa3
commit 2defebe9e7

@ -67,13 +67,14 @@ module Match = struct
let matching_separator = "#"
let regexp_string_of_qualifiers quals =
Str.quote (to_separated_string ~sep:matching_separator quals) ^ "$"
let regexp_string_of_qualifiers ?(prefix= false) quals =
Str.quote (to_separated_string ~sep:matching_separator quals) ^ if prefix then "" else "$"
let qualifiers_list_matcher quals_list =
let qualifiers_list_matcher ?prefix quals_list =
( if List.is_empty quals_list then "a^" (* regexp that does not match anything *)
else List.rev_map ~f:regexp_string_of_qualifiers quals_list |> String.concat ~sep:"\\|" )
else List.rev_map ~f:(regexp_string_of_qualifiers ?prefix) quals_list
|> String.concat ~sep:"\\|" )
|> Str.regexp
@ -89,8 +90,9 @@ module Match = struct
of_qual_string qual_name
let of_fuzzy_qual_names fuzzy_qual_names =
List.rev_map fuzzy_qual_names ~f:qualifiers_of_fuzzy_qual_name |> qualifiers_list_matcher
let of_fuzzy_qual_names ?prefix fuzzy_qual_names =
List.rev_map fuzzy_qual_names ~f:qualifiers_of_fuzzy_qual_name
|> qualifiers_list_matcher ?prefix
let match_qualifiers matcher quals =

@ -81,7 +81,7 @@ val pp : Format.formatter -> t -> unit
module Match : sig
type quals_matcher
val of_fuzzy_qual_names : string list -> quals_matcher
val of_fuzzy_qual_names : ?prefix:bool -> string list -> quals_matcher
val match_qualifiers : quals_matcher -> t -> bool
end

@ -209,17 +209,16 @@ module Models = struct
let should_skip =
let matcher =
lazy
(QualifiedCppName.Match.of_fuzzy_qual_names
[ "folly::AtomicStruct::AtomicStruct"
; "folly::Future::Future"
; "folly::LockedPtr::LockedPtr"
; "folly::Optional::Optional"
; "folly::Optional::hasValue"
; "folly::Promise::Promise"
; "folly::ThreadLocal::ThreadLocal"
; "folly::detail::SingletonHolder::createInstance"
(QualifiedCppName.Match.of_fuzzy_qual_names ~prefix:true
[ "folly::AtomicStruct"
; "folly::Future"
; "folly::LockedPtr"
; "folly::Optional"
; "folly::Promise"
; "folly::ThreadLocal"
; "folly::detail::SingletonHolder"
; "std::atomic"
; "std::vector::vector" ])
; "std::vector" ])
in
function
| Typ.Procname.ObjC_Cpp _ | C _ as pname ->

Loading…
Cancel
Save