From 8ede47649c2d4bb40ac82835ca1869d0fb41d868 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Wed, 11 Mar 2020 11:13:10 -0700 Subject: [PATCH] [java][procname] always return pointer types to objects Summary: `Procname.Java.get_return_typ` is buggy because whenever faced with an array of objects, it returns a type that implies the object is stored by value in the array (this is correct behaviour only when the element type is primitive, not when it's an object type). Reviewed By: ezgicicek Differential Revision: D20384403 fbshipit-source-id: d91322d3a --- infer/src/IR/Procname.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml index 9928cedce..94a11cf9b 100644 --- a/infer/src/IR/Procname.ml +++ b/infer/src/IR/Procname.ml @@ -145,12 +145,11 @@ module Java = struct Typ.double | typ_str when String.contains typ_str '[' -> let stripped_typ = String.sub typ_str ~pos:0 ~len:(String.length typ_str - 2) in - Typ.mk (Tptr (Typ.mk_array (java_from_string stripped_typ), Pk_pointer)) + Typ.(mk_ptr (mk_array (java_from_string stripped_typ))) | typ_str -> - Typ.mk (Tstruct (Typ.Name.Java.from_string typ_str)) + Typ.(mk_ptr (mk_struct (Typ.Name.Java.from_string typ_str))) in - let typ = java_from_string (F.asprintf "%a" (pp_return_type Verbose) pname_java) in - match typ.desc with Tstruct _ -> Typ.mk (Tptr (typ, Pk_pointer)) | _ -> typ + java_from_string (F.asprintf "%a" (pp_return_type Verbose) pname_java) let is_close {method_name} = String.equal method_name "close"