Add optional field in serialized output

Reviewed By: jvillard

Differential Revision: D4970806

fbshipit-source-id: b857003
master
Martino Luca 8 years ago committed by Facebook Github Bot
parent 4e7c7f30c1
commit 34a0efd626

@ -62,6 +62,8 @@ INFER_COMMANDS = \
infer-run \
INFERTRACEBUGS_BIN = $(BIN_DIR)/inferTraceBugs
INFER_CREATE_TRACEVIEW_LINKS = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_BIN = $(BIN_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS)
INFERTRACEBUGS_BIN_RELPATH = infer/bin/inferTraceBugs
INFER_COMMAND_MANUALS = $(INFER_COMMANDS:%=$(MAN_DIR)/man1/%.1)

@ -6,6 +6,7 @@ PKG cmdliner
PKG core
PKG javalib
PKG oUnit
PKG parmap
PKG ppx_compare
PKG ptrees
PKG sawja

@ -52,6 +52,7 @@ JSON_INDEX_TRACE_LEVEL = 'level'
JSON_INDEX_TRACE_FILENAME = 'filename'
JSON_INDEX_TRACE_LINE = 'line_number'
JSON_INDEX_TRACE_DESCRIPTION = 'description'
JSON_INDEX_TRACEVIEW_ID = 'traceview_id'
JSON_INDEX_VISIBILITY = 'visibility'

@ -164,6 +164,21 @@ module Tags = struct
let get tags tag = List.Assoc.find ~equal:String.equal tags tag
let tag_value_records_of_tags tags =
List.map ~f:(fun (tag, value) -> {Jsonbug_t.tag; value}) tags
let tags_of_tag_value_records (tag_value_records: Jsonbug_t.tag_value_record list) =
List.map ~f:(fun {Jsonbug_t.tag; value} -> (tag, value)) tag_value_records
let lines_of_tags (tags: t) =
let line_tags = String.Set.of_list [
dereferenced_line;
call_line;
assigned_line;
alloc_line;
accessed_line;
dealloc_line;
] in
List.filter_map ~f:(fun (tag, value) ->
if String.Set.mem line_tags tag then Some (int_of_string value) else None) tags
end
type error_desc = {

@ -107,6 +107,12 @@ module Tags : sig
(** convert error description's tags to atd-serializable format *)
val tag_value_records_of_tags: t -> Jsonbug_t.tag_value_record list
(* convert atd-serializable format to error description's tags *)
val tags_of_tag_value_records: Jsonbug_t.tag_value_record list -> t
(* collect all lines from tags *)
val lines_of_tags: t -> int list
end
(** description field of error messages *)

@ -40,7 +40,7 @@ OCAMLBUILD_OPTIONS = \
-tag-line "<*{clang/clang_ast_*,backend/jsonbug_*,checkers/stacktree_*}>: warn(-27-32-34-35-39)" \
-tag-line "<*/{,*/}*.{ml,re}{,i}>: package(ppx_compare)" \
-tag thread \
-pkgs ANSITerminal,atdgen,cmdliner,core,extlib,oUnit,str,unix,xmlm,yojson,zip
-pkgs ANSITerminal,atdgen,cmdliner,core,extlib,oUnit,parmap,str,unix,xmlm,yojson,zip
ifeq ($(ENABLE_OCAML_BINANNOT),yes)
OCAMLBUILD_OPTIONS += -cflags -bin-annot
@ -58,7 +58,6 @@ ifeq ($(TEST),1)
OCAMLBUILD_OPTIONS += -cflags -warn-error,$(OCAML_FATAL_WARNINGS)
endif
#### Backend declarations ####
INFER_MAIN = backend/infer
@ -75,6 +74,12 @@ INFERPRINT_ATDGEN_STUB_BASE = backend/jsonbug
INFERPRINT_ATDGEN_STUB_ATD = $(INFERPRINT_ATDGEN_STUB_BASE).atd
INFERPRINT_ATDGEN_STUBS = $(addprefix $(INFERPRINT_ATDGEN_STUB_BASE), $(ATDGEN_SUFFIXES))
#### InferCreateTraceViewLinks declarations ####
FACEBOOK_DIR = facebook
INFER_CREATE_TRACEVIEW_LINKS_MODULE = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_MAIN = $(FACEBOOK_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS_MODULE)
### InferUnit declarations ###
UNIT_SOURCES = unit
@ -141,6 +146,9 @@ OCAMLBUILD_ALL = $(OCAMLBUILD_BASE) $(JAVA_OCAMLBUILD_OPTIONS)
OCAMLBUILD_CONFIG = $(OCAMLBUILD_BASE)
# list of ocamlbuild targets common to all build targets -- native version
INFER_CONFIG_TARGETS = $(INFER_MAIN).native
ifeq ($(IS_FACEBOOK_TREE),yes)
INFER_CONFIG_TARGETS += $(INFER_CREATE_TRACEVIEW_LINKS_MAIN).native
endif
ifeq ($(BUILD_JAVA_ANALYZERS),yes)
OCAMLBUILD_CONFIG += $(JAVA_OCAMLBUILD_OPTIONS)
@ -194,6 +202,11 @@ $(INFER_BIN_ALIASES): Makefile
$(INFER_BIN).native: $(INFER_BUILD_DIR)/$(INFER_MAIN).native $(INFER_BIN_ALIASES)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFER_MAIN).native $(INFER_BIN)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFER_MAIN).native $(INFER_BIN).native
ifeq ($(IS_FACEBOOK_TREE),yes)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS_MAIN).native \
$(INFER_CREATE_TRACEVIEW_LINKS_BIN)
endif
.PHONY: infer
infer: $(INFER_BIN).native
@ -215,6 +228,10 @@ $(INFER_BIN).byte: $(INFER_BUILD_DIR)/$(INFER_MAIN).byte $(INFER_BIN_ALIASES)
ifeq ($(TEST),1)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERUNIT_MAIN).byte $(INFERUNIT_BIN)
endif
ifeq ($(IS_FACEBOOK_TREE),yes)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS_MAIN).byte \
$(INFER_CREATE_TRACEVIEW_LINKS_BIN)
endif
.PHONY: byte
byte: $(INFER_BIN).byte
@ -252,6 +269,9 @@ rei:
$(SCRIPT_DIR)/refmt.sh -parse ml -print re $< > $*.rei
roots:=Infer StatsAggregator
ifeq ($(IS_FACEBOOK_TREE),yes)
roots += $(INFER_CREATE_TRACEVIEW_LINKS_MODULE)
endif
clusters:=base clang java IR
ml_src_files:=$(shell find $(DEPENDENCIES) -regex '.*\.ml\(i\)*')
@ -395,5 +415,6 @@ clean:
$(REMOVE) $(INFERUNIT_BIN) $(CHECKCOPYRIGHT_BIN)
$(REMOVE) $(CLANG_ATDGEN_STUBS)
$(REMOVE) $(INFER_CLANG_FCP_MIRRORED_FILES)
$(REMOVE) $(INFER_CREATE_TRACEVIEW_LINKS_BIN)
$(REMOVE) mod_dep.dot
$(REMOVE) mod_dep.pdf

