add clang_method_kind field to AnalysisIssue

Summary: Add new clang_method_kind field to AnalysisIssue, logged similarly to the existing one in AnalysisStats

Reviewed By: dulmarod

Differential Revision: D7273660

fbshipit-source-id: d1ca79b
master
Varun Arora 7 years ago committed by Facebook Github Bot
parent 266ae2ed6e
commit 9387706a54

@ -234,8 +234,9 @@ let update errlog_old errlog_new =
ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new
let log_issue procname err_kind err_log loc (node_id, node_key) session ltr ?linters_def_file let log_issue procname ?clang_method_kind err_kind err_log loc (node_id, node_key) session ltr
?doc_url ?access exn = ?linters_def_file ?doc_url ?access exn =
let lang = Typ.Procname.get_language procname in
let error = Exceptions.recognize_exception exn in let error = Exceptions.recognize_exception exn in
let err_kind = match error.kind with Some err_kind -> err_kind | _ -> err_kind in let err_kind = match error.kind with Some err_kind -> err_kind | _ -> err_kind in
let hide_java_loc_zero = let hide_java_loc_zero =
@ -263,11 +264,11 @@ let log_issue procname err_kind err_log loc (node_id, node_key) session ltr ?lin
( if exn_developer then ( if exn_developer then
let issue = let issue =
EventLogger.AnalysisIssue EventLogger.AnalysisIssue
(* TODO: Add clang_method_kind field (T26423401) *)
{ bug_type= error.name.IssueType.unique_id { bug_type= error.name.IssueType.unique_id
; bug_kind= Exceptions.err_kind_string err_kind ; bug_kind= Exceptions.err_kind_string err_kind
; clang_method_kind= (match lang with Language.Clang -> clang_method_kind | _ -> None)
; exception_triggered_location= error.ocaml_pos ; exception_triggered_location= error.ocaml_pos
; lang= Typ.Procname.get_language procname |> Language.to_explicit_string ; lang= Language.to_explicit_string lang
; procedure_name= Typ.Procname.to_string procname ; procedure_name= Typ.Procname.to_string procname
; source_location= loc } ; source_location= loc }
in in

@ -93,5 +93,6 @@ val update : t -> t -> unit
(** Update an old error log with a new one *) (** Update an old error log with a new one *)
val log_issue : val log_issue :
Typ.Procname.t -> Exceptions.err_kind -> t -> Location.t -> int * Caml.Digest.t -> int Typ.Procname.t -> ?clang_method_kind:string -> Exceptions.err_kind -> t -> Location.t
-> loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> exn -> unit -> int * Caml.Digest.t -> int -> loc_trace -> ?linters_def_file:string -> ?doc_url:string
-> ?access:string -> exn -> unit

@ -33,7 +33,7 @@ type clang_method_kind =
| C_FUNCTION | C_FUNCTION
[@@deriving compare] [@@deriving compare]
let clang_method_kind_equal = [%compare.equal : clang_method_kind] let equal_clang_method_kind = [%compare.equal : clang_method_kind]
let string_of_clang_method_kind = function let string_of_clang_method_kind = function
| CPP_INSTANCE -> | CPP_INSTANCE ->

@ -23,7 +23,7 @@ type clang_method_kind =
| C_FUNCTION | C_FUNCTION
[@@deriving compare] [@@deriving compare]
val clang_method_kind_equal : clang_method_kind -> clang_method_kind -> bool val equal_clang_method_kind : clang_method_kind -> clang_method_kind -> bool
val string_of_clang_method_kind : clang_method_kind -> string val string_of_clang_method_kind : clang_method_kind -> string

@ -996,12 +996,12 @@ let check_inconsistency_base tenv prop =
let is_objc_instance_self pvar = let is_objc_instance_self pvar =
Language.equal language Clang Language.equal language Clang
&& Mangled.equal (Pvar.get_name pvar) (Mangled.from_string "self") && Mangled.equal (Pvar.get_name pvar) (Mangled.from_string "self")
&& ProcAttributes.clang_method_kind_equal procedure_attr.ProcAttributes.clang_method_kind && ProcAttributes.equal_clang_method_kind procedure_attr.ProcAttributes.clang_method_kind
ProcAttributes.OBJC_INSTANCE ProcAttributes.OBJC_INSTANCE
in in
let is_cpp_this pvar = let is_cpp_this pvar =
Language.equal language Clang && Pvar.is_this pvar Language.equal language Clang && Pvar.is_this pvar
&& ProcAttributes.clang_method_kind_equal procedure_attr.ProcAttributes.clang_method_kind && ProcAttributes.equal_clang_method_kind procedure_attr.ProcAttributes.clang_method_kind
ProcAttributes.CPP_INSTANCE ProcAttributes.CPP_INSTANCE
in in
let do_hpred = function let do_hpred = function

@ -16,8 +16,11 @@ type log_t =
type log_issue_from_errlog = Errlog.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t
let log_issue_from_errlog procname err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file let log_issue_from_errlog procname ?clang_method_kind err_kind err_log ?loc ?node_id ?session ?ltr
?doc_url ?access exn = ?linters_def_file ?doc_url ?access exn =
let clang_method_kind =
Option.map clang_method_kind ~f:ProcAttributes.string_of_clang_method_kind
in
let issue_type = (Exceptions.recognize_exception exn).name in let issue_type = (Exceptions.recognize_exception exn).name in
if not Config.filtering (* no-filtering takes priority *) || issue_type.IssueType.enabled then if not Config.filtering (* no-filtering takes priority *) || issue_type.IssueType.enabled then
let loc = match loc with None -> State.get_loc () | Some loc -> loc in let loc = match loc with None -> State.get_loc () | Some loc -> loc in
@ -32,13 +35,15 @@ let log_issue_from_errlog procname err_kind err_log ?loc ?node_id ?session ?ltr
match session with None -> (State.get_session () :> int) | Some session -> session match session with None -> (State.get_session () :> int) | Some session -> session
in in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
Errlog.log_issue procname err_kind err_log loc node_id session ltr ?linters_def_file ?doc_url Errlog.log_issue procname ?clang_method_kind err_kind err_log loc node_id session ltr
?access exn ?linters_def_file ?doc_url ?access exn
let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file ?doc_url let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file ?doc_url
?access exn = ?access exn =
let procname = Specs.get_proc_name summary in let attrs = Specs.get_attributes summary in
let procname = attrs.proc_name in
let clang_method_kind = attrs.clang_method_kind in
let is_java_generated_method = let is_java_generated_method =
match procname with match procname with
| Typ.Procname.Java java_pname -> | Typ.Procname.Java java_pname ->
@ -54,8 +59,8 @@ let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters
if should_suppress_lint || is_java_generated_method then () (* Skip the reporting *) if should_suppress_lint || is_java_generated_method then () (* Skip the reporting *)
else else
let err_log = Specs.get_err_log summary in let err_log = Specs.get_err_log summary in
log_issue_from_errlog procname err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file log_issue_from_errlog procname ~clang_method_kind err_kind err_log ?loc ?node_id ?session ?ltr
?doc_url ?access exn ?linters_def_file ?doc_url ?access exn
let log_issue_deprecated ?(store_summary= false) err_kind proc_name ?loc ?node_id ?session ?ltr let log_issue_deprecated ?(store_summary= false) err_kind proc_name ?loc ?node_id ?session ?ltr

@ -32,7 +32,9 @@ val log_info_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
DEPRECATED as it can create race conditions between checkers. DEPRECATED as it can create race conditions between checkers.
Use log_info instead *) Use log_info instead *)
val log_issue_from_errlog : Typ.Procname.t -> Exceptions.err_kind -> log_issue_from_errlog val log_issue_from_errlog :
Typ.Procname.t -> ?clang_method_kind:ProcAttributes.clang_method_kind -> Exceptions.err_kind
-> log_issue_from_errlog
(** Report an issue of a given kind in the given error log. *) (** Report an issue of a given kind in the given error log. *)
val log_error : Specs.summary -> log_t val log_error : Specs.summary -> log_t

