From a7c1105147a51fa8936accfdc4ccb3d2990230a0 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 20 Oct 2016 13:32:58 -0700 Subject: [PATCH] [config] Combine analyze_models into models_mode Summary: Config.analyze_models, set by the INFER_ANALYZE_MODELS environment variable, is redundant with Config.models_mode. Reviewed By: jvillard Differential Revision: D4047338 fbshipit-source-id: 4522d65 --- infer/models/c/Makefile | 4 +--- infer/models/cpp/Makefile | 4 +--- infer/models/java/Makefile | 5 +---- infer/models/objc/Makefile | 4 +--- infer/src/backend/interproc.ml | 2 +- infer/src/base/Config.ml | 4 +--- infer/src/base/Config.mli | 1 - infer/src/java/jMain.ml | 8 ++++---- infer/src/java/jTrans.ml | 2 +- 9 files changed, 11 insertions(+), 23 deletions(-) diff --git a/infer/models/c/Makefile b/infer/models/c/Makefile index 064237e87..6b8552fd9 100644 --- a/infer/models/c/Makefile +++ b/infer/models/c/Makefile @@ -11,14 +11,12 @@ include $(ROOT_DIR)/Makefile.config C_MODELS_FILE = $(SPECS_LIB_DIR)/c_models C_MODELS_SOURCES = $(shell find src/ -name "*.c") -INFER = INFER_ANALYZE_MODELS=1 $(BIN_DIR)/infer - all: $(C_MODELS_FILE) $(C_MODELS_FILE): $(C_MODELS_SOURCES) $(CLANG_DEPS) # make clean in src/ in case $(CLANG_DEPS) have changed $(MAKE) -C src clean - $(INFER) -o out/ --models_mode --no_failures_allowed -- $(MAKE) -C src + $(INFER_BIN) -o out/ --models-mode --no-failures-allowed -- $(MAKE) -C src touch $(C_MODELS_FILE) install: $(C_MODELS_FILE) diff --git a/infer/models/cpp/Makefile b/infer/models/cpp/Makefile index d6bce6fa9..7c3ed859c 100644 --- a/infer/models/cpp/Makefile +++ b/infer/models/cpp/Makefile @@ -12,14 +12,12 @@ CPP_MODELS_FILE = $(SPECS_LIB_DIR)/cpp_models CPP_MODELS_SOURCES = $(shell find src/ -name "*.cpp") C_MODELS_SOURCES = $(shell find src/c_src/ -name "*.c") -INFER = INFER_ANALYZE_MODELS=1 $(BIN_DIR)/infer - all: $(CPP_MODELS_FILE) $(CPP_MODELS_FILE): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS) # make clean in src/ in case $(CLANG_DEPS) have changed $(MAKE) -C src clean - $(INFER) -o out/ --models_mode --no_failures_allowed --cxx -- $(MAKE) -C src + $(INFER_BIN) -o out/ --models-mode --no-failures-allowed --cxx -- $(MAKE) -C src touch $(CPP_MODELS_FILE) install: $(CPP_MODELS_FILE) diff --git a/infer/models/java/Makefile b/infer/models/java/Makefile index 06d38616e..4179ed18e 100644 --- a/infer/models/java/Makefile +++ b/infer/models/java/Makefile @@ -8,9 +8,6 @@ ROOT_DIR = ../../.. include $(ROOT_DIR)/Makefile.config -INFER = INFER_ANALYZE_MODELS=1 $(INFER_BIN) \ - --buck --analyzer infer --multicore 1 - ANDROID_JAR = $(LIB_DIR)/java/android/android-19.jar JACKSON_JAR = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar INFER_ANNOTATIONS_JAR = $(ANNOTATIONS_DIR)/annotations.jar @@ -36,7 +33,7 @@ $(INFER_REPORT): $(ANDROID_JAR) $(JACKSON_JAR) $(JAVA_DEPS) $(INFER_ANNOTATIONS_ @rm -fr $(MODELS_OUT) mkdir -p $(MODELS_OUT) @rm -f $(DEPLOYED_MODELS_JAR) - $(INFER) -- javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(JACKSON_JAR):$(INFER_ANNOTATIONS_JAR) $(JAVA_SOURCES) + $(INFER_BIN) --buck --models-mode -- javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(JACKSON_JAR):$(INFER_ANNOTATIONS_JAR) $(JAVA_SOURCES) $(MODELS_JAR): $(INFER_REPORT) cd $(MODELS_OUT); jar cf ../$(MODELS_JAR) * diff --git a/infer/models/objc/Makefile b/infer/models/objc/Makefile index 566adba1c..f1fd79142 100644 --- a/infer/models/objc/Makefile +++ b/infer/models/objc/Makefile @@ -11,14 +11,12 @@ include $(ROOT_DIR)/Makefile.config OBJC_MODELS_FILE = $(SPECS_LIB_DIR)/objc_models OBJC_MODELS_SOURCES = $(shell find src/ -name "*.m" -or -name "*.c") -INFER = INFER_ANALYZE_MODELS=1 $(BIN_DIR)/infer - all: $(OBJC_MODELS_FILE) $(OBJC_MODELS_FILE): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS) # make clean in src/ in case $(CLANG_DEPS) have changed $(MAKE) -C src clean - $(INFER) -o out/ --models_mode --no_failures_allowed -- $(MAKE) -C src + $(INFER_BIN) -o out/ --models-mode --no-failures-allowed -- $(MAKE) -C src touch $(OBJC_MODELS_FILE) install: $(OBJC_MODELS_FILE) diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index b23fdb9e2..4aa89466f 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -1464,7 +1464,7 @@ let do_analysis exe_env = IList.iter (fun ((pn, _) as x) -> let should_init () = - Config.analyze_models || + Config.models_mode || Specs.get_summary pn = None in if should_init () then init_proc x) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 8feb1bbae..21058c4cb 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1232,8 +1232,6 @@ let get_env_variable var_name = if v = "" then None else Some v with Not_found -> None -let analyze_models = from_env_variable "INFER_ANALYZE_MODELS" - (** experimental: handle dynamic dispatch by following the JVM semantics and creating during the symbolic excution procedure descriptions using the types information found in the abstract state *) @@ -1311,7 +1309,7 @@ let post_parsing_initialization () = let default_seconds_timeout = 10.0 in let long_symops_timeout = 1000 in let long_seconds_timeout = 30.0 in - if analyze_models then + if !models_mode then (* use longer timeouts when analyzing models *) long_symops_timeout, long_seconds_timeout else diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 02cb208ae..a276f639c 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -134,7 +134,6 @@ val wrappers_dir : string val from_env_variable : string -> bool val get_env_variable : string -> string option -val analyze_models : bool val lazy_dynamic_dispatch : bool val report_custom_error : bool val sound_dynamic_dispatch : bool diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index a6213d4ed..0a2fa27d5 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -16,9 +16,9 @@ module L = Logging let () = (match Config.models_file with Some file -> JClasspath.add_models file | None -> ()); - if Config.analyze_models && !JClasspath.models_jar <> "" then + if Config.models_mode && !JClasspath.models_jar <> "" then failwith "Not expecting model file when analyzing the models"; - if not Config.analyze_models && !JClasspath.models_jar = "" then + if not Config.models_mode && !JClasspath.models_jar = "" then failwith "Java model file is required" @@ -96,7 +96,7 @@ let load_tenv () = match Tenv.load_from_file DB.global_tenv_fname with | None -> Tenv.create () - | Some _ when Config.analyze_models -> + | Some _ when Config.models_mode -> let error_msg = "Unexpected tenv file " ^ (DB.filename_to_string DB.global_tenv_fname) @@ -111,7 +111,7 @@ let load_tenv () = (* Store to a file the type environment containing all the types required to perform the analysis *) let save_tenv tenv = - if not Config.analyze_models then JTransType.add_models_types tenv; + if not Config.models_mode then JTransType.add_models_types tenv; (* TODO: this prevents per compilation step incremental analysis at this stage *) if DB.file_exists DB.global_tenv_fname then DB.file_remove DB.global_tenv_fname; JUtils.log "writing new tenv %s@." (DB.filename_to_string DB.global_tenv_fname); diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 65d61a10d..cfa1689fc 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -626,7 +626,7 @@ let method_invocation let instrs = match call_args with (* modeling a class bypasses the treatment of Closeable *) - | _ when Config.analyze_models || JClasspath.is_model callee_procname -> call_instrs + | _ when Config.models_mode || JClasspath.is_model callee_procname -> call_instrs (* add a file attribute when calling the constructor of a subtype of Closeable *) | (_, typ) as exp :: _