From 67a883e1a2703c90399d8ff660b4f1bffb044a2c Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 28 Sep 2016 04:39:02 -0700 Subject: [PATCH] [models] Use return type for ObjC models Summary: Change implementation of NSArray and NSDictionary model builtins to use the method return type instead of magicking up types from strings. Reviewed By: jvillard Differential Revision: D3919815 fbshipit-source-id: f07a993 --- infer/src/backend/modelBuiltins.ml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/infer/src/backend/modelBuiltins.ml b/infer/src/backend/modelBuiltins.ml index 081932721..321bd6633 100644 --- a/infer/src/backend/modelBuiltins.ml +++ b/infer/src/backend/modelBuiltins.ml @@ -1165,8 +1165,11 @@ let arrayWithObjects_pname = mk_objc_class_method "NSArray" "arrayWithObjects:" let arrayWithObjectsCount_pname = mk_objc_class_method "NSArray" "arrayWithObjects:count:" let execute_objc_NSArray_alloc_no_fail builtin_args symb_state pname = - let nsarray_typ = Typ.Tstruct (TN_csu (Class Objc, Mangled.from_string "NSArray")) in - execute_objc_alloc_no_fail symb_state nsarray_typ (Some pname) builtin_args + let ret_typ = + match builtin_args.Builtin.ret_id with + | Some (_, typ) -> typ + | None -> Typ.Tptr (Tvoid, Pk_pointer) in + execute_objc_alloc_no_fail symb_state ret_typ (Some pname) builtin_args let execute_NSArray_arrayWithObjects_count builtin_args = let n_formals = 1 in @@ -1185,8 +1188,11 @@ let _ = (* NSDictionary models *) let execute_objc_NSDictionary_alloc_no_fail symb_state pname builtin_args = - let nsdictionary_typ = Typ.Tstruct (TN_csu (Class Objc, Mangled.from_string "NSDictionary")) in - execute_objc_alloc_no_fail symb_state nsdictionary_typ (Some pname) builtin_args + let ret_typ = + match builtin_args.Builtin.ret_id with + | Some (_, typ) -> typ + | None -> Typ.Tptr (Tvoid, Pk_pointer) in + execute_objc_alloc_no_fail symb_state ret_typ (Some pname) builtin_args let __objc_dictionary_literal_pname = mk_objc_class_method "NSDictionary" "dictionaryWithObjects:forKeys:count:"