From 9bdd1a9d0fa69d74e98773a436623c5a351370ba Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 16 Feb 2016 14:23:56 -0800 Subject: [PATCH] Enable -principal to check ambiguous code Summary:public Type-based resolution of fields, constructors, etc. can be ambiguous if types are not principal. Compile with -principal and enable warnings 18 and 19 to check these cases. Reviewed By: jvillard Differential Revision: D2938237 fb-gh-sync-id: bb4237b shipit-source-id: bb4237b --- infer/src/Makefile.in | 12 +++++++++++- infer/src/backend/localise.ml | 2 +- infer/src/backend/procname.ml | 2 +- infer/src/harness/stacktrace.ml | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/infer/src/Makefile.in b/infer/src/Makefile.in index b704d788f..d4c9c99a0 100644 --- a/infer/src/Makefile.in +++ b/infer/src/Makefile.in @@ -77,7 +77,17 @@ OCAMLBUILD_OPTIONS = \ $(OCAMLBUILD_BINANNOT_OPTIONS) \ $(OCAMLBUILD_QUIET_OPTIONS) \ -classic-display \ - -cflags -warn-error,@5@8@10..12@20@26@39 \ + -cflags -principal \ + -cflags -w,@5 \ + -cflags -w,@8 \ + -cflags -w,@10 \ + -cflags -w,@11 \ + -cflags -w,@12 \ + -cflags -w,@18 \ + -cflags -w,@19 \ + -cflags -w,@20 \ + -cflags -w,@26 \ + -cflags -w,@39 \ -lflags $(OCAML_INCLUDES) \ -cflags $(OCAML_INCLUDES) \ $(addprefix -lib ,$(OCAML_LIBS)) \ diff --git a/infer/src/backend/localise.ml b/infer/src/backend/localise.ml index 1bba02f90..95c6f923e 100644 --- a/infer/src/backend/localise.ml +++ b/infer/src/backend/localise.ml @@ -489,7 +489,7 @@ let dereference_string deref_str value_str access_opt loc = [(problem_str ^ " " ^ at_line tags loc)] in { no_desc with descriptions = value_desc:: access_desc @ problem_desc; tags = !tags } -let parameter_field_not_null_checked_desc desc exp = +let parameter_field_not_null_checked_desc (desc : error_desc) exp = let parameter_not_nullable_desc var = let var_s = Sil.pvar_to_string var in let param_not_null_desc = diff --git a/infer/src/backend/procname.ml b/infer/src/backend/procname.ml index 234989e42..3d4ef4156 100644 --- a/infer/src/backend/procname.ml +++ b/infer/src/backend/procname.ml @@ -281,7 +281,7 @@ let java_is_static = function | _ -> assert false (** Prints a string of a java procname with the given level of verbosity *) -let java_to_string ?(withclass = false) j verbosity = +let java_to_string ?(withclass = false) (j : java_signature) verbosity = match verbosity with | Verbose | Non_verbose -> (* if verbose, then package.class.method(params): rtype, diff --git a/infer/src/harness/stacktrace.ml b/infer/src/harness/stacktrace.ml index 923141501..1219b0b09 100644 --- a/infer/src/harness/stacktrace.ml +++ b/infer/src/harness/stacktrace.ml @@ -36,7 +36,7 @@ type stack_frame = type stack_trace = stack_frame list (** given [str_frame], try to resolve its components in [exe_env] *) -let try_resolve_frame str_frame exe_env tenv = +let try_resolve_frame (str_frame : str_frame) exe_env tenv = try let class_name = Mangled.from_string str_frame.class_str in (* find the class name in the tenv and get the procedure(s) whose names match the procedure name