[racerd] recognize more class member types as concurrency hints for C++

Summary: Even though we recognize the lock/unlock methods of various classes in C++, to report we insist that the class must have a `mutex` member.  Equalize the two sets of types recognized.

Reviewed By: da319

Differential Revision: D10446527

fbshipit-source-id: f42ae1a35
master
Nikos Gorogiannis 6 years ago committed by Facebook Github Bot
parent 3f969414fe
commit 7e7913d5ee

@ -41,6 +41,19 @@ let get_thread = function
UnknownThread UnknownThread
let cpp_lock_types_matcher =
QualifiedCppName.Match.of_fuzzy_qual_names
[ "apache::thrift::concurrency::ReadWriteMutex"
; "folly::LockedPtr"
; "folly::MicroSpinLock"
; "folly::RWSpinLock"
; "folly::SharedMutex"
(* NB not impl as in [matcher_lock] as this is just a type, not a call *)
; "folly::SpinLock"
; "folly::SpinLockGuard"
; "std::mutex" ]
let get_lock = let get_lock =
let is_cpp_lock = let is_cpp_lock =
let matcher_lock = let matcher_lock =

@ -34,3 +34,5 @@ val get_current_class_and_annotated_superclasses :
val find_annotated_or_overriden_annotated_method : val find_annotated_or_overriden_annotated_method :
(Annot.Item.t -> bool) -> BuiltinDecl.t -> Tenv.t -> BuiltinDecl.t sexp_option (Annot.Item.t -> bool) -> BuiltinDecl.t -> Tenv.t -> BuiltinDecl.t sexp_option
val cpp_lock_types_matcher : QualifiedCppName.Match.quals_matcher

@ -1256,9 +1256,9 @@ let report_unsafe_accesses (aggregated_access_map : ReportMap.t) =
in in
let class_has_mutex_member objc_cpp tenv = let class_has_mutex_member objc_cpp tenv =
let class_name = Typ.Procname.ObjC_Cpp.get_class_type_name objc_cpp in let class_name = Typ.Procname.ObjC_Cpp.get_class_type_name objc_cpp in
let matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["std::mutex"] in let matcher = ConcurrencyModels.cpp_lock_types_matcher in
Option.exists (Tenv.lookup tenv class_name) ~f:(fun class_str -> Option.exists (Tenv.lookup tenv class_name) ~f:(fun class_str ->
(* check if the class contains a member of type std::mutex *) (* check if the class contains a lock member *)
List.exists class_str.Typ.Struct.fields ~f:(fun (_, ft, _) -> List.exists class_str.Typ.Struct.fields ~f:(fun (_, ft, _) ->
Option.exists (Typ.name ft) ~f:(fun name -> Option.exists (Typ.name ft) ~f:(fun name ->
QualifiedCppName.Match.match_qualifiers matcher (Typ.Name.qual_name name) ) ) ) QualifiedCppName.Match.match_qualifiers matcher (Typ.Name.qual_name name) ) ) )
@ -1266,9 +1266,8 @@ let report_unsafe_accesses (aggregated_access_map : ReportMap.t) =
let should_report {tenv; procdesc} = let should_report {tenv; procdesc} =
match Procdesc.get_proc_name procdesc with match Procdesc.get_proc_name procdesc with
| Java _ -> | Java _ ->
List.exists List.exists grouped_accesses ~f:(fun ({threads} : reported_access) ->
~f:(fun ({threads} : reported_access) -> ThreadsDomain.is_any threads) ThreadsDomain.is_any threads )
grouped_accesses
&& should_report_on_proc procdesc tenv && should_report_on_proc procdesc tenv
| ObjC_Cpp objc_cpp -> | ObjC_Cpp objc_cpp ->
(* do not report if a procedure is private *) (* do not report if a procedure is private *)

Loading…
Cancel
Save