@ -91,6 +91,8 @@ let get_bug_hash
)
};
let exception_value = "exception";
let loc_trace_to_jsonbug_record trace_list ekind =>
switch ekind {
| Exceptions.Kinfo => []
@ -102,7 +104,7 @@ let loc_trace_to_jsonbug_record trace_list ekind =>
{Jsonbug_j.tag: Io_infer.Xml.tag_branch, value: Printf.sprintf "%B" cond}
]
| Errlog.Exception exn_name =>
let res = [{Jsonbug_j.tag: Io_infer.Xml.tag_kind, value: "exception"}];
let res = [{Jsonbug_j.tag: Io_infer.Xml.tag_kind, value: exception_value}];
let exn_str = Typ.Name.name exn_name;
if (String.is_empty exn_str) {
res
@ -500,7 +502,8 @@ module IssuesJson = {
dotty: error_desc_to_dotty_string key.err_desc,
infer_source_loc: json_ml_loc,
bug_type_hum: Localise.to_human_readable_string key.err_name,
linters_def_file: err_data.linters_def_file
linters_def_file: err_data.linters_def_file,
traceview_id: None
};
if (not !is_first_item) {
pp ","

@ -8,6 +8,8 @@
*/
open! IStd;
let exception_value: string;
let main: report_csv::option string => report_json::option string => unit;
let main_from_config: unit => unit;

@ -39,6 +39,7 @@ type jsonbug = {
?infer_source_loc: loc option;
bug_type_hum: string;
?linters_def_file: string option;
?traceview_id: int option;
}
type report = jsonbug list

@ -1037,6 +1037,9 @@ and icfg_dotty_outfile =
"If set, specifies path where .dot file should be written, it overrides the path for all \
other options that would generate icfg file otherwise"
and ignore_trivial_traces = CLOpt.mk_bool
~long:"ignore-trivial-traces" ~default:true "Ignore traces whose length is at most 1"
and infer_cache =
CLOpt.mk_path_opt ~deprecated:["infer_cache"; "-infer_cache"] ~long:"infer-cache"
~meta:"dir" "Select a directory to contain the infer cache (Buck and Java only)"
@ -1778,6 +1781,7 @@ and frontend_debug = !frontend_debug
and frontend_stats = !frontend_stats
and headers = !headers
and icfg_dotty_outfile = !icfg_dotty_outfile
and ignore_trivial_traces = !ignore_trivial_traces
and immutable_cast = !immutable_cast
and infer_cache = !infer_cache
and iphoneos_target_sdk_version = !iphoneos_target_sdk_version

@ -240,6 +240,7 @@ val frontend_stats : bool
val generated_classes : string option
val headers : bool
val icfg_dotty_outfile : string option
val ignore_trivial_traces : bool
val immutable_cast : bool
val infer_cache : string option
val iphoneos_target_sdk_version : string option

@ -49,7 +49,8 @@ let create_fake_jsonbug
dotty;
infer_source_loc;
bug_type_hum = kind;
linters_def_file
linters_def_file;
traceview_id = None;
}
let pp_diff_of_int_list group_name fmt (expected, actual) =

@ -36,6 +36,7 @@ depends: [
"javalib" {>="2.3.3"}
"ocamlfind" {build}
"ounit" {="2.0.0"}
"parmap" {>="1.0-rc8"}
"ppx_deriving" {>="4.1"}
"reason" {="1.13.4"}
"sawja" {>="1.5.2"}

@ -28,6 +28,7 @@ ocaml-migrate-parsetree = 0.7
ocamlbuild = 0.11.0
ocamlfind = 1.7.1
ounit = 2.0.0
parmap = 1.0-rc8
ppx_assert = 113.33.00
ppx_bench = 113.33.00+4.03
ppx_bin_prot = 113.33.00+4.03

Loading…
Cancel
Save