From e49f3f1512b82833ad7387cd862d58db6e969301 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Thu, 22 Aug 2019 03:52:44 -0700 Subject: [PATCH] [racerd] use access expression structure in ownership domain Summary: The access path format forced some weird patterns on this code, simplify using the access expression structure. Reviewed By: ezgicicek Differential Revision: D16960660 fbshipit-source-id: e8faf619e --- infer/src/concurrency/RacerDDomain.ml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/infer/src/concurrency/RacerDDomain.ml b/infer/src/concurrency/RacerDDomain.ml index 04c455ff0..9444b8455 100644 --- a/infer/src/concurrency/RacerDDomain.ml +++ b/infer/src/concurrency/RacerDDomain.ml @@ -356,21 +356,17 @@ module OwnershipDomain = struct (* return the first non-Unowned ownership value found when checking progressively shorter prefixes of [access_exp] *) - let rec get_owned access_exp astate = - let keep_looking (access_exp : AccessExpression.t) astate = - match AccessExpression.truncate access_exp with - | Some (prefix_exp, _) -> - get_owned prefix_exp astate - | None -> - OwnershipAbstractValue.Unowned - in - match find access_exp astate with - | OwnershipAbstractValue.OwnedIf _ as v -> + let rec get_owned (access_exp : AccessExpression.t) astate = + match find_opt access_exp astate with + | Some (OwnershipAbstractValue.OwnedIf _ as v) -> v - | OwnershipAbstractValue.Unowned -> - keep_looking access_exp astate - | exception Caml.Not_found -> - keep_looking access_exp astate + | _ -> ( + match access_exp with + | Base _ -> + OwnershipAbstractValue.Unowned + | AddressOf prefix | Dereference prefix | FieldOffset (prefix, _) | ArrayOffset (prefix, _, _) + -> + get_owned prefix astate ) let rec ownership_of_expr expr ownership =