From 1b2186910845a7f9499d0719919495204edaa5d4 Mon Sep 17 00:00:00 2001 From: Dino Distefano Date: Tue, 5 Apr 2016 09:16:57 -0700 Subject: [PATCH] Disabling the NSNotification center error from the backend Reviewed By: dulmarod Differential Revision: D3139192 fb-gh-sync-id: d0cd264 fbshipit-source-id: d0cd264 --- infer/src/backend/abs.ml | 2 +- infer/src/backend/config.ml | 2 ++ .../objc/errors/registered_observer/ViewController.m | 6 +++--- infer/tests/endtoend/objc/RegisteredObserver.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/infer/src/backend/abs.ml b/infer/src/backend/abs.ml index bffa1307b..88716a9d7 100644 --- a/infer/src/backend/abs.ml +++ b/infer/src/backend/abs.ml @@ -1024,7 +1024,7 @@ let check_observer_is_unsubscribed_deallocation prop e = match Prop.get_observer_attribute prop e with | Some Sil.Aobserver -> (match pvar_opt with - | Some pvar -> + | Some pvar when !Config.nsnotification_center_checker_backend -> L.d_strln (" ERROR: Object " ^ (Pvar.to_string pvar) ^ " is being deallocated while still registered in a notification center"); let desc = Localise.desc_registered_observer_being_deallocated pvar loc in diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 9edf59031..e2b742669 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -412,3 +412,5 @@ let string_of_language = function | C_CPP -> "C_CPP" let show_progress_bar = ref true + +let nsnotification_center_checker_backend = ref false diff --git a/infer/tests/codetoanalyze/objc/errors/registered_observer/ViewController.m b/infer/tests/codetoanalyze/objc/errors/registered_observer/ViewController.m index 231a06317..12e897630 100644 --- a/infer/tests/codetoanalyze/objc/errors/registered_observer/ViewController.m +++ b/infer/tests/codetoanalyze/objc/errors/registered_observer/ViewController.m @@ -64,10 +64,10 @@ int fooOK2() { } int barError() { - ViewController* vc = [[ViewController alloc] init]; - [vc fired]; + // ViewController* vc = [[ViewController alloc] init]; + //[vc fired]; - vc = [[ViewController alloc] init]; + // vc = [[ViewController alloc] init]; return 0; } diff --git a/infer/tests/endtoend/objc/RegisteredObserver.java b/infer/tests/endtoend/objc/RegisteredObserver.java index 330195d6c..521c9ba0f 100644 --- a/infer/tests/endtoend/objc/RegisteredObserver.java +++ b/infer/tests/endtoend/objc/RegisteredObserver.java @@ -50,7 +50,7 @@ public class RegisteredObserver { throws InterruptedException, IOException, InferException { InferResults inferResults = InferRunner.runInferObjC(inferCmd); String[] methods = { - "fooError", "barError" + //"fooError", "barError" }; assertThat( "Results should contain " + REGISTERED_OBSERVER,