diff --git a/infer/src/backend/errlog.ml b/infer/src/backend/errlog.ml index 23a32684a..a3aa9bac7 100644 --- a/infer/src/backend/errlog.ml +++ b/infer/src/backend/errlog.ml @@ -196,7 +196,7 @@ let log_issue _ekind err_log loc node_id_key session ltr pre_opt exn = | _ -> added in let print_now () = let ex_name, desc, ml_loc_opt, _, _, _, _ = Exceptions.recognize_exception exn in - L.err "%a@?" (Exceptions.pp_err node_id_key loc ekind ex_name desc ml_loc_opt) (); + L.err "@\n%a@\n@?" (Exceptions.pp_err node_id_key loc ekind ex_name desc ml_loc_opt) (); if _ekind <> Exceptions.Kerror then begin let warn_str = let pp fmt () = diff --git a/infer/src/backend/lintIssues.ml b/infer/src/backend/lintIssues.ml index d32aec825..b3099dd33 100644 --- a/infer/src/backend/lintIssues.ml +++ b/infer/src/backend/lintIssues.ml @@ -13,6 +13,9 @@ open! Utils let errLogMap = ref Procname.Map.empty +let exists_issues () = + not (Procname.Map.is_empty !errLogMap) + let get_err_log procname = try Procname.Map.find procname !errLogMap with Not_found -> diff --git a/infer/src/backend/lintIssues.mli b/infer/src/backend/lintIssues.mli index ab4f936a6..0d2be45be 100644 --- a/infer/src/backend/lintIssues.mli +++ b/infer/src/backend/lintIssues.mli @@ -11,6 +11,8 @@ val errLogMap : Errlog.t Procname.Map.t ref +val exists_issues : unit -> bool + (** Save issues to a file *) val get_err_log : Procname.t -> Errlog.t diff --git a/infer/src/clang/cFrontend_checkers_main.ml b/infer/src/clang/cFrontend_checkers_main.ml index 67af8c3d0..b9fb542b0 100644 --- a/infer/src/clang/cFrontend_checkers_main.ml +++ b/infer/src/clang/cFrontend_checkers_main.ml @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. *) +open! Utils open CFrontend_utils let rec do_frontend_checks_stmt (context:CLintersContext.context) cfg cg stmt = @@ -66,7 +67,7 @@ let context_with_ck_set context decl_list = let store_issues source_file = let abbrev_source_file = DB.source_file_encoding source_file in - let lint_issues_dir = Filename.concat Config.results_dir Config.lint_issues_dir_name in + let lint_issues_dir = Config.results_dir // Config.lint_issues_dir_name in DB.create_dir lint_issues_dir; let lint_issues_file = DB.filename_from_string (Filename.concat lint_issues_dir (abbrev_source_file ^ ".issue")) in @@ -82,5 +83,6 @@ let do_frontend_checks cfg cg source_file ast = let allowed_decls = IList.filter is_decl_allowed decl_list in IList.iter (do_frontend_checks_decl context cfg cg) allowed_decls; (* TODO (t12740727): Remove condition once the transition to linters mode is finished *) - if Config.analyzer = Some Config.Linters then store_issues source_file + if Config.analyzer = Some Config.Linters && (LintIssues.exists_issues ()) then + store_issues source_file | _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *)