diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-30 12:33:38 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-30 12:33:38 +0100 |
commit | 88cfc534ae24986a95211038b828a1878001044c (patch) | |
tree | f7f2c4d4d65b9995b2116a78ad75be4065e0343e | |
parent | e858c84a7b2af9e7ccf4ac3268129520041210d9 (diff) | |
download | compcert-88cfc534ae24986a95211038b828a1878001044c.tar.gz compcert-88cfc534ae24986a95211038b828a1878001044c.zip |
Added support for different diagnostic formats.
The new option -fdiagnostics-format allows it to switch between
the three different format version:
-ccomp (default) with file:line:
-vi with file+line:
-msvc with file(line):
Bug 19872
-rw-r--r-- | cparser/Cerrors.ml | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml index b8df328e..dffd9c14 100644 --- a/cparser/Cerrors.ml +++ b/cparser/Cerrors.ml @@ -272,10 +272,31 @@ let pp_key key fmt = | Some s -> " ["^s^"]" in fprintf fmt "%s%t@." key rsc +(* Different loc output formats *) +type loc_format = + | Default + | MSVC + | Vi + +let diagnostics_format : loc_format ref = ref Default + +(* Parse the option string *) +let parse_loc_format s = + let s = String.sub s 21 ((String.length s) - 21) in + let loc_fmt = match s with + | "ccomp" -> Default + | "msvc" -> MSVC + | "vi" -> Vi + | s -> Printf.eprintf "Invalid value '%s' in '-fdiagnostics-format=%s'\n" s s; exit 2 in + diagnostics_format := loc_fmt + (* Print the location or ccomp for the case of unknown loc *) let pp_loc fmt (filename,lineno) = if filename <> "" && lineno <> -10 && filename <> "cabs loc unknown" then - fprintf fmt "%t%s:%d:%t " bc filename lineno rsc + match !diagnostics_format with + | Default -> fprintf fmt "%t%s:%d:%t " bc filename lineno rsc + | MSVC -> fprintf fmt "%t%s(%d):%t " bc filename lineno rsc + | Vi -> fprintf fmt "%t%s +%d:%t " bc filename lineno rsc else fprintf fmt "%tccomp:%t " bc rsc @@ -355,7 +376,9 @@ let warning_options = Exact ("-w"), Unit wnothing; longopt_int ("-fmax-errors") ((:=) max_error); Exact("-fno-diagnostics-show-option"),Unset diagnostics_show_option; - Exact("-fdiagnostics-show-option"),Set diagnostics_show_option;] + Exact("-fdiagnostics-show-option"),Set diagnostics_show_option; + _Regexp("-fdiagnostics-format=\\(ccomp\\|msvc\\|vi\\)"),Self parse_loc_format; + ] let warning_help = {|Diagnostic options: -Wall Enable all warnings |