PrintfArgs is not an Eradicate checker

Reviewed By: jeremydubreil

Differential Revision: D9688756

fbshipit-source-id: 2487f15aa
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent 249ef9d75b
commit 46cd49df8d

@ -182,8 +182,13 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr)
check_type_names cl (printf.format_pos + 1) pn (format_string_type_names fmt 0)
(fixed_nvar_type_names @ vararg_ivar_type_names)
| None ->
Checkers.ST.report_error tenv proc_name proc_desc IssueType.checkers_printf_args cl
"Format string must be string literal"
if not (Reporting.is_suppressed tenv proc_desc IssueType.checkers_printf_args) then
let exn =
Exceptions.Checkers
( IssueType.checkers_printf_args
, Localise.verbatim_desc "Format string must be string literal" )
in
Reporting.log_warning summary ~loc:cl exn
with e ->
L.internal_error "%s Exception when analyzing %s: %s@."
IssueType.checkers_printf_args.unique_id

@ -1,31 +0,0 @@
(*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
(** Module for user-defined checkers. *)
module ST = struct
let report_error tenv proc_name proc_desc kind loc ?(field_name = None) ?(origin_loc = None)
?(exception_kind = fun k d -> Exceptions.Checkers (k, d)) ?(severity = Exceptions.Warning)
description =
let suppressed = Reporting.is_suppressed tenv proc_desc kind ~field_name in
if not suppressed then
let localized_description = Localise.custom_desc description [] in
let exn = exception_kind kind localized_description in
let trace =
let origin_elements =
match origin_loc with
| Some oloc ->
[Errlog.make_trace_element 0 oloc "origin" []]
| None ->
[]
in
origin_elements @ [Errlog.make_trace_element 0 loc description []]
in
Reporting.log_issue_deprecated_using_state severity proc_name ~loc ~ltr:trace exn
end

@ -1,26 +0,0 @@
(*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
(** Module for user-defined checkers. *)
module ST : sig
val report_error :
Tenv.t
-> Typ.Procname.t
-> Procdesc.t
-> IssueType.t
-> Location.t
-> ?field_name:Typ.Fieldname.t option
-> ?origin_loc:Location.t option
-> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn)
-> ?severity:Exceptions.severity
-> string
-> unit
(** Report an error. *)
end

@ -297,7 +297,7 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
if checks.TypeCheck.eradicate then
EradicateChecks.check_overridden_annotations find_canonical_duplicate tenv curr_pname
curr_pdesc annotated_signature ;
TypeErr.report_forall_checks_and_reset tenv (Checkers.ST.report_error tenv) curr_pdesc ;
TypeErr.report_forall_checks_and_reset tenv (EradicateCheckers.report_error tenv) curr_pdesc ;
()

@ -0,0 +1,29 @@
(*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
(** Module for Eradicate-based user-defined checkers. *)
let report_error tenv proc_name proc_desc kind loc ?(field_name = None) ?(origin_loc = None)
?(exception_kind = fun k d -> Exceptions.Checkers (k, d)) ?(severity = Exceptions.Warning)
description =
let suppressed = Reporting.is_suppressed tenv proc_desc kind ~field_name in
if not suppressed then
let localized_description = Localise.verbatim_desc description in
let exn = exception_kind kind localized_description in
let trace =
let origin_elements =
match origin_loc with
| Some oloc ->
[Errlog.make_trace_element 0 oloc "origin" []]
| None ->
[]
in
origin_elements @ [Errlog.make_trace_element 0 loc description []]
in
Reporting.log_issue_deprecated_using_state severity proc_name ~loc ~ltr:trace exn

@ -0,0 +1,24 @@
(*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
(** Module for Eradicate-based user-defined checkers. *)
val report_error :
Tenv.t
-> Typ.Procname.t
-> Procdesc.t
-> IssueType.t
-> Location.t
-> ?field_name:Typ.Fieldname.t option
-> ?origin_loc:Location.t option
-> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn)
-> ?severity:Exceptions.severity
-> string
-> unit
(** Report an error. *)

@ -29,7 +29,7 @@ let get_field_annotation tenv fn typ =
Some (t, ia')
let report_error tenv = TypeErr.report_error tenv (Checkers.ST.report_error tenv)
let report_error tenv = TypeErr.report_error tenv (EradicateCheckers.report_error tenv)
let explain_expr tenv node e =
match Errdesc.exp_rv_dexp tenv node e with

@ -34,8 +34,8 @@ let check_immutable_cast tenv curr_pname curr_pdesc typ_expected typ_found_opt l
(Typ.Procname.to_simplified_string curr_pname)
Typ.Name.pp name_given Typ.Name.pp name_expected
in
Checkers.ST.report_error tenv curr_pname curr_pdesc IssueType.checkers_immutable_cast
loc description
EradicateCheckers.report_error tenv curr_pname curr_pdesc
IssueType.checkers_immutable_cast loc description
| _ ->
() )
| None ->

@ -44,7 +44,7 @@ codetoanalyze/java/checkers/NullableViolation.java, codetoanalyze.java.checkers.
codetoanalyze/java/checkers/NullableViolation.java, codetoanalyze.java.checkers.NullableViolation.dereferenceNullableMethodIncorrectlyCheckedForNullBad():void, 2, NULLABLE_DEREFERENCE, no_bucket, ERROR, [dereferencing the return of NullableViolation.returnsNullable(),definition of returnsNullable]
codetoanalyze/java/checkers/NullableViolation.java, codetoanalyze.java.checkers.NullableViolation.dereferenceNullableMethodNotAlwaysCheckedForNullBad():void, 2, NULLABLE_DEREFERENCE, no_bucket, ERROR, [dereferencing the return of NullableViolation.returnsNullable(),definition of returnsNullable]
codetoanalyze/java/checkers/NullableViolation.java, codetoanalyze.java.checkers.NullableViolation.dereferenceNullableReturnValueBad():void, 2, NULLABLE_DEREFERENCE, no_bucket, ERROR, [dereference of t,assignment of the nullable value,definition of returnsNullable]
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.formatStringIsNotLiteral(java.io.PrintStream):void, 2, CHECKERS_PRINTF_ARGS, no_bucket, WARNING, [Format string must be string literal]
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.formatStringIsNotLiteral(java.io.PrintStream):void, 2, CHECKERS_PRINTF_ARGS, no_bucket, WARNING, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.stringInsteadOfInteger(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.wrongNumberOfArguments(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.SuppressedPrintfArgsChecker.classSuppressed(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []

Loading…
Cancel
Save