make printfArgs an `intraprocedural`

Summary: Making checkers/ its own dune library.

Reviewed By: ngorogiannis

Differential Revision: D21407067

fbshipit-source-id: 04fe20574
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 1de6dac41a
commit 2fee63ef75

@ -15,12 +15,6 @@ let log_error summary ~loc ?ltr ?extras issue_type error_message =
Reporting.log_error attrs err_log ~loc ?ltr ?extras issue_type error_message
let log_warning summary ~loc ?ltr ?extras issue_type error_message =
let attrs = Summary.get_attributes summary in
let err_log = Summary.get_err_log summary in
Reporting.log_warning attrs err_log ~loc ?ltr ?extras issue_type error_message
let log_error_using_state summary exn =
BiabductionReporting.log_error_using_state (Summary.get_proc_desc summary)
(Summary.get_err_log summary) exn

@ -14,8 +14,5 @@ type log_t = Reporting.log_t
val log_error : Summary.t -> loc:Location.t -> log_t
(** Add an error to the given summary. *)
val log_warning : Summary.t -> loc:Location.t -> log_t
(** Add a warning to the given summary. *)
val log_error_using_state : Summary.t -> exn -> unit
(** Add an error to the given summary using biabduction state (DO NOT USE ELSEWHERE). *)

@ -169,7 +169,7 @@ let all_checkers =
[(impurity, Language.Java); (impurity, Language.Clang)] ) }
; { name= "printf args"
; active= Config.is_checker_enabled PrintfArgs
; callbacks= [(Procedure PrintfArgs.callback_printf_args, Language.Java)] }
; callbacks= [(intraprocedural PrintfArgs.checker, Language.Java)] }
; { name= "liveness"
; active= Config.is_checker_enabled Liveness
; callbacks= [(intraprocedural Liveness.checker, Language.Clang)] }

@ -98,7 +98,8 @@ let rec format_string_type_names (fmt_string : string) (start : int) : string li
let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc_name : Procname.t)
(proc_desc : Procdesc.t) summary : unit =
(proc_desc : Procdesc.t) err_log : unit =
let attrs = Procdesc.get_attributes proc_desc in
(* Check if format string lines up with arguments *)
let rec check_type_names instr_loc n_arg instr_proc_name fmt_type_names arg_type_names =
let instr_name = Procname.to_simplified_string instr_proc_name in
@ -111,7 +112,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
"%s at line %s: parameter %d is expected to be of type %s but %s was given."
instr_name instr_line n_arg (default_format_type_name ft) gt
in
SummaryReporting.log_error summary ~loc:instr_loc IssueType.checkers_printf_args
Reporting.log_error attrs err_log ~loc:instr_loc IssueType.checkers_printf_args
description
else check_type_names instr_loc (n_arg + 1) instr_proc_name fs gs
| [], [] ->
@ -121,7 +122,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
Printf.sprintf "format string arguments don't mach provided arguments in %s at line %s"
instr_name instr_line
in
SummaryReporting.log_error summary ~loc:instr_loc IssueType.checkers_printf_args description
Reporting.log_error attrs err_log ~loc:instr_loc IssueType.checkers_printf_args description
in
(* Get the array ivar for a given nvar *)
let array_ivar instrs nvar =
@ -157,7 +158,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
vararg_ivar_type_names
| None ->
if not (Reporting.is_suppressed tenv proc_desc IssueType.checkers_printf_args) then
SummaryReporting.log_warning summary ~loc:cl IssueType.checkers_printf_args
Reporting.log_warning attrs err_log ~loc:cl IssueType.checkers_printf_args
"Format string must be string literal"
with e ->
L.internal_error "%s Exception when analyzing %s: %s@."
@ -169,11 +170,8 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
()
let callback_printf_args {Callbacks.exe_env; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} =
let proc_name = Procdesc.get_proc_name proc_desc in
let tenv = Exe_env.get_tenv exe_env proc_name in
Procdesc.iter_instrs
(fun n i -> check_printf_args_ok tenv n i proc_name proc_desc summary)
proc_desc ;
summary
(fun n i -> check_printf_args_ok tenv n i proc_name proc_desc err_log)
proc_desc

@ -7,4 +7,4 @@
open! IStd
val callback_printf_args : Callbacks.proc_callback_t
val checker : IntraproceduralAnalysis.t -> unit

Loading…
Cancel
Save