From 1356fd331f3db485be9ee38446a7389c9310d344 Mon Sep 17 00:00:00 2001 From: jrm Date: Wed, 8 Jul 2015 23:54:18 -0700 Subject: [PATCH] [infer][clang] test reporting of assertion failures --- infer/bin/inferlib.py | 7 ++++++- infer/src/backend/config.ml | 2 +- infer/src/backend/interproc.ml | 3 ++- .../codetoanalyze/c/errors/assertions/assertion_failure.c | 2 +- .../objc/frontend/assertions/NSAssert_example.dot | 8 ++++---- infer/tests/endtoend/c/AssertionFailureTest.java | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/infer/bin/inferlib.py b/infer/bin/inferlib.py index 434f83076..162247ad7 100644 --- a/infer/bin/inferlib.py +++ b/infer/bin/inferlib.py @@ -236,7 +236,12 @@ def should_report(analyzer, row): ] null_style_buckets = ['B1', 'B2'] - other_bugs = ['RESOURCE_LEAK', 'MEMORY_LEAK', 'RETAIN_CYCLE'] + other_bugs = [ + 'RESOURCE_LEAK', + 'MEMORY_LEAK', + 'RETAIN_CYCLE', + 'ASSERTION_FAILURE' + ] if analyzer in [ERADICATE, CHECKERS, TRACING]: # report all issues for eradicate and checkers diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 910204c33..814b610df 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -345,7 +345,7 @@ let arc_mode = ref false let objc_memory_model_on = ref false let report_assertion_failure = from_env_variable "INFER_REPORT_ASSERTION_FAILURE" -let default_failure_name = "Assertion_failure" +let default_failure_name = "ASSERTION_FAILURE" let analyze_models = from_env_variable "INFER_ANALYZE_MODELS" diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index 08d086349..8dc99c809 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -1055,7 +1055,8 @@ let analyze_proc exe_env (proc_name: Procname.t) : Specs.summary = let prev_summary = Specs.get_summary_unsafe proc_name in let updated_summary = update_summary prev_summary specs proc_name elapsed res in - if (Config.report_assertion_failure || !Config.report_runtime_exceptions) then + if (!Sil.curr_language <> Sil.Java && Config.report_assertion_failure) + || !Config.report_runtime_exceptions then report_runtime_exceptions tenv cfg proc_desc updated_summary; updated_summary diff --git a/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c b/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c index 2fc079fd6..81d3b05c0 100644 --- a/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c +++ b/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c @@ -50,7 +50,7 @@ void __infer_fail(char*); void my_assert(int x) { if (!x) { - __infer_fail("Assertion_failure"); + __infer_fail("ASSERTION_FAILURE"); } } diff --git a/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.dot b/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.dot index f01b7c302..ed6e78992 100644 --- a/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.dot +++ b/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.dot @@ -1,5 +1,5 @@ digraph iCFG { -69 [label="69: Assertion failure \n _fun___infer_fail(\"Assertion_failure\":void ) [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +69 [label="69: Assertion failure \n _fun___infer_fail(\"ASSERTION_FAILURE\":void ) [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] 69 -> 56 ; @@ -61,7 +61,7 @@ digraph iCFG { 55 -> 58 ; -54 [label="54: Assertion failure \n _fun___infer_fail(\"Assertion_failure\":void ) [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +54 [label="54: Assertion failure \n _fun___infer_fail(\"ASSERTION_FAILURE\":void ) [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 54 -> 40 ; @@ -149,7 +149,7 @@ digraph iCFG { 33 -> 35 ; -32 [label="32: Assertion failure \n _fun___infer_fail(\"Assertion_failure\":void ) [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +32 [label="32: Assertion failure \n _fun___infer_fail(\"ASSERTION_FAILURE\":void ) [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 32 -> 18 ; @@ -215,7 +215,7 @@ digraph iCFG { 17 -> 20 ; -16 [label="16: Assertion failure \n _fun___infer_fail(\"Assertion_failure\":void ) [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +16 [label="16: Assertion failure \n _fun___infer_fail(\"ASSERTION_FAILURE\":void ) [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 16 -> 2 ; diff --git a/infer/tests/endtoend/c/AssertionFailureTest.java b/infer/tests/endtoend/c/AssertionFailureTest.java index 92f27c3a9..38b4fc6cc 100644 --- a/infer/tests/endtoend/c/AssertionFailureTest.java +++ b/infer/tests/endtoend/c/AssertionFailureTest.java @@ -21,7 +21,7 @@ public class AssertionFailureTest { public static final String SOURCE_FILE = "assertions/assertion_failure.c"; - public static final String ASSERTION_FAILURE = "Assertion_failure"; + public static final String ASSERTION_FAILURE = "ASSERTION_FAILURE"; private static InferResults inferResults;