diff --git a/infer/lib/python/infer b/infer/lib/python/infer index eb93424d3..a65bebef9 100755 --- a/infer/lib/python/infer +++ b/infer/lib/python/infer @@ -99,6 +99,14 @@ def create_argparser(parents=[]): return parser +def validate_args(mode, args): + if mode is not None and mode.LANG == ['clang'] and \ + args.analyzer == config.ANALYZER_CHECKERS: + utils.stderr('error: checkers are only enabled for Java.') + if not args.debug: + exit(1) + + def main(): toplevel_envvar_value = os.environ.get(TOP_LEVEL_ENVVAR, None) is_toplevel_instance = False @@ -125,14 +133,16 @@ def main(): args = global_argparser.parse_args(to_parse) - remove_infer_out = (imported_module + validate_args(imported_module, args) + + remove_infer_out = (imported_module is not None and not args.reactive and capture_module_name != 'analyze' and not args.buck) if remove_infer_out: analyze.remove_infer_out(args.infer_out) - if imported_module: + if imported_module is not None: analyze.create_results_dir(args.infer_out) analyze.reset_start_file(args.infer_out, touch_if_present=not args.continue_capture) diff --git a/infer/lib/python/inferlib/capture/analyze.py b/infer/lib/python/inferlib/capture/analyze.py index a3ebe1af6..770e1bc10 100644 --- a/infer/lib/python/inferlib/capture/analyze.py +++ b/infer/lib/python/inferlib/capture/analyze.py @@ -13,6 +13,7 @@ MODULE_DESCRIPTION = '''Run analysis of what has already been captured: Usage: infer -- analyze infer --out -- analyze''' +LANG = ['clang', 'java'] def gen_instance(*args): diff --git a/infer/lib/python/inferlib/capture/ant.py b/infer/lib/python/inferlib/capture/ant.py index e4ff051a0..639fa00e2 100644 --- a/infer/lib/python/inferlib/capture/ant.py +++ b/infer/lib/python/inferlib/capture/ant.py @@ -17,6 +17,7 @@ ant [options] [target] Analysis examples: infer -- ant compile''' +LANG = ['java'] def gen_instance(*args): return AntCapture(*args) diff --git a/infer/lib/python/inferlib/capture/buck.py b/infer/lib/python/inferlib/capture/buck.py index 04badf560..6fa5b5254 100644 --- a/infer/lib/python/inferlib/capture/buck.py +++ b/infer/lib/python/inferlib/capture/buck.py @@ -26,6 +26,7 @@ buck [options] [target] Analysis examples: infer -- buck build HelloWorld''' +LANG = ['clang', 'java'] def gen_instance(*args): diff --git a/infer/lib/python/inferlib/capture/gradle.py b/infer/lib/python/inferlib/capture/gradle.py index d3a3e40d8..0117d809f 100644 --- a/infer/lib/python/inferlib/capture/gradle.py +++ b/infer/lib/python/inferlib/capture/gradle.py @@ -19,7 +19,7 @@ gradle [options] [task] Analysis examples: infer -- gradle build infer -- ./gradlew build''' - +LANG = ['java'] def gen_instance(*args): diff --git a/infer/lib/python/inferlib/capture/javac.py b/infer/lib/python/inferlib/capture/javac.py index fe5b96545..ce970aa6a 100644 --- a/infer/lib/python/inferlib/capture/javac.py +++ b/infer/lib/python/inferlib/capture/javac.py @@ -19,6 +19,7 @@ javac Analysis examples: infer -- javac srcfile.java infer -- /path/to/javac srcfile.java''' +LANG = ['java'] def gen_instance(*args): diff --git a/infer/lib/python/inferlib/capture/make.py b/infer/lib/python/inferlib/capture/make.py index 411281a3a..8c64bc08b 100644 --- a/infer/lib/python/inferlib/capture/make.py +++ b/infer/lib/python/inferlib/capture/make.py @@ -24,6 +24,7 @@ Analysis examples: infer -- make all infer -- clang -c srcfile.m infer -- gcc -c srcfile.c''' +LANG = ['clang'] ALIASED_COMMANDS = ['clang', 'clang++', 'cc', 'gcc', 'g++'] BUILD_COMMANDS = ['cmake', 'configure', 'make', 'waf'] diff --git a/infer/lib/python/inferlib/capture/mvn.py b/infer/lib/python/inferlib/capture/mvn.py index f7c60c5e2..231515694 100644 --- a/infer/lib/python/inferlib/capture/mvn.py +++ b/infer/lib/python/inferlib/capture/mvn.py @@ -18,6 +18,8 @@ mvn [options] [task] Analysis examples: infer -- mvn build''' +LANG = ['java'] + def gen_instance(*args): return MavenCapture(*args) diff --git a/infer/lib/python/inferlib/capture/xcodebuild.py b/infer/lib/python/inferlib/capture/xcodebuild.py index cdeda76cc..d9728c0dc 100644 --- a/infer/lib/python/inferlib/capture/xcodebuild.py +++ b/infer/lib/python/inferlib/capture/xcodebuild.py @@ -21,6 +21,7 @@ xcodebuild [options] Analysis examples: infer -- xcodebuild -target HelloWorldApp -sdk iphonesimulator infer -- xcodebuild -workspace HelloWorld.xcworkspace -scheme HelloWorld''' +LANG = ['clang'] CLANG_WRAPPER = os.path.join(config.XCODE_WRAPPERS_DIRECTORY, 'clang') CLANGPLUSPLUS_WRAPPER = os.path.join(config.XCODE_WRAPPERS_DIRECTORY, diff --git a/infer/src/checkers/registerCheckers.ml b/infer/src/checkers/registerCheckers.ml index c7be732b7..2fd25b9d3 100644 --- a/infer/src/checkers/registerCheckers.ml +++ b/infer/src/checkers/registerCheckers.ml @@ -44,7 +44,7 @@ let active_procedure_checkers () = let l = [ Checkers.callback_print_c_method_calls, false; - CheckDeadCode.callback_check_dead_code, checkers_enabled; + CheckDeadCode.callback_check_dead_code, false; ] in IList.map (fun (x, y) -> (x, y, Some Config.Clang)) l in diff --git a/infer/src/checkers/registerCheckers.mli b/infer/src/checkers/registerCheckers.mli new file mode 100644 index 000000000..fa037ecc0 --- /dev/null +++ b/infer/src/checkers/registerCheckers.mli @@ -0,0 +1,18 @@ +(* + * Copyright (c) 2013 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + *) + +open! Utils + +(* val active_procedure_checkers : unit -> *) +(* (Callbacks.proc_callback_t * bool * Config.language option) list *) + +(* val active_cluster_checkers : unit -> *) +(* (Callbacks.cluster_callback_t * bool * Config.language option) list *) + +val register : unit -> unit