From 4ad73acf9db09764bde4c8f767f706d5658d123d Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Tue, 28 Jul 2015 08:55:44 -0600 Subject: [PATCH] [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. --- infer/src/harness/androidFramework.ml | 7 +++++++ infer/src/harness/androidFramework.mli | 3 +++ 2 files changed, 10 insertions(+) diff --git a/infer/src/harness/androidFramework.ml b/infer/src/harness/androidFramework.ml index 47266fae6..f6669679d 100644 --- a/infer/src/harness/androidFramework.ml +++ b/infer/src/harness/androidFramework.ml @@ -267,6 +267,13 @@ let get_all_supertypes typ tenv = let is_subtype (typ0 : Sil.typ) (typ1 : Sil.typ) 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 *) let is_callback_class_name class_name = Mangled.MangledSet.mem class_name android_callbacks diff --git a/infer/src/harness/androidFramework.mli b/infer/src/harness/androidFramework.mli index 48f060b3b..99bece57b 100644 --- a/infer/src/harness/androidFramework.mli +++ b/infer/src/harness/androidFramework.mli @@ -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 *) 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 *) val is_destroy_method : Procname.t -> bool