diff --git a/infer/man/man1/infer-capture.txt b/infer/man/man1/infer-capture.txt index 161a69f8d..92ce190d0 100644 --- a/infer/man/man1/infer-capture.txt +++ b/infer/man/man1/infer-capture.txt @@ -267,8 +267,9 @@ CLANG OPTIONS Activates: Skip clang commands that Infer doesn't use to capture data (Conversely: --no-skip-non-capture-clang-commands) - --skip-translation-headers +path_prefix - Ignore headers whose path matches the given prefix + --skip-translation-headers +path_regex + Ignore declarations in headers whose path matches the given OCaml + regex from the start of the string during capture. --Xclang +string Pass values as command-line arguments to invocations of clang diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index aae52535e..11935bd6c 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1203,8 +1203,9 @@ OPTIONS data (Conversely: --no-skip-non-capture-clang-commands) See also infer-capture(1). - --skip-translation-headers +path_prefix - Ignore headers whose path matches the given prefix See also infer-capture(1). + --skip-translation-headers +path_regex + Ignore declarations in headers whose path matches the given OCaml + regex from the start of the string during capture. See also infer-capture(1). --source-files Activates: Print source files discovered by infer (Conversely: diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 1fd5e343c..bca6fa8f3 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -1203,8 +1203,9 @@ OPTIONS data (Conversely: --no-skip-non-capture-clang-commands) See also infer-capture(1). - --skip-translation-headers +path_prefix - Ignore headers whose path matches the given prefix See also infer-capture(1). + --skip-translation-headers +path_regex + Ignore declarations in headers whose path matches the given OCaml + regex from the start of the string during capture. See also infer-capture(1). --source-files Activates: Print source files discovered by infer (Conversely: diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 4866e89c2..edb59e0d1 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -2330,7 +2330,9 @@ and skip_non_capture_clang_commands = and skip_translation_headers = CLOpt.mk_string_list ~deprecated:["skip_translation_headers"] ~long:"skip-translation-headers" ~in_help:InferCommand.[(Capture, manual_clang)] - ~meta:"path_prefix" "Ignore headers whose path matches the given prefix" + ~meta:"path_regex" + "Ignore declarations in headers whose path matches the given OCaml regex from the start of the \ + string during capture." and source_preview = diff --git a/infer/src/clang/cLocation.ml b/infer/src/clang/cLocation.ml index a7815852c..2bceaf526 100644 --- a/infer/src/clang/cLocation.ml +++ b/infer/src/clang/cLocation.ml @@ -20,14 +20,19 @@ let clang_to_sil_location default_source_file clang_loc = Location.{line; col; file} +let matches_skip_translation_headers = + match Config.skip_translation_headers with + | [] -> + fun _ -> false + | reg_list -> + let regex = Re.Str.regexp (String.concat ~sep:"\\|" reg_list) in + fun file -> Re.Str.string_match regex file 0 + + let source_file_in_project source_file = let file_in_project = SourceFile.is_under_project_root source_file in - let rel_source_file = SourceFile.to_string source_file in - let file_should_be_skipped = - List.exists - ~f:(fun path -> String.is_prefix ~prefix:path rel_source_file) - Config.skip_translation_headers - in + let source_file_path = SourceFile.to_string source_file in + let file_should_be_skipped = matches_skip_translation_headers source_file_path in file_in_project && not file_should_be_skipped