diff --git a/infer/src/clang/ClangCommand.ml b/infer/src/clang/ClangCommand.ml index 2af358aa2..a4666e994 100644 --- a/infer/src/clang/ClangCommand.ml +++ b/infer/src/clang/ClangCommand.ml @@ -124,8 +124,12 @@ let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s) ?( aux in_argfiles' (false, at_argfile :: res_rev, changed) tl ) | flag :: tl when List.mem ~equal:String.equal Config.clang_blacklisted_flags flag - || List.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg - (String.split ~on:'=' flag |> List.hd |> Option.value ~default:"") -> + || String.lsplit2 ~on:'=' flag + |> function + | Some (flag, _arg) -> + List.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag + | None -> + false -> aux in_argfiles (false, res_rev, true) tl | flag :: tl when List.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag -> (* remove the flag and its arg separately in case we are at the end of an argfile *) diff --git a/infer/tests/build_systems/clang_with_blacklisted_flags/Makefile b/infer/tests/build_systems/clang_with_blacklisted_flags/Makefile index 3dfd060b7..dddeea8c1 100644 --- a/infer/tests/build_systems/clang_with_blacklisted_flags/Makefile +++ b/infer/tests/build_systems/clang_with_blacklisted_flags/Makefile @@ -10,8 +10,8 @@ TESTS_DIR = ../.. # a folder, is not discarded, and Clang considers it as a source file. This # leads to an error. This weird case can be observed when -index-store-path is # passed in a sequence like the one in CLANG_OPTIONS. -CLANG_OPTIONS = -x c -index-store-path . -c -fsanitize=builtin -fsanitize=address,builtin -INFER_OPTIONS = --report-custom-error --developer-mode --project-root ../codetoanalyze +CLANG_OPTIONS = -x c -index-store-path . -c -fsanitize=builtin -fsanitize=address,builtin -bogus=arg +INFER_OPTIONS = --report-custom-error --developer-mode --project-root ../codetoanalyze --clang-blacklisted-flags-with-arg -bogus INFERPRINT_OPTIONS = --issues-tests SOURCES = ../codetoanalyze/hello.c