From 9d70339b6181444523b33e547b77e0cc2f54064a Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 10 Jan 2020 05:36:32 -0800 Subject: [PATCH] [starvation] ignore unary ops in lock paths Summary: Try a little bit harder to find an access expression. Reviewed By: ezgicicek Differential Revision: D19344989 fbshipit-source-id: 5925e10cf --- infer/src/concurrency/starvationDomain.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/infer/src/concurrency/starvationDomain.ml b/infer/src/concurrency/starvationDomain.ml index 4b6208b63..5d796a620 100644 --- a/infer/src/concurrency/starvationDomain.ml +++ b/infer/src/concurrency/starvationDomain.ml @@ -115,8 +115,9 @@ module Lock = struct let make_class path typename = {root= Class typename; path} (** convert an expression to a canonical form for a lock identifier *) - let make formal_map = function - | HilExp.AccessExpression access_exp -> ( + let rec make formal_map (hilexp : HilExp.t) = + match hilexp with + | AccessExpression access_exp -> ( let path = HilExp.AccessExpression.to_access_path access_exp in match fst (fst path) with | Var.LogicalVar _ -> @@ -129,12 +130,14 @@ module Lock = struct FormalMap.get_formal_index (fst norm_path) formal_map (* ignores non-formals *) |> Option.map ~f:(make_parameter norm_path) ) - | HilExp.Constant (Const.Cclass class_id) -> + | Constant (Cclass class_id) -> (* this is a synchronized/lock(CLASSNAME.class) construct *) let path = path_of_java_class class_id in let typename = Ident.name_to_string class_id |> Typ.Name.Java.from_string in Some (make_class path typename) - | _ -> + | Cast (_, hilexp) | Exception hilexp | UnaryOperator (_, hilexp, _) -> + make formal_map hilexp + | BinaryOperator _ | Closure _ | Constant _ | Sizeof _ -> None