[eradicate] read the procedure attributes directly

Summary: Always read the attributes from the attributes DB instead of trying to read the attributes from the analysis summaries

Reviewed By: mbouaziz

Differential Revision: D9845085

fbshipit-source-id: aef48e6bf
master
Jeremy Dubreil 6 years ago committed by Facebook Github Bot
parent e24ce31744
commit ff851040fc

@ -168,9 +168,7 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
in in
is_private && same_class is_private && same_class
in in
let private_called = let private_called = PatternMatch.proc_calls Attributes.load init_pd filter in
PatternMatch.proc_calls Summary.proc_resolve_attributes init_pd filter
in
let do_called (callee_pn, _) = let do_called (callee_pn, _) =
match Ondemand.get_proc_desc callee_pn with match Ondemand.get_proc_desc callee_pn with
| Some callee_pd -> | Some callee_pd ->
@ -218,7 +216,7 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
let pname_and_pdescs_with f = let pname_and_pdescs_with f =
let res = ref [] in let res = ref [] in
let filter pname = let filter pname =
match Summary.proc_resolve_attributes pname with match Attributes.load pname with
| Some proc_attributes -> | Some proc_attributes ->
f (pname, proc_attributes) f (pname, proc_attributes)
| None -> | None ->

@ -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) ignore (List.fold2_exn ~f:compare ~init:initial_pos current_params overridden_params)
in in
let check overriden_proc_name = let check overriden_proc_name =
match Summary.proc_resolve_attributes overriden_proc_name with match Attributes.load overriden_proc_name with
| Some attributes -> ( | Some attributes -> (
let overridden_signature = Models.get_modelled_annotated_signature attributes in let overridden_signature = Models.get_modelled_annotated_signature attributes in
check_params overriden_proc_name overridden_signature ; check_params overriden_proc_name overridden_signature ;

@ -19,7 +19,7 @@ module ComplexExpressions = struct
let procname_instanceof = Typ.Procname.equal BuiltinDecl.__instanceof let procname_instanceof = Typ.Procname.equal BuiltinDecl.__instanceof
let procname_is_false_on_null pn = let procname_is_false_on_null pn =
match Summary.proc_resolve_attributes pn with match Attributes.load pn with
| Some proc_attributes -> | Some proc_attributes ->
let annotated_signature = Models.get_modelled_annotated_signature proc_attributes in let annotated_signature = Models.get_modelled_annotated_signature proc_attributes in
let ret_ann, _ = annotated_signature.AnnotatedSignature.ret in let ret_ann, _ = annotated_signature.AnnotatedSignature.ret in
@ -30,7 +30,7 @@ module ComplexExpressions = struct
let procname_is_true_on_null pn = let procname_is_true_on_null pn =
let annotated_true_on_null () = let annotated_true_on_null () =
match Summary.proc_resolve_attributes pn with match Attributes.load pn with
| Some proc_attributes -> | Some proc_attributes ->
let annotated_signature = Models.get_modelled_annotated_signature proc_attributes in let annotated_signature = Models.get_modelled_annotated_signature proc_attributes in
let ret_ann, _ = annotated_signature.AnnotatedSignature.ret 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_ , etl_
, loc , loc
, cflags ) -> , cflags ) ->
let callee_summary_opt = Ondemand.analyze_proc_name ~caller_pdesc:curr_pdesc callee_pname in
let callee_attributes = let callee_attributes =
let proc_attriutes_opt = match Attributes.load callee_pname with
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
| Some proc_attributes -> | Some proc_attributes ->
proc_attributes proc_attributes
| None -> | 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 -> when Models.is_noreturn callee_pname ->
noreturn := true noreturn := true
| Sil.Call (_, Exp.Const (Const.Cfun callee_pname), _, _, _) -> | 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 *) (* check if the call might throw an exception *)
let has_exceptions = let has_exceptions =
match callee_attributes_opt with match callee_attributes_opt with

@ -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$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, 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.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.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.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()`.] 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()`.]

Loading…
Cancel
Save