The following patch kit overhauls various aspects of JSON/SARIF output: * patch 1: adds a simpler json::value::dump () method to make it easier to debug JSON-handling code
* patches 2-9 are cleanups/refactorings of the json-handling code and the JSON/SARIF output formats with no functional change intended. Among other things, they make it more type-safe (useful when enforcing a schema), and use std::unique_ptr in many places to indicate ownership. * patches 10-16: add new functionality to our SARIF output whilst building out selftest coverage for it. See the individual patches for more details. Lightly tested with valgrind. Successfully bootstrapped with GCC 4.8.5 on powerpc64le-unknown-linux-gnu (cfarm135). Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Successful run of analyzer integration tests on x86_64-pc-linux-gnu. Pushed to trunk as r15-2278-g6baa26c3d6ceec through r15-2293-g142003df61b45b. David Malcolm (16): json: add dump overload for easier debugging json: add array::append_string analyzer: reduce use of naked "new" for json dumps gcov: reduce use of naked "new" for json output diagnostics: SARIF output: add sarif_object subclasses throughout diagnostics: output formats: use references for non-null pointers json: support std::unique_ptr in array::append and object::set diagnostics: SARIF output: use std::unique_ptr throughout diagnostics: JSON output: use std::unique_ptr throughout diagnostics: SARIF output: potentially add escaped renderings of source (§3.3.4) diagnostics: SARIF output: add "workingDirectory" property (§3.20.19) diagnostics: SARIF output: add "arguments" property (§3.20.2) diagnostics: SARIF output: add "{start,end}TimeUtc" properties (§§3.20.7-8) diagnostics: SARIF output: add "annotations" property (§3.28.6) diagnostics: add selftests for SARIF output diagnostics: SARIF output: tweak output for UNKNOWN_LOCATION gcc/Makefile.in | 1 + gcc/analyzer/call-string.cc | 9 +- gcc/analyzer/checker-event.cc | 5 +- gcc/analyzer/constraint-manager.cc | 12 +- gcc/analyzer/diagnostic-manager.cc | 14 +- gcc/analyzer/engine.cc | 13 +- gcc/analyzer/program-point.cc | 11 +- gcc/analyzer/program-state.cc | 2 +- gcc/analyzer/sm.cc | 2 +- gcc/analyzer/store.cc | 6 +- gcc/analyzer/supergraph.cc | 21 +- gcc/diagnostic-format-json.cc | 167 +- gcc/diagnostic-format-sarif.cc | 1738 ++++++++++++----- gcc/diagnostic-format-sarif.h | 9 +- gcc/diagnostic-show-locus.cc | 98 +- gcc/diagnostic.cc | 19 +- gcc/diagnostic.h | 25 +- gcc/dumpfile.cc | 1 + gcc/gcc-rich-location.h | 17 - gcc/gcc.cc | 3 +- gcc/gcov.cc | 5 +- gcc/jit/jit-playback.cc | 6 +- gcc/json.cc | 36 +- gcc/json.h | 45 + gcc/optinfo-emit-json.cc | 5 +- gcc/optinfo.cc | 1 + gcc/opts.cc | 3 +- gcc/selftest-diagnostic-show-locus.h | 82 + gcc/selftest-diagnostic.cc | 14 + gcc/selftest-diagnostic.h | 10 + gcc/selftest-json.cc | 163 ++ gcc/selftest-json.h | 141 ++ gcc/selftest-run-tests.cc | 1 + gcc/selftest.h | 1 + .../diagnostic-format-sarif-file-1.c | 11 + ...diagnostic-format-sarif-file-Wbidi-chars.c | 17 + .../diagnostic_plugin_test_show_locus.c | 1 + gcc/text-range-label.h | 42 + gcc/timevar.cc | 1 + gcc/toplev.cc | 14 +- gcc/tree-diagnostic-client-data-hooks.cc | 1 + gcc/unique-argv.h | 67 + libcpp/include/rich-location.h | 31 +- libcpp/line-map.cc | 28 + 44 files changed, 2179 insertions(+), 720 deletions(-) create mode 100644 gcc/selftest-diagnostic-show-locus.h create mode 100644 gcc/selftest-json.cc create mode 100644 gcc/selftest-json.h create mode 100644 gcc/text-range-label.h create mode 100644 gcc/unique-argv.h -- 2.26.3