From 30a3615fa3e99b9c82af0d5e1b026d35459f361a Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Thu, 7 Jun 2018 03:36:55 -0700 Subject: [PATCH] [IR] Adding module for type of parameters to be added to procnames. Reviewed By: mbouaziz Differential Revision: D8297974 fbshipit-source-id: 3312588 --- infer/src/IR/Typ.ml | 17 +++++++++++++++++ infer/src/IR/Typ.mli | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 68bb8c5df..3d51d4045 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -733,6 +733,23 @@ module Procname = struct Option.exists ~f:Config.java_package_is_external package end + module Parameter = struct + (** [Some name] means the parameter is of type pointer to struct, with [name] +being the name of the struct, [None] means the parameter is of some other type. *) + type t = Name.t option [@@deriving compare] + + let of_typ typ = + match typ.T.desc with T.Tptr ({desc= Tstruct name}, Pk_pointer) -> Some name | _ -> None + + + let parameters_to_string parameters = + let name_opt_to_string par_opt = + match par_opt with Some par -> Name.to_string par | None -> "" + in + let string_pars = List.map ~f:name_opt_to_string parameters in + if List.is_empty parameters then "" else "(" ^ String.concat ~sep:"," string_pars ^ ")" + end + module ObjC_Cpp = struct type kind = | CPPMethod of {mangled: string option} diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index e99e61f7e..6a12e2c31 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -364,6 +364,14 @@ module Procname : sig (** Check if the method belongs to one of the specified external packages *) end + module Parameter : sig + (** [Some name] means the parameter is of type pointer to struct, with [name] + being the name of the struct, [None] means the parameter is of some other type. *) + type t = Name.t option + + val of_typ : typ -> t + end + module ObjC_Cpp : sig type kind = | CPPMethod of {mangled: string option}