[siof] enable SIOF checker only when new --siof option is passed

Summary:
As an interprocedural checker, SIOF should not run unless explicitly required.
Make it a new type of analyzer like other similar checkers.

Reviewed By: mbouaziz

Differential Revision: D4937820

fbshipit-source-id: a9e2d38
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 2cd80105b5
commit 31a6aba3c2

@ -32,7 +32,7 @@ BUILD_SYSTEMS_TESTS += \
DIRECT_TESTS += \
c_bufferoverrun c_errors c_frontend \
cpp_bufferoverrun cpp_checkers cpp_errors cpp_frontend cpp_quandary \
cpp_bufferoverrun cpp_errors cpp_frontend cpp_quandary cpp_siof \
ifneq ($(BUCK),no)
BUILD_SYSTEMS_TESTS += buck-clang-db

@ -271,6 +271,7 @@ let should_report (issue_kind: Exceptions.err_kind) issue_type error_desc eclass
switch Config.analyzer {
| Checkers
| Eradicate
| Siof
| Tracing => true
| Bufferoverrun
| Capture

@ -375,7 +375,8 @@ let analyze driver_mode =
false, false
| _, (Capture | Compile) ->
false, false
| _, (Infer | Eradicate | Checkers | Tracing | Crashcontext | Quandary | Threadsafety | Bufferoverrun) ->
| _, (Infer | Eradicate | Checkers | Tracing | Crashcontext | Quandary | Siof | Threadsafety
| Bufferoverrun) ->
true, true
| _, Linters ->
false, true in

@ -36,8 +36,9 @@ let exe_name =
let frontend_parse_modes = CLOpt.(Infer [Clang])
type analyzer =
Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters | Quandary
| Threadsafety | Bufferoverrun [@@deriving compare]
| Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters | Quandary
| Siof | Threadsafety | Bufferoverrun
[@@deriving compare]
let equal_analyzer = [%compare.equal : analyzer]
@ -45,7 +46,7 @@ let string_to_analyzer =
[("capture", Capture); ("compile", Compile);
("infer", Infer); ("eradicate", Eradicate); ("checkers", Checkers);
("tracing", Tracing); ("crashcontext", Crashcontext); ("linters", Linters);
("quandary", Quandary); ("threadsafety", Threadsafety);
("quandary", Quandary); ("siof", Siof); ("threadsafety", Threadsafety);
("bufferoverrun", Bufferoverrun)]
let string_of_analyzer a =
@ -479,7 +480,7 @@ and analyzer =
(* NOTE: if compilation fails here, it means you have added a new analyzer without updating the
documentation of this option *)
| Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters
| Quandary | Threadsafety | Bufferoverrun -> () in
| Quandary | Siof | Threadsafety | Bufferoverrun -> () in
CLOpt.mk_symbol_opt ~deprecated:["analyzer"] ~long:"analyzer" ~short:'a'
~parse_mode:CLOpt.(Infer [Driver])
"Specify which analyzer to run (only one at a time is supported):\n\
@ -487,7 +488,8 @@ and analyzer =
- capture: run capture phase only (no analysis)\n\
- compile: run compilation command without interfering (not supported by all frontends)\n\
- crashcontext, tracing: experimental (see --crashcontext and --tracing)\n\
- linters: run linters based on the ast only (Objective-C and Objective-C++ only)"
- linters: run linters based on the ast only (Objective-C and Objective-C++ only)\n\
- siof: check for Static Initialization Order Fiasco (C++ only)"
~symbols:string_to_analyzer
and android_harness =
@ -585,7 +587,7 @@ and changed_files_index =
start. Source files should be specified relative to project root or be absolute"
and bufferoverrun, checkers, checkers_repeated_calls,
crashcontext, eradicate, quandary, threadsafety =
crashcontext, eradicate, quandary, siof, threadsafety =
let checkers =
CLOpt.mk_bool ~deprecated:["checkers"] ~long:"checkers"
"Activate the checkers instead of the full analysis"
@ -615,13 +617,18 @@ and bufferoverrun, checkers, checkers_repeated_calls,
"Activate the quandary taint analysis"
[checkers] []
in
let siof =
CLOpt.mk_bool_group ~long:"siof"
"Activate the Static Initialization Order Fiasco analysis"
[checkers] []
in
let threadsafety =
CLOpt.mk_bool_group ~deprecated:["threadsafety"] ~long:"threadsafety"
"Activate the thread safety analysis"
[checkers] []
in
(bufferoverrun, checkers, checkers_repeated_calls,
crashcontext, eradicate, quandary, threadsafety)
crashcontext, eradicate, quandary, siof, threadsafety)
and clang_biniou_file =
CLOpt.mk_path_opt ~long:"clang-biniou-file" ~parse_mode:CLOpt.(Infer [Clang]) ~meta:"file"
@ -1537,6 +1544,7 @@ let post_parsing_initialization () =
| Some Quandary -> checkers := true; quandary := true
| Some Threadsafety -> checkers := true; threadsafety := true
| Some Bufferoverrun -> checkers := true; bufferoverrun := true
| Some Siof -> checkers := true; siof := true
| Some Tracing -> tracing := true
| Some (Capture | Compile | Infer | Linters) | None -> ()
@ -1727,6 +1735,7 @@ and save_analysis_results = !save_results
and seconds_per_iteration = !seconds_per_iteration
and show_buckets = !print_buckets
and show_progress_bar = !progress_bar
and siof = !siof
and siof_safe_methods = !siof_safe_methods
and skip_analysis_in_path = !skip_analysis_in_path
and skip_duplicated_types = !skip_duplicated_types

