diff --git a/infer/src/eradicate/eradicate.ml b/infer/src/eradicate/eradicate.ml index 60d00a0dd..b271ba58f 100644 --- a/infer/src/eradicate/eradicate.ml +++ b/infer/src/eradicate/eradicate.ml @@ -168,9 +168,7 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct in is_private && same_class in - let private_called = - PatternMatch.proc_calls Summary.proc_resolve_attributes init_pd filter - in + let private_called = PatternMatch.proc_calls Attributes.load init_pd filter in let do_called (callee_pn, _) = match Ondemand.get_proc_desc callee_pn with | Some callee_pd -> @@ -218,7 +216,7 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct let pname_and_pdescs_with f = let res = ref [] in let filter pname = - match Summary.proc_resolve_attributes pname with + match Attributes.load pname with | Some proc_attributes -> f (pname, proc_attributes) | None -> diff --git a/infer/src/eradicate/eradicateChecks.ml b/infer/src/eradicate/eradicateChecks.ml index aea84c9da..78fedfec8 100644 --- a/infer/src/eradicate/eradicateChecks.ml +++ b/infer/src/eradicate/eradicateChecks.ml @@ -477,7 +477,7 @@ let check_overridden_annotations find_canonical_duplicate tenv proc_name proc_de ignore (List.fold2_exn ~f:compare ~init:initial_pos current_params overridden_params) in let check overriden_proc_name = - match Summary.proc_resolve_attributes overriden_proc_name with + match Attributes.load overriden_proc_name with | Some attributes -> ( let overridden_signature = Models.get_modelled_annotated_signature attributes in check_params overriden_proc_name overridden_signature ; diff --git a/infer/src/eradicate/typeCheck.ml b/infer/src/eradicate/typeCheck.ml index b10842acb..700406e8f 100644 --- a/infer/src/eradicate/typeCheck.ml +++ b/infer/src/eradicate/typeCheck.ml @@ -19,7 +19,7 @@ module ComplexExpressions = struct let procname_instanceof = Typ.Procname.equal BuiltinDecl.__instanceof let procname_is_false_on_null pn = - match Summary.proc_resolve_attributes pn with + match Attributes.load pn with | Some proc_attributes -> let annotated_signature = Models.get_modelled_annotated_signature proc_attributes in let ret_ann, _ = annotated_signature.AnnotatedSignature.ret in @@ -30,7 +30,7 @@ module ComplexExpressions = struct let procname_is_true_on_null pn = let annotated_true_on_null () = - match Summary.proc_resolve_attributes pn with + match Attributes.load pn with | Some proc_attributes -> let annotated_signature = Models.get_modelled_annotated_signature proc_attributes in let ret_ann, _ = annotated_signature.AnnotatedSignature.ret in @@ -492,15 +492,8 @@ let typecheck_instr tenv calls_this checks (node : Procdesc.Node.t) idenv curr_p , etl_ , loc , cflags ) -> - let callee_summary_opt = Ondemand.analyze_proc_name ~caller_pdesc:curr_pdesc callee_pname in let callee_attributes = - let proc_attriutes_opt = - Option.value_map - ~default:(Summary.proc_resolve_attributes callee_pname) - ~f:(fun summary -> Some (Summary.get_attributes summary)) - callee_summary_opt - in - match proc_attriutes_opt with + match Attributes.load callee_pname with | Some proc_attributes -> proc_attributes | None -> @@ -1044,7 +1037,7 @@ let typecheck_node tenv calls_this checks idenv curr_pname curr_pdesc find_canon when Models.is_noreturn callee_pname -> noreturn := true | Sil.Call (_, Exp.Const (Const.Cfun callee_pname), _, _, _) -> - let callee_attributes_opt = Summary.proc_resolve_attributes callee_pname in + let callee_attributes_opt = Attributes.load callee_pname in (* check if the call might throw an exception *) let has_exceptions = match callee_attributes_opt with diff --git a/infer/tests/codetoanalyze/java/eradicate/issues.exp b/infer/tests/codetoanalyze/java/eradicate/issues.exp index 8c3cfe87a..d99d5d5bd 100644 --- a/infer/tests/codetoanalyze/java/eradicate/issues.exp +++ b/infer/tests/codetoanalyze/java/eradicate/issues.exp @@ -27,6 +27,8 @@ codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD3():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 285)] codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Map.put(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 323)] codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 3, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestPut.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: null constant at line 323)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.TestInitializerBuilder.build():codetoanalyze.java.eradicate.TestInitializer, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition TestInitializerBuilder.required1 is always true according to the existing annotations.] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.TestInitializerBuilder.build():codetoanalyze.java.eradicate.TestInitializer, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition TestInitializerBuilder.required2 is always true according to the existing annotations.] codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java, codetoanalyze.java.eradicate.ExtendsExternalLibrary.externalMethod2(java.lang.Object):void, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `object` of method `ExtendsExternalLibrary.externalMethod2(...)` is not `@Nullable` but is declared `@Nullable`in the parent class method `SomeExternalClass.externalMethod2(...)`.] codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java, codetoanalyze.java.eradicate.InconsistentSubclassAnnotation.implementInAnotherFile(java.lang.String):java.lang.String, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `s` of method `InconsistentSubclassAnnotation.implementInAnotherFile(...)` is not `@Nullable` but is declared `@Nullable`in the parent class method `InconsistentSubclassAnnotationInterface.implementInAnotherFile(...)`.] codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java, codetoanalyze.java.eradicate.SubclassExample$B.foo():codetoanalyze.java.eradicate.SubclassExample$T, 0, ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION, no_bucket, WARNING, [Method `SubclassExample$B.foo()` is annotated with `@Nullable` but overrides unannotated method `SubclassExample$A.foo()`.]