diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index ff0c09d12..a9b8e8f31 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1548,6 +1548,18 @@ INTERNAL OPTIONS Activates: Warn when containers are used with nullable keys or values (Conversely: --no-nullsafe-strict-containers) + --nullsafe-third-party-location-for-messaging-only string + Path to a folder with annotated signatures to include into error + message. If not specified, path will be fetched from + nullsafe-third-party-signatures. This param is only needed for the + case when the real repository is located in the different place, + and nullsafe-third-party-signatures contains only its copy (which + can happen e.g. in case of caching by the build system) + + --nullsafe-third-party-location-for-messaging-only-reset + Cancel the effect of + --nullsafe-third-party-location-for-messaging-only. + --nullsafe-third-party-signatures string Path to a folder with annotated signatures of third-party methods to be taken into account by nullsafe. Path is either relative to diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 4f9280572..111494a02 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1756,6 +1756,15 @@ and nullsafe_third_party_signatures = nullsafe. Path is either relative to .inferconfig folder or absolute" +and nullsafe_third_party_location_for_messaging_only = + CLOpt.mk_string_opt ~long:"nullsafe-third-party-location-for-messaging-only" + "Path to a folder with annotated signatures to include into error message. If not specified, \ + path will be fetched from nullsafe-third-party-signatures. This param is only needed for the \ + case when the real repository is located in the different place, and \ + nullsafe-third-party-signatures contains only its copy (which can happen e.g. in case of \ + caching by the build system)" + + and nullsafe_strict_containers = CLOpt.mk_bool ~long:"nullsafe-strict-containers" ~default:false "Warn when containers are used with nullable keys or values" @@ -3006,6 +3015,10 @@ and nullable_annotation = !nullable_annotation and nullsafe_third_party_signatures = !nullsafe_third_party_signatures +and nullsafe_third_party_location_for_messaging_only = + !nullsafe_third_party_location_for_messaging_only + + and nullsafe_strict_containers = !nullsafe_strict_containers and no_translate_libs = not !headers diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 31606d613..5331e1ddf 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -500,6 +500,8 @@ val nullsafe : bool val nullsafe_third_party_signatures : string option +val nullsafe_third_party_location_for_messaging_only : string option + val nullsafe_strict_containers : bool val oom_threshold : int option diff --git a/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.ml b/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.ml index 3b63ceb2a..197458035 100644 --- a/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.ml +++ b/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.ml @@ -38,11 +38,16 @@ let get_last_2_dirs path = String.concat last_2_dirs ~sep:"/" -let get_user_friendly_third_party_sig_file_name ~filename = - (* Enough details that will hint the user to where to look for the file. *) - let absolute_path_opt = get_absolute_path_to_repo () in +let get_from_absolute_path () = (* If we got file_name from somewhere, it definitely means the repo exists. *) - let absolute_path = Option.value_exn absolute_path_opt in - (* Take last 2 dirs: the last one is one with the folder itself, and the previous will indicate - the location *) - get_last_2_dirs absolute_path ^ "/" ^ filename + Option.value_exn (get_absolute_path_to_repo ()) + (* Enough details to have an idea where to look *) + |> get_last_2_dirs + + +let get_user_friendly_third_party_sig_file_name ~filename = + let path = + Config.nullsafe_third_party_location_for_messaging_only + |> Option.value ~default:(get_from_absolute_path ()) + in + path ^ "/" ^ filename