Skip to content

Commit

Permalink
[lock-consistency] Skip prefixes of blacklist entries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jberdine authored and facebook-github-bot committed Nov 9, 2017
1 parent 979c476 commit 2defebe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
14 changes: 8 additions & 6 deletions infer/src/IR/QualifiedCppName.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion infer/src/IR/QualifiedCppName.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions infer/src/concurrency/RacerDConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 2defebe

Please sign in to comment.