[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_class_and_recursive_lock = function
| {Typ.desc= Tptr ({desc= Tstruct name}, _)} | {desc= Tstruct name} ->
ConcurrencyModels.is_recursive_lock_type name
| typ ->
L.debug Analysis Verbose "Asked if non-struct type %a is a recursive lock type.@."
(Typ.pp_full Pp.text) typ ;
true
in
get_typ tenv lock |> Option.exists ~f:is_class_and_recursive_lock
(* The "default" below is returned when we don't have enough information. We choose
the default depending on the language, since most Java locks are recursive and most C++ locks
are not. *)
match get_typ tenv lock with
| Some {Typ.desc= Tptr ({desc= Tstruct name}, _)} | Some {desc= Tstruct name} ->
ConcurrencyModels.is_recursive_lock_type name
| Some typ ->
(* weird type passed as a lock, return default *)
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
module AccessExpressionDomain = struct

Loading…
Cancel
Save