diff --git a/infer/src/IR/HilExp.ml b/infer/src/IR/HilExp.ml index 3e9e822aa..cc464fc8b 100644 --- a/infer/src/IR/HilExp.ml +++ b/infer/src/IR/HilExp.ml @@ -350,9 +350,8 @@ let rec get_typ tenv = function | Constant (Cfloat _) -> Some (Typ.mk (Typ.Tfloat Typ.FFloat)) | Constant (Cclass _) -> - (* TODO: this only happens in Java. We probably need to change it to `Cclass of Typ.Name.t` - to give a useful result here *) - None + let typ = Typ.(mk (Tstruct Name.Java.java_lang_class)) in + Some Typ.(mk (Tptr (typ, Pk_pointer))) | Constant (Cstr _) -> (* TODO: this will need to behave differently depending on whether we're in C++ or Java *) None diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 762c1af36..0e9135523 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -462,12 +462,14 @@ module Name = struct let is_class = function JavaClass _ -> true | _ -> false - let java_lang_object = from_string "java.lang.Object" - let java_io_serializable = from_string "java.io.Serializable" + let java_lang_class = from_string "java.lang.Class" + let java_lang_cloneable = from_string "java.lang.Cloneable" + let java_lang_object = from_string "java.lang.Object" + let split_typename typename = Split.of_string (name typename) let get_outer_class class_name = @@ -1436,6 +1438,7 @@ module Fieldname = struct | _ -> None + module Clang = struct let from_class_name class_name field_name = Clang {class_name; field_name} end diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index a0dc9d129..bfd332129 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -232,6 +232,8 @@ module Name : sig val java_io_serializable : t val java_lang_cloneable : t + + val java_lang_class : t end module Cpp : sig diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 2e3e0c1a8..d4d646d89 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -39,9 +39,8 @@ end) (* using an indentifier for a class object, create an access path representing that lock; this is for synchronizing on Java class objects only *) let lock_of_class = - let type_name = Typ.Name.Java.from_string "java.lang.Class" in - let typ = Typ.mk (Typ.Tstruct type_name) in - let typ' = Typ.mk (Typ.Tptr (typ, Typ.Pk_pointer)) in + let typ = Typ.(mk (Tstruct Name.Java.java_lang_class)) in + let typ' = Typ.(mk (Tptr (typ, Pk_pointer))) in fun class_id -> let ident = Ident.create_normal class_id 0 in AccessPath.of_id ident typ'