From c423b0d6a64194eb7056d1871e9dbdb204ab9289 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 25 Jun 2021 03:53:40 -0700 Subject: [PATCH] [java] introduce flag controlling masking of sawja exceptions Summary: Purpose is to be able to write tests for failure cases. Reviewed By: jvillard Differential Revision: D29364785 fbshipit-source-id: 734be7826 --- infer/man/man1/infer-capture.txt | 4 ++++ infer/man/man1/infer-full.txt | 4 ++++ infer/man/man1/infer.txt | 4 ++++ infer/src/base/Config.ml | 8 ++++++++ infer/src/base/Config.mli | 2 ++ infer/src/java/jTrans.ml | 2 +- 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/infer/man/man1/infer-capture.txt b/infer/man/man1/infer-capture.txt index 92ce190d0..b13a55acb 100644 --- a/infer/man/man1/infer-capture.txt +++ b/infer/man/man1/infer-capture.txt @@ -310,6 +310,10 @@ JAVA OPTIONS The version of Java being used. Set it to your Java version if mvn is failing. + --no-mask-sawja-exceptions + Deactivates: Mask exceptions thrown by Sawja/Javalib during Java + capture (Conversely: --mask-sawja-exceptions) + ENVIRONMENT INFER_ARGS, INFERCONFIG, INFER_STRICT_MODE diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index ca244cad4..e987809cc 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -885,6 +885,10 @@ OPTIONS Activates: Enable loop-hoisting and disable all other checkers (Conversely: --no-loop-hoisting-only) See also infer-analyze(1). + --no-mask-sawja-exceptions + Deactivates: Mask exceptions thrown by Sawja/Javalib during Java + capture (Conversely: --mask-sawja-exceptions) See also infer-capture(1). + --max-jobs int Maximum number of analysis jobs running simultaneously See also infer-analyze(1). diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 61e53367d..558851f83 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -885,6 +885,10 @@ OPTIONS Activates: Enable loop-hoisting and disable all other checkers (Conversely: --no-loop-hoisting-only) See also infer-analyze(1). + --no-mask-sawja-exceptions + Deactivates: Mask exceptions thrown by Sawja/Javalib during Java + capture (Conversely: --mask-sawja-exceptions) See also infer-capture(1). + --max-jobs int Maximum number of analysis jobs running simultaneously See also infer-analyze(1). diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 44c2d2eb3..9c0bef7ad 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1733,6 +1733,12 @@ and margin = "Set right margin for the pretty printing functions" +and mask_sajwa_exceptions = + CLOpt.mk_bool ~long:"mask-sawja-exceptions" ~default:true + ~in_help:InferCommand.[(Capture, manual_java)] + "Mask exceptions thrown by Sawja/Javalib during Java capture" + + and max_jobs = CLOpt.mk_int_opt ~long:"max-jobs" ~in_help:InferCommand.[(Analyze, manual_generic)] @@ -3197,6 +3203,8 @@ and load_average = match !load_average with None when !buck -> Some (float_of_int ncpu) | _ -> !load_average +and mask_sajwa_exceptions = !mask_sajwa_exceptions + and max_nesting = !max_nesting and memtrace_analysis = !memtrace_analysis diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index fdac29e4b..6a3297876 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -407,6 +407,8 @@ val liveness_ignored_constant : string list val load_average : float option +val mask_sajwa_exceptions : bool + val max_nesting : int option val memtrace_analysis : bool diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 6d4b7568c..7a5604bc2 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -465,7 +465,7 @@ let create_cm_procdesc source_file program icfg cm proc_name = Procdesc.set_start_node procdesc start_node ; Procdesc.set_exit_node procdesc exit_node ; Some (procdesc, start_node, exit_node, exn_node, jbir_code) - with JBir.Subroutine -> + with JBir.Subroutine when Config.mask_sajwa_exceptions -> L.internal_error "create_procdesc raised JBir.Subroutine when translating %a in %a@." Procname.pp proc_name SourceFile.pp source_file ; None