[starvation] determine lock recursiveness on language if type unknown

Summary: Sometimes the type definition is missing, especially in not-well supported build systems. When missing, default to true if on Java since you'd have to explicitly select a non-recursive one on purpose, and vice versa for clang.

Reviewed By: jvillard

Differential Revision: D28745172

fbshipit-source-id: 8b0e26e1a
master
Nikos Gorogiannis 4 years ago committed by Facebook GitHub Bot
parent 951cc1f7f9
commit f3ded9e492

@ -128,15 +128,21 @@ module Lock = struct
let is_recursive tenv lock = let is_recursive tenv lock =
let is_class_and_recursive_lock = function (* The "default" below is returned when we don't have enough information. We choose
| {Typ.desc= Tptr ({desc= Tstruct name}, _)} | {desc= Tstruct name} -> the default depending on the language, since most Java locks are recursive and most C++ locks
ConcurrencyModels.is_recursive_lock_type name are not. *)
| typ -> match get_typ tenv lock with
L.debug Analysis Verbose "Asked if non-struct type %a is a recursive lock type.@." | Some {Typ.desc= Tptr ({desc= Tstruct name}, _)} | Some {desc= Tstruct name} ->
(Typ.pp_full Pp.text) typ ; ConcurrencyModels.is_recursive_lock_type name
true | Some typ ->
in (* weird type passed as a lock, return default *)
get_typ tenv lock |> Option.exists ~f:is_class_and_recursive_lock L.debug Analysis Verbose "Asked if non-struct type %a is a recursive lock type.@\n"
(Typ.pp_full Pp.text) typ ;
Language.curr_language_is Java
| None ->
(* could not find type definition, return default *)
L.debug Analysis Verbose "Could not resolve type for lock %a.@\n" pp lock ;
Language.curr_language_is Java
end end
module AccessExpressionDomain = struct module AccessExpressionDomain = struct

Loading…
Cancel
Save