From c5a8f2e454e61da91a7685e4307608562a41d519 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Tue, 14 Jan 2020 15:05:55 -0800 Subject: [PATCH] [starvation][whole-program] gate analysis of constructors Summary: In whole-program mode, analysing a method requires analysing first all constructors of the same class. This is not needed in normal mode, so gate that computation under `starvation_whole_program` for efficiency. Reviewed By: artempyanykh Differential Revision: D19393412 fbshipit-source-id: 2277e6b5e --- infer/src/concurrency/starvation.ml | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 7bc16f089..f4d9b261e 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -329,21 +329,23 @@ let set_constructor_attributes tenv procname (astate : Domain.t) = let set_initial_attributes tenv procname astate = - match procname with - | Procname.Java java_pname when Procname.Java.is_class_initializer java_pname -> - (* we are analyzing the class initializer, don't go through on-demand again *) - astate - | Procname.Java java_pname when Procname.Java.(is_constructor java_pname || is_static java_pname) - -> - (* analyzing a constructor or static method, so we need the attributes established by the - class initializer *) - set_class_init_attributes procname astate - | Procname.Java _ -> - (* we are analyzing an instance method, so we need constructor-established attributes - which will include those by the class initializer *) - set_constructor_attributes tenv procname astate - | _ -> - astate + if not Config.starvation_whole_program then astate + else + match procname with + | Procname.Java java_pname when Procname.Java.is_class_initializer java_pname -> + (* we are analyzing the class initializer, don't go through on-demand again *) + astate + | Procname.Java java_pname + when Procname.Java.(is_constructor java_pname || is_static java_pname) -> + (* analyzing a constructor or static method, so we need the attributes established by the + class initializer *) + set_class_init_attributes procname astate + | Procname.Java _ -> + (* we are analyzing an instance method, so we need constructor-established attributes + which will include those by the class initializer *) + set_constructor_attributes tenv procname astate + | _ -> + astate let analyze_procedure {Callbacks.exe_env; summary} =