@ -19,8 +19,9 @@ val exe_name : exe -> string
(** Various kind of analyzers *)
type analyzer =
Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters | Quandary
| Threadsafety | Bufferoverrun [@@deriving compare]
| Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters | Quandary
| Siof | Threadsafety | Bufferoverrun
[@@deriving compare]
val equal_analyzer : analyzer -> analyzer -> bool
@ -315,6 +316,7 @@ val save_analysis_results : string option
val seconds_per_iteration : float option
val show_buckets : bool
val show_progress_bar : bool
val siof : bool
val siof_safe_methods : string list
val skip_analysis_in_path : string list
val skip_duplicated_types : bool

@ -51,7 +51,7 @@ let active_procedure_checkers () =
CheckDeadCode.callback_check_dead_code, false;
Checkers.callback_print_access_to_globals, false;
ClangTaintAnalysis.checker, Config.quandary;
Siof.checker, Config.checkers_enabled;
Siof.checker, Config.siof;
BufferOverrunChecker.checker, Config.bufferoverrun;
] in
List.map ~f:(fun (x, y) -> (x, y, Some Config.Clang)) l in

@ -53,7 +53,7 @@ let add_flavor_to_target target =
add "infer-capture-all"
| None, (Checkers | Infer) ->
add "infer"
| None, (Eradicate | Tracing | Crashcontext | Quandary | Threadsafety | Bufferoverrun) ->
| None, (Eradicate | Tracing | Crashcontext | Quandary | Siof | Threadsafety | Bufferoverrun) ->
failwithf "Unsupported infer analyzer with Buck flavors: %s"
(Config.string_of_analyzer Config.analyzer)

@ -12,4 +12,4 @@ default: compile
.PHONY: print replace test clean
print replace test clean:
$(QUIET)INFER_ARGS=-j^1 $(MAKE) -C ../../codetoanalyze/cpp/checkers TEST_SUFFIX=-j1 $@
$(QUIET)INFER_ARGS=-j^1 $(MAKE) -C ../../codetoanalyze/cpp/siof TEST_SUFFIX=-j1 $@

@ -1,10 +0,0 @@
codetoanalyze/cpp/checkers/siof/siof.cpp, __infer_globals_initializer_X::static_pod_accesses_non_pod, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of X::static_pod_accesses_non_pod,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/checkers/siof/siof.cpp, __infer_globals_initializer_another_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object,call to SomeOtherNonPODObject_SomeOtherNonPODObject,access to extern_global_object]
codetoanalyze/cpp/checkers/siof/siof.cpp, __infer_globals_initializer_another_global_object2, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object2,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/checkers/siof/siof.cpp, __infer_globals_initializer_another_global_object3, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object3,call to access_to_templated_non_pod,access to global_object3]
codetoanalyze/cpp/checkers/siof/siof.cpp, __infer_globals_initializer_initWithGlobal, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of initWithGlobal,call to getGlobalNonPOD,access to some_other_global_object2,access to global_object2]
codetoanalyze/cpp/checkers/siof/siof.cpp, __infer_globals_initializer_pod_accesses_non_pod, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of pod_accesses_non_pod,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/checkers/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object,call to SomeOtherTemplatedNonPODObject<_Bool>_SomeOtherTemplatedNonPODObject,access to extern_global_object]
codetoanalyze/cpp/checkers/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object2, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object2,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/checkers/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object3, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object3,call to access_to_templated_non_pod,access to global_object3]
codetoanalyze/cpp/checkers/siof/std_ios_base_init.cpp, __infer_globals_initializer_global_bad_std_cerr_access, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of global_bad_std_cerr_access,call to return_4_SIOF,call to printing_SIOF,access to std::cerr]

@ -7,7 +7,7 @@
TESTS_DIR = ../../..
ANALYZER = checkers
ANALYZER = siof
# 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) --no-failures-allowed

@ -0,0 +1,10 @@
codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_X::static_pod_accesses_non_pod, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of X::static_pod_accesses_non_pod,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object,call to SomeOtherNonPODObject_SomeOtherNonPODObject,access to extern_global_object]
codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object2, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object2,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object3, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object3,call to access_to_templated_non_pod,access to global_object3]
codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_initWithGlobal, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of initWithGlobal,call to getGlobalNonPOD,access to some_other_global_object2,access to global_object2]
codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_pod_accesses_non_pod, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of pod_accesses_non_pod,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object,call to SomeOtherTemplatedNonPODObject<_Bool>_SomeOtherTemplatedNonPODObject,access to extern_global_object]
codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object2, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object2,call to access_to_non_pod,access to global_object2,access to some_other_global_object2]
codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object3, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object3,call to access_to_templated_non_pod,access to global_object3]
codetoanalyze/cpp/siof/siof/std_ios_base_init.cpp, __infer_globals_initializer_global_bad_std_cerr_access, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of global_bad_std_cerr_access,call to return_4_SIOF,call to printing_SIOF,access to std::cerr]
Loading…
Cancel
Save