[thread-safety][c++] Skip folly::detail::SingletonHolder::createInstance

Summary:
The analyzer currently does not understand the control flow of
Singletons, which leads to false alarms. This diff is an unsound hack
that simply ignores any read or write accesses made when computing the
value of a singleton.

Reviewed By: sblackshear

Differential Revision: D5979639

fbshipit-source-id: 34caecb
master
Josh Berdine 7 years ago committed by Facebook Github Bot
parent b92909fe71
commit c081cef5a5

@ -534,6 +534,16 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
; return_ownership= OwnershipAbstractValue.unowned ; return_ownership= OwnershipAbstractValue.unowned
; return_attributes= AttributeSetDomain.empty } ; return_attributes= AttributeSetDomain.empty }
let cpp_force_skipped =
let matcher =
( lazy
(QualifiedCppName.Match.of_fuzzy_qual_names ["folly::detail::SingletonHolder::createInstance"])
)
in
fun pname ->
QualifiedCppName.Match.match_qualifiers (Lazy.force matcher)
(Typ.Procname.get_qualifiers pname)
let get_summary caller_pdesc callee_pname actuals callee_loc tenv = let get_summary caller_pdesc callee_pname actuals callee_loc tenv =
let get_receiver_ap actuals = let get_receiver_ap actuals =
match List.hd actuals with match List.hd actuals with
@ -544,13 +554,15 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
"Call to %a is marked as a container write, but has no receiver" Typ.Procname.pp "Call to %a is marked as a container write, but has no receiver" Typ.Procname.pp
callee_pname callee_pname
in in
match get_container_access callee_pname tenv with match (get_container_access callee_pname tenv, callee_pname) with
| Some ContainerWrite | Some ContainerWrite, _
-> make_container_access callee_pname ~is_write:true (get_receiver_ap actuals) callee_loc tenv -> make_container_access callee_pname ~is_write:true (get_receiver_ap actuals) callee_loc tenv
| Some ContainerRead | Some ContainerRead, _
-> make_container_access callee_pname ~is_write:false (get_receiver_ap actuals) callee_loc -> make_container_access callee_pname ~is_write:false (get_receiver_ap actuals) callee_loc
tenv tenv
| None | None, Typ.Procname.ObjC_Cpp _ when cpp_force_skipped callee_pname
-> None
| None, _
-> Summary.read_summary caller_pdesc callee_pname -> Summary.read_summary caller_pdesc callee_pname
(* return true if the given procname boxes a primitive type into a reference type *) (* return true if the given procname boxes a primitive type into a reference type *)

Loading…
Cancel
Save