From caa7534a7187b47ef04752bdd1621e60863b0e3c Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Wed, 12 Oct 2016 02:34:29 -0700 Subject: [PATCH] [cpp] Report issues in the cpp models as relative paths Reviewed By: jvillard Differential Revision: D4001979 fbshipit-source-id: 483a758 --- infer/src/backend/InferPrint.re | 21 ++++++++++++++++++--- infer/src/base/Config.ml | 3 ++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index ff2a1dbec..90a1a677b 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -410,6 +410,18 @@ let module IssuesJson = { } else { file }; + let make_cpp_models_path_relative file => + if (Utils.string_is_prefix Config.cpp_models_dir file) { + if (Config.debug_mode || Config.debug_exceptions) { + Some ( + DB.source_file_to_rel_path (DB.rel_source_file_from_abs_path Config.cpp_models_dir file) + ) + } else { + None + } + } else { + Some file + }; /** Write bug report in JSON format */ let pp_issues_of_error_log fmt error_filter _ proc_loc_opt procname err_log => { @@ -431,12 +443,15 @@ let module IssuesJson = { | Some proc_loc => proc_loc.Location.file | None => loc.Location.file }; - if (in_footprint && error_filter source_file error_desc error_name) { + let file = DB.source_file_to_string source_file; + let file_opt = make_cpp_models_path_relative file; + if ( + in_footprint && error_filter source_file error_desc error_name && Option.is_some file_opt + ) { let kind = Exceptions.err_kind_string ekind; let bug_type = Localise.to_string error_name; let procedure_id = Procname.to_filename procname; - let file = DB.source_file_to_string source_file; - let file = expand_links_under_buck_out file; + let file = expand_links_under_buck_out (Option.get file_opt); let json_ml_loc = switch ml_loc_opt { | Some (file, lnum, cnum, enum) when Config.reports_include_ml_loc => diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 8472455a5..4ec922ee8 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -250,7 +250,8 @@ let models_dir = lib_dir // specs_dir_name let cpp_models_dir = - bin_dir // Filename.parent_dir_name // "models" // "cpp" // "include" + let dir = bin_dir // Filename.parent_dir_name // "models" // "cpp" // "include" in + Utils.filename_to_absolute dir (* Normalize the path *) let wrappers_dir = lib_dir // "wrappers"