distinguish between the user added annotation @Expensive and the inferred annotation @CallsExpensive

Summary: public
We should be able to distinguish if a method is annotated with Expensive and has been automatically annotated as calling an expensive method using internally the annotation CallsExpensive in the later case.

Reviewed By: cristianoc

Differential Revision: D2640478

fb-gh-sync-id: 32a7ee9
master
jrm 9 years ago committed by facebook-github-bot-7
parent 07ebdc0918
commit b1b9cbe771

@ -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

@ -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

@ -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

Loading…
Cancel
Save