@ -1277,7 +1277,7 @@ let rec sym_exec tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) path
prop path prop path
| None, false -> | None, false ->
let is_objc_instance_method = let is_objc_instance_method =
ProcAttributes.clang_method_kind_equal ProcAttributes.equal_clang_method_kind
attrs.ProcAttributes.clang_method_kind ProcAttributes.OBJC_INSTANCE attrs.ProcAttributes.clang_method_kind ProcAttributes.OBJC_INSTANCE
in in
skip_call ~is_objc_instance_method ~reason:"function or method not found" skip_call ~is_objc_instance_method ~reason:"function or method not found"

@ -74,6 +74,7 @@ end
type analysis_issue = type analysis_issue =
{ bug_kind: string { bug_kind: string
; bug_type: string ; bug_type: string
; clang_method_kind: string option
; exception_triggered_location: Logging.ocaml_pos option ; exception_triggered_location: Logging.ocaml_pos option
; lang: string ; lang: string
; procedure_name: string ; procedure_name: string
@ -83,6 +84,7 @@ let create_analysis_issue_row base record =
let open JsonBuilder in let open JsonBuilder in
base |> add_string ~key:"bug_kind" ~data:record.bug_kind base |> add_string ~key:"bug_kind" ~data:record.bug_kind
|> add_string ~key:"bug_type" ~data:record.bug_type |> add_string ~key:"bug_type" ~data:record.bug_type
|> add_string_opt ~key:"clang_method_kind" ~data:record.clang_method_kind
|> add_string_opt ~key:"exception_triggered_location" |> add_string_opt ~key:"exception_triggered_location"
~data:(Option.map ~f:Logging.ocaml_pos_to_string record.exception_triggered_location) ~data:(Option.map ~f:Logging.ocaml_pos_to_string record.exception_triggered_location)
|> add_string ~key:"lang" ~data:record.lang |> add_string ~key:"lang" ~data:record.lang

@ -10,6 +10,7 @@
type analysis_issue = type analysis_issue =
{ bug_kind: string { bug_kind: string
; bug_type: string ; bug_type: string
; clang_method_kind: string option
; exception_triggered_location: Logging.ocaml_pos option ; exception_triggered_location: Logging.ocaml_pos option
; lang: string ; lang: string
; procedure_name: string ; procedure_name: string

@ -41,7 +41,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
| _ -> | _ ->
Option.exists Option.exists
~f:(fun attributes -> ~f:(fun attributes ->
ProcAttributes.clang_method_kind_equal attributes.ProcAttributes.clang_method_kind ProcAttributes.equal_clang_method_kind attributes.ProcAttributes.clang_method_kind
ProcAttributes.CPP_INSTANCE ) ProcAttributes.CPP_INSTANCE )
(Specs.proc_resolve_attributes callee_pname) (Specs.proc_resolve_attributes callee_pname)
@ -49,7 +49,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_objc_instance_method callee_pname = let is_objc_instance_method callee_pname =
Option.exists Option.exists
~f:(fun attributes -> ~f:(fun attributes ->
ProcAttributes.clang_method_kind_equal attributes.ProcAttributes.clang_method_kind ProcAttributes.equal_clang_method_kind attributes.ProcAttributes.clang_method_kind
ProcAttributes.OBJC_INSTANCE ) ProcAttributes.OBJC_INSTANCE )
(Specs.proc_resolve_attributes callee_pname) (Specs.proc_resolve_attributes callee_pname)

@ -71,7 +71,7 @@ let rec is_objc_instance context =
is_objc_instance outer_context is_objc_instance outer_context
| None -> | None ->
let attrs = Procdesc.get_attributes context.procdesc in let attrs = Procdesc.get_attributes context.procdesc in
ProcAttributes.clang_method_kind_equal attrs.ProcAttributes.clang_method_kind ProcAttributes.equal_clang_method_kind attrs.ProcAttributes.clang_method_kind
ProcAttributes.OBJC_INSTANCE ProcAttributes.OBJC_INSTANCE

@ -349,7 +349,7 @@ let get_formal_parameters tenv ms =
&& CFrontend_config.equal_clang_lang ms.CMethodSignature.lang CFrontend_config.CPP && CFrontend_config.equal_clang_lang ms.CMethodSignature.lang CFrontend_config.CPP
in in
is_objc_self is_objc_self
&& ProcAttributes.clang_method_kind_equal ms.CMethodSignature.method_kind && ProcAttributes.equal_clang_method_kind ms.CMethodSignature.method_kind
ProcAttributes.OBJC_INSTANCE ProcAttributes.OBJC_INSTANCE
|| is_cxx_this || is_cxx_this
in in

Loading…
Cancel
Save