Buckets comments and cosmetics

Reviewed By: sblackshear

Differential Revision: D5975176

fbshipit-source-id: f3a028f
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 929c9c07a1
commit 4873e78440

@ -25,11 +25,10 @@ let string_of_visibility vis =
match vis with Exn_user -> "user" | Exn_developer -> "developer" | Exn_system -> "system"
(** severity of bugs *)
type severity = High (* high severity bug *)
| Medium (* medium severity bug *)
| Low
(* low severity bug *)
type severity =
| High (** high severity bug *)
| Medium (** medium severity bug *)
| Low (** low severity bug *)
(** class of error/warning *)
type err_class = Checker | Prover | Nocat | Linters [@@deriving compare]

@ -41,7 +41,7 @@ module Tags = struct
(* line where value was last assigned *)
let bucket = "bucket"
(* bucket to classify likelyhood of real bug *)
(* bucket to classify likelihood of real bug *)
let call_procedure = "call_procedure"
(* name of the procedure called *)
@ -146,18 +146,17 @@ let error_desc_get_tags err_desc = err_desc.tags
let error_desc_get_dotty err_desc = err_desc.dotty
module BucketLevel = struct
(** highest likelihood *)
let b1 = "B1"
(* highest likelyhood *)
let b2 = "B2"
let b3 = "B3"
let b4 = "B4"
(** lowest likelihood *)
let b5 = "B5"
(* lowest likelyhood *)
end
(** takes in input a tag to extract from the given error_desc
@ -178,12 +177,14 @@ let error_desc_get_tag_call_procedure error_desc =
(** get the bucket value of an error_desc, if any *)
let error_desc_get_bucket err_desc = Tags.get err_desc.tags Tags.bucket
(** set the bucket value of an error_desc; the boolean indicates where the bucket should be shown in the message *)
let error_desc_set_bucket err_desc bucket show_in_message =
let tags' = Tags.add err_desc.tags Tags.bucket bucket in
let l = err_desc.descriptions in
let l' = if not show_in_message then l else ("[" ^ bucket ^ "]") :: l in
{err_desc with descriptions= l'; tags= tags'}
(** set the bucket value of an error_desc *)
let error_desc_set_bucket err_desc bucket =
let tags = Tags.add err_desc.tags Tags.bucket bucket in
let descriptions =
if Config.show_buckets then Printf.sprintf "[%s]" bucket :: err_desc.descriptions
else err_desc.descriptions
in
{err_desc with descriptions; tags}
(** get the value tag, if any *)
let get_value_line_tag tags =
@ -791,7 +792,7 @@ let desc_leak hpred_type_opt value_str_opt resource_opt resource_action_opt loc
let desc_buffer_overrun bucket desc =
let err_desc = {no_desc with descriptions= [desc]} in
error_desc_set_bucket err_desc bucket Config.show_buckets
error_desc_set_bucket err_desc bucket
(** kind of precondition not met *)
type pnm_kind = Pnm_bounds | Pnm_dangling

@ -44,7 +44,7 @@ val custom_desc_with_advice : string -> string -> (string * string) list -> erro
module BucketLevel : sig
val b1 : string
(** highest likelyhood *)
(** highest likelihood *)
val b2 : string
@ -53,7 +53,7 @@ module BucketLevel : sig
val b4 : string
val b5 : string
(** lowest likelyhood *)
(** lowest likelihood *)
end
val error_desc_extract_tag_value : error_desc -> string -> string
@ -71,9 +71,8 @@ val error_desc_get_tag_call_procedure : error_desc -> string
val error_desc_get_bucket : error_desc -> string option
(** get the bucket value of an error_desc, if any *)
val error_desc_set_bucket : error_desc -> string -> bool -> error_desc
(** set the bucket value of an error_desc.
The boolean indicates where the bucket should be shown in the message *)
val error_desc_set_bucket : error_desc -> string -> error_desc
(** set the bucket value of an error_desc *)
val error_desc_hash : error_desc -> int
(** hash function for error_desc *)

@ -148,9 +148,5 @@ let check_access access_opt de_opt =
let classify_access desc access_opt de_opt is_nullable =
let default_bucket = if is_nullable then Localise.BucketLevel.b1 else Localise.BucketLevel.b5 in
let show_in_message = Config.show_buckets in
match check_access access_opt de_opt with
| None
-> Localise.error_desc_set_bucket desc default_bucket show_in_message
| Some bucket
-> Localise.error_desc_set_bucket desc bucket show_in_message
let bucket = check_access access_opt de_opt |> Option.value ~default:default_bucket in
Localise.error_desc_set_bucket desc bucket

@ -1675,9 +1675,7 @@ let check_call_to_objc_block_error tenv pdesc prop fun_exp loc =
-> (
let e_opt, is_field_deref = is_field_deref () in
let warn err_desc =
let err_desc =
Localise.error_desc_set_bucket err_desc Localise.BucketLevel.b1 Config.show_buckets
in
let err_desc = Localise.error_desc_set_bucket err_desc Localise.BucketLevel.b1 in
if is_field_deref then raise (Exceptions.Field_not_null_checked (err_desc, __POS__))
else raise (Exceptions.Parameter_not_null_checked (err_desc, __POS__))
in
@ -1692,10 +1690,7 @@ let check_call_to_objc_block_error tenv pdesc prop fun_exp loc =
| _
-> (* HP: fun_exp is not a footprint therefore,
either is a local or it's a modified param *)
let err_desc =
Localise.error_desc_set_bucket err_desc_nobuckets Localise.BucketLevel.b1
Config.show_buckets
in
let err_desc = Localise.error_desc_set_bucket err_desc_nobuckets Localise.BucketLevel.b1 in
raise (Exceptions.Null_dereference (err_desc, __POS__))
(** [rearrange lexp prop] rearranges [prop] into the form [prop' * lexp|->strexp:typ].

Loading…
Cancel
Save