From e08d9341c83e574f857c08ff3e1405015ffd5ca0 Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Thu, 9 Mar 2017 05:16:57 -0800 Subject: [PATCH] [clang] Run direct tests with --no-failures-allowed flag Reviewed By: dulmarod Differential Revision: D4674385 fbshipit-source-id: 0816239 --- infer/src/clang/cFrontend_decl.ml | 11 ++++++++--- infer/src/clang/cTrans.ml | 7 +++++++ infer/src/clang/cTrans_utils.ml | 2 ++ infer/src/clang/cTrans_utils.mli | 2 ++ infer/tests/codetoanalyze/c/bufferoverrun/Makefile | 2 +- infer/tests/codetoanalyze/c/errors/Makefile | 2 +- infer/tests/codetoanalyze/c/frontend/Makefile | 1 + infer/tests/codetoanalyze/cpp/checkers/Makefile | 2 +- infer/tests/codetoanalyze/cpp/errors/Makefile | 2 +- infer/tests/codetoanalyze/cpp/frontend/Makefile | 2 +- infer/tests/codetoanalyze/cpp/quandary/Makefile | 2 +- infer/tests/codetoanalyze/objc/errors/Makefile | 2 +- infer/tests/codetoanalyze/objc/ioslints/Makefile | 2 +- infer/tests/codetoanalyze/objc/linters/Makefile | 2 +- infer/tests/codetoanalyze/objc/quandary/Makefile | 2 +- infer/tests/codetoanalyze/objcpp/frontend/Makefile | 2 ++ infer/tests/codetoanalyze/objcpp/linters/Makefile | 5 +++-- 17 files changed, 35 insertions(+), 15 deletions(-) diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 846cb1b15..f32e47375 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -21,6 +21,10 @@ struct (* Translates the method/function's body into nodes of the cfg. *) let add_method trans_unit_ctx tenv cg cfg class_decl_opt procname body has_return_param is_objc_method outer_context_opt extra_instrs = + let handle_translation_failure () = + Cfg.remove_proc_desc cfg procname; + CMethod_trans.create_external_procdesc cfg procname is_objc_method None + in Logging.out_debug "@\n@\n>>---------- ADDING METHOD: '%s' ---------<<@\n@." (Procname.to_string procname); try @@ -48,11 +52,12 @@ struct (* this shouldn't happen, because self or [a class] should always be arguments of functions. This is to make sure I'm not wrong. *) assert false + | CTrans_utils.TemplatedCodeException _ -> + Logging.out "Fatal error: frontend doesn't support translation of templated code\n"; + handle_translation_failure () | Assert_failure (file, line, column) when Config.failures_allowed -> Logging.out "Fatal error: exception Assert_failure(%s, %d, %d)\n%!" file line column; - Cfg.remove_proc_desc cfg procname; - CMethod_trans.create_external_procdesc cfg procname is_objc_method None; - () + handle_translation_failure () let function_decl trans_unit_ctx tenv cfg cg func_decl block_data_opt = let captured_vars, outer_context_opt = diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 9ba812678..20200d3c3 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2665,6 +2665,13 @@ struct | VAArgExpr (_, _, expr_info) -> trans_into_undefined_expr trans_state expr_info + + (* Infer somehow ended up in templated non instantiated code - right now + it's not supported and failure in those cases is expected. *) + | SubstNonTypeTemplateParmExpr _ + | SubstNonTypeTemplateParmPackExpr _ + | CXXDependentScopeMemberExpr _ -> raise (CTrans_utils.TemplatedCodeException instr) + | s -> (Logging.out "\n!!!!WARNING: found statement %s. \nACTION REQUIRED: \ Translation need to be defined. Statement ignored.... \n" diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index e20e76f12..aeefc15db 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -14,6 +14,8 @@ module Hashtbl = Caml.Hashtbl module L = Logging +exception TemplatedCodeException of Clang_ast_t.stmt + (* Extract the element of a singleton list. If the list is not a singleton *) (* It stops the computation giving a warning. We use this because we *) (* assume in many places that a list is just a singleton. We use the *) diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index 8950a4ca2..e7c4d7ba4 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -40,6 +40,8 @@ type trans_result = { is_cpp_call_virtual : bool; } +exception TemplatedCodeException of Clang_ast_t.stmt + val empty_res_trans: trans_result val undefined_expression: unit -> Exp.t diff --git a/infer/tests/codetoanalyze/c/bufferoverrun/Makefile b/infer/tests/codetoanalyze/c/bufferoverrun/Makefile index 5e1e03985..1c1347076 100644 --- a/infer/tests/codetoanalyze/c/bufferoverrun/Makefile +++ b/infer/tests/codetoanalyze/c/bufferoverrun/Makefile @@ -12,7 +12,7 @@ TESTS_DIR = ../../.. ANALYZER = bufferoverrun CLANG_OPTIONS = -c -INFER_OPTIONS = -nf --project-root $(TESTS_DIR) +INFER_OPTIONS = -nf --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/c/errors/Makefile b/infer/tests/codetoanalyze/c/errors/Makefile index 44b71bded..e301f8469 100644 --- a/infer/tests/codetoanalyze/c/errors/Makefile +++ b/infer/tests/codetoanalyze/c/errors/Makefile @@ -9,7 +9,7 @@ TESTS_DIR = ../../.. ANALYZER = infer CLANG_OPTIONS = -c -INFER_OPTIONS = --report-custom-error --developer-mode --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --report-custom-error --developer-mode --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed # we need to disable traces in C tests because assertions/assertion_failure.c has different traces # on Linux and OSX because of different implementations of assert() on each platform INFERPRINT_OPTIONS = --issues-fields "file,procedure,line_offset,bug_type" --issues-tests diff --git a/infer/tests/codetoanalyze/c/frontend/Makefile b/infer/tests/codetoanalyze/c/frontend/Makefile index 6e6cb853d..faa0d4400 100644 --- a/infer/tests/codetoanalyze/c/frontend/Makefile +++ b/infer/tests/codetoanalyze/c/frontend/Makefile @@ -8,6 +8,7 @@ TESTS_DIR=../../.. CLANG_OPTIONS = -c +INFER_OPTIONS = --no-failures-allowed SOURCES = \ $(wildcard */*.c) \ diff --git a/infer/tests/codetoanalyze/cpp/checkers/Makefile b/infer/tests/codetoanalyze/cpp/checkers/Makefile index e6e0167aa..aa6b8906a 100644 --- a/infer/tests/codetoanalyze/cpp/checkers/Makefile +++ b/infer/tests/codetoanalyze/cpp/checkers/Makefile @@ -10,7 +10,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers # see explanations in cpp/errors/Makefile for the custom isystem CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/cpp/errors/Makefile b/infer/tests/codetoanalyze/cpp/errors/Makefile index 5d1d70c42..a7ff0bfc0 100644 --- a/infer/tests/codetoanalyze/cpp/errors/Makefile +++ b/infer/tests/codetoanalyze/cpp/errors/Makefile @@ -12,7 +12,7 @@ ANALYZER = infer # Use the system headers of our own clang. This way, we always use the same system headers # regardless of the libraries installed on the machine. CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/cpp/frontend/Makefile b/infer/tests/codetoanalyze/cpp/frontend/Makefile index 1c55f02f9..748c56a24 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/cpp/frontend/Makefile @@ -11,7 +11,7 @@ TESTS_DIR=../../.. CLANG_OPTIONS = \ -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ \ -x c++ -std=c++11 -c -INFER_OPTIONS = --headers +INFER_OPTIONS = --headers --no-failures-allowed SOURCES = \ diff --git a/infer/tests/codetoanalyze/cpp/quandary/Makefile b/infer/tests/codetoanalyze/cpp/quandary/Makefile index 2d34259f8..4fc50bc8c 100644 --- a/infer/tests/codetoanalyze/cpp/quandary/Makefile +++ b/infer/tests/codetoanalyze/cpp/quandary/Makefile @@ -10,7 +10,7 @@ TESTS_DIR = ../../.. ANALYZER = quandary # see explanations in cpp/errors/Makefile for the custom isystem CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/objc/errors/Makefile b/infer/tests/codetoanalyze/objc/errors/Makefile index a0850e557..d79b77d2f 100644 --- a/infer/tests/codetoanalyze/objc/errors/Makefile +++ b/infer/tests/codetoanalyze/objc/errors/Makefile @@ -18,7 +18,7 @@ CLANG_OPTIONS = -x objective-c \ CLEAN_EXTRA = infer-out-arc infer-out-all infer-out-all infer-out-arc \ issues.exp.test.all issues.exp.test.arc issues.exp.test.default -INFER_OPTIONS = --check-duplicate-symbols --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --check-duplicate-symbols --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES_DEFAULT = \ diff --git a/infer/tests/codetoanalyze/objc/ioslints/Makefile b/infer/tests/codetoanalyze/objc/ioslints/Makefile index 021421ae2..422bc0cef 100644 --- a/infer/tests/codetoanalyze/objc/ioslints/Makefile +++ b/infer/tests/codetoanalyze/objc/ioslints/Makefile @@ -17,7 +17,7 @@ CLANG_OPTIONS = -x objective-c \ ANALYZER = linters INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \ ---iphoneos-target-sdk-version 8.0 +--iphoneos-target-sdk-version 8.0 --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/objc/linters/Makefile b/infer/tests/codetoanalyze/objc/linters/Makefile index 457d20a22..d17d370ef 100644 --- a/infer/tests/codetoanalyze/objc/linters/Makefile +++ b/infer/tests/codetoanalyze/objc/linters/Makefile @@ -9,7 +9,7 @@ TESTS_DIR = ../../.. ANALYZER = linters CLANG_OPTIONS = -x objective-c -fobjc-arc -c -INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/objc/quandary/Makefile b/infer/tests/codetoanalyze/objc/quandary/Makefile index 2a49d4632..2c2dc325e 100644 --- a/infer/tests/codetoanalyze/objc/quandary/Makefile +++ b/infer/tests/codetoanalyze/objc/quandary/Makefile @@ -16,7 +16,7 @@ CLANG_OPTIONS = -x objective-c \ -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ ANALYZER = quandary -INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --iphoneos-target-sdk-version 8.0 +INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --iphoneos-target-sdk-version 8.0 --no-failures-allowed INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/objcpp/frontend/Makefile b/infer/tests/codetoanalyze/objcpp/frontend/Makefile index fba92e78d..75273c05e 100644 --- a/infer/tests/codetoanalyze/objcpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/objcpp/frontend/Makefile @@ -15,6 +15,8 @@ CLANG_OPTIONS = -x objective-c++ -std=c++11 \ -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ +INFER_OPTIONS = --no-failures-allowed + SOURCES = \ $(wildcard */*.mm) \ diff --git a/infer/tests/codetoanalyze/objcpp/linters/Makefile b/infer/tests/codetoanalyze/objcpp/linters/Makefile index be14b64b7..3507a5068 100644 --- a/infer/tests/codetoanalyze/objcpp/linters/Makefile +++ b/infer/tests/codetoanalyze/objcpp/linters/Makefile @@ -9,8 +9,9 @@ TESTS_DIR = ../../.. ANALYZER = linters CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c -INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --enable-checks GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL -INFERPRINT_OPTIONS = --issues-tests +INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed \ +--enable-checks GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL +INFERPRINT_OPTIONS = --issues-tests SOURCES = \ $(wildcard */*.mm) \