Add Infer# Support for Inference Between Type Expressions (#1455)

Summary:
This PR enables implications to be drawn between .NET types.

Pull Request resolved: https://github.com/facebook/infer/pull/1455

Reviewed By: ngorogiannis

Differential Revision: D29612722

Pulled By: jvillard

fbshipit-source-id: 2e29b51a9
master
Matthew Jin 3 years ago committed by Facebook GitHub Bot
parent 9d7eb5684a
commit f0ab545594

@ -48,6 +48,8 @@ module Name = struct
open Typ.Name.CSharp open Typ.Name.CSharp
let system_string = from_string "System.String" let system_string = from_string "System.String"
let system_object = from_string "System.Object"
end end
module Objc = struct module Objc = struct

@ -45,6 +45,8 @@ module Name : sig
module CSharp : sig module CSharp : sig
val system_string : t val system_string : t
val system_object : t
end end
module Objc : sig module Objc : sig

@ -46,6 +46,8 @@ let is_root_class class_name =
match class_name with match class_name with
| Typ.JavaClass _ -> | Typ.JavaClass _ ->
Typ.Name.equal class_name StdTyp.Name.Java.java_lang_object Typ.Name.equal class_name StdTyp.Name.Java.java_lang_object
| Typ.CSharpClass _ ->
Typ.Name.equal class_name StdTyp.Name.CSharp.system_object
| _ -> | _ ->
false false

@ -512,6 +512,8 @@ module Name = struct
module CSharp = struct module CSharp = struct
let from_string name_str = CSharpClass (CSharpClassName.from_string name_str) let from_string name_str = CSharpClass (CSharpClassName.from_string name_str)
let is_class = function CSharpClass _ -> true | _ -> false
end end
module Java = struct module Java = struct

@ -200,6 +200,8 @@ module Name : sig
module CSharp : sig module CSharp : sig
val from_string : string -> t val from_string : string -> t
val is_class : t -> bool
end end
module Java : sig module Java : sig

@ -45,6 +45,16 @@ let rec is_java_class tenv (typ : Typ.t) =
false false
let rec is_csharp_class tenv (typ : Typ.t) =
match typ.desc with
| Tstruct name ->
Typ.Name.CSharp.is_class name
| Tarray {elt= inner_typ} | Tptr (inner_typ, _) ->
is_csharp_class tenv inner_typ
| _ ->
false
(** Negate an atom *) (** Negate an atom *)
let atom_negate tenv (atom : Predicates.atom) : Predicates.atom = let atom_negate tenv (atom : Predicates.atom) : Predicates.atom =
match atom with match atom with
@ -1845,7 +1855,7 @@ let texp_imply tenv subs texp1 texp2 e1 calc_missing =
| Exp.Sizeof {typ= typ1}, Exp.Sizeof {typ= typ2} -> ( | Exp.Sizeof {typ= typ1}, Exp.Sizeof {typ= typ2} -> (
match (typ1.desc, typ2.desc) with match (typ1.desc, typ2.desc) with
| (Tstruct _ | Tarray _), (Tstruct _ | Tarray _) -> | (Tstruct _ | Tarray _), (Tstruct _ | Tarray _) ->
is_java_class tenv typ1 (is_java_class tenv typ1 || is_csharp_class tenv typ1)
|| (Typ.is_cpp_class typ1 && Typ.is_cpp_class typ2) || (Typ.is_cpp_class typ1 && Typ.is_cpp_class typ2)
|| (Typ.is_objc_class typ1 && Typ.is_objc_class typ2) || (Typ.is_objc_class typ1 && Typ.is_objc_class typ2)
| _ -> | _ ->

Loading…
Cancel
Save