diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index fff337b99..db08d2fdf 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1540,8 +1540,8 @@ INTERNAL OPTIONS --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 relative to - .inferconfig folder. + to be taken into account by nullsafe. Path is either relative to + .inferconfig folder or absolute --nullsafe-third-party-signatures-reset Cancel the effect of --nullsafe-third-party-signatures. diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 2f5a75242..a0277bfc6 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1761,7 +1761,7 @@ and nullable_annotation = and nullsafe_third_party_signatures = CLOpt.mk_string_opt ~long:"nullsafe-third-party-signatures" "Path to a folder with annotated signatures of third-party methods to be taken into account \ - by nullsafe. Path is relative to .inferconfig folder." + by nullsafe. Path is either relative to .inferconfig folder or absolute" and nullsafe_strict_containers = diff --git a/infer/src/nullsafe/NullsafeInit.ml b/infer/src/nullsafe/NullsafeInit.ml index ce5f01a3d..b64dd729f 100644 --- a/infer/src/nullsafe/NullsafeInit.ml +++ b/infer/src/nullsafe/NullsafeInit.ml @@ -21,20 +21,26 @@ let load_third_party_repo ~absolute_path_to_repo_dir = absolute_path_to_repo_dir -let get_absolute_path_to_repo_dir relative_path_to_repo_dir = - match Config.inferconfig_dir with - | None -> - Logging.die Logging.InternalError - "Could not locate .inferconfig directory, which is required for resolving the path to \ - third party annotation repository" - | Some inferconfig_dir -> - inferconfig_dir ^/ relative_path_to_repo_dir +let get_absolute_path_to_repo_dir path_to_repo_dir = + if Filename.is_absolute path_to_repo_dir then + (* By agreement, this means absolute path *) + path_to_repo_dir + else + (* By agreement, this means path relative to inferconfig dir *) + match Config.inferconfig_dir with + | None -> + Logging.die Logging.InternalError + "Could not locate .inferconfig directory, which is required for resolving the path to \ + third party annotation repository" + | Some inferconfig_dir -> + inferconfig_dir ^/ path_to_repo_dir let create_global_storage () = match Config.nullsafe_third_party_signatures with - | Some dir -> - load_third_party_repo ~absolute_path_to_repo_dir:(get_absolute_path_to_repo_dir dir) + | Some path_to_repo_dir -> + load_third_party_repo + ~absolute_path_to_repo_dir:(get_absolute_path_to_repo_dir path_to_repo_dir) (* Create empty *) | None -> ThirdPartyAnnotationInfo.create_storage ()