[infer] adding is_activity method

Summary: We need to know when a class is a subclass of Activity in order to implement Activity leak checking.
master
Sam Blackshear 9 years ago
parent 66ef0ec0b9
commit 4ad73acf9d

@ -267,6 +267,13 @@ let get_all_supertypes typ tenv =
let is_subtype (typ0 : Sil.typ) (typ1 : Sil.typ) tenv = let is_subtype (typ0 : Sil.typ) (typ1 : Sil.typ) tenv =
TypSet.mem typ1 (get_all_supertypes typ0 tenv) TypSet.mem typ1 (get_all_supertypes typ0 tenv)
(** return true if [typ] <: android.app.Activity *)
let is_activity typ tenv =
let activity_mangled = Mangled.from_package_class "android.app" "Activity" in
match Sil.get_typ activity_mangled (Some Sil.Class) tenv with
| Some activity_typ -> is_subtype typ activity_typ tenv
| None -> false
(** return true if [class_name] is a known callback class name *) (** return true if [class_name] is a known callback class name *)
let is_callback_class_name class_name = Mangled.MangledSet.mem class_name android_callbacks let is_callback_class_name class_name = Mangled.MangledSet.mem class_name android_callbacks

@ -20,6 +20,9 @@ val typ_is_lifecycle_typ : Sil.typ -> Sil.typ -> Sil.tenv -> bool
(** return true if [typ] is a known callback class, false otherwise *) (** return true if [typ] is a known callback class, false otherwise *)
val is_callback_class : Sil.typ -> Sil.tenv -> bool val is_callback_class : Sil.typ -> Sil.tenv -> bool
(** return true if [typ] <: android.app.Activity *)
val is_activity : Sil.typ -> Sil.tenv -> bool
(** return true if [procname] is a special lifecycle cleanup method *) (** return true if [procname] is a special lifecycle cleanup method *)
val is_destroy_method : Procname.t -> bool val is_destroy_method : Procname.t -> bool

Loading…
Cancel
Save