diff --git a/infer/src/checkers/annotations.ml b/infer/src/checkers/annotations.ml index 6f7abef9e..43a3e4fa9 100644 --- a/infer/src/checkers/annotations.ml +++ b/infer/src/checkers/annotations.ml @@ -110,10 +110,11 @@ let strict = "com.facebook.infer.annotation.Strict" let true_on_null = "TrueOnNull" let verify_annotation = "com.facebook.infer.annotation.Verify" let expensive = "Expensive" +let calls_expensive = "CallsExpensive" let performance_critical = "PerformanceCritical" -let expensive_annotation = { - Sil.class_name = expensive; +let calls_expensive_annotation = { + Sil.class_name = calls_expensive; Sil.parameters = [] } @@ -157,6 +158,9 @@ let ia_is_verify ia = let ia_is_expensive ia = ia_ends_with ia expensive +let ia_calls_expensive ia = + ia_is_expensive ia || ia_ends_with ia calls_expensive + let ia_is_performance_critical ia = ia_ends_with ia performance_critical diff --git a/infer/src/checkers/annotations.mli b/infer/src/checkers/annotations.mli index 232bbd9a4..75eaab7ae 100644 --- a/infer/src/checkers/annotations.mli +++ b/infer/src/checkers/annotations.mli @@ -14,7 +14,7 @@ val suppressLint : string val expensive : string val performance_critical : string -val expensive_annotation : Sil.annotation +val calls_expensive_annotation : Sil.annotation type annotation = | Nullable @@ -71,6 +71,7 @@ val ia_is_present : Sil.item_annotation -> bool val ia_is_true_on_null : Sil.item_annotation -> bool val ia_is_verify : Sil.item_annotation -> bool val ia_is_expensive : Sil.item_annotation -> bool +val ia_calls_expensive : Sil.item_annotation -> bool val ia_is_performance_critical : Sil.item_annotation -> bool val ia_iter : (Sil.annotation -> unit) -> Sil.item_annotation -> unit diff --git a/infer/src/checkers/performanceCritical.ml b/infer/src/checkers/performanceCritical.ml index 08759612c..8249d5bb9 100644 --- a/infer/src/checkers/performanceCritical.ml +++ b/infer/src/checkers/performanceCritical.ml @@ -32,7 +32,7 @@ let search_expensive_call checked_pnames expensive_callee (pname, _) = | Some attributes -> let annotated_signature = Annotations.get_annotated_signature attributes in let ret_annotation, _ = annotated_signature.Annotations.ret in - if Annotations.ia_is_expensive ret_annotation then + if Annotations.ia_calls_expensive ret_annotation then Some pname else None @@ -121,7 +121,7 @@ let callback_performance_checker _ _ _ tenv pname pdesc = | Some _ when not expensive -> let ret_annot, param_annot = attributes.ProcAttributes.method_annotation in let updated_method_annot = - (Annotations.expensive_annotation, true) :: ret_annot, param_annot in + (Annotations.calls_expensive_annotation, true) :: ret_annot, param_annot in let updated_attributes = { attributes with ProcAttributes.method_annotation = updated_method_annot } in AttributesTable.store_attributes updated_attributes