)]}'
{
  "commit": "71dcf0c4aaef7d9ac814250018242a6b5dc7705b",
  "tree": "bf7fa78e80f27d7bbc65da85d6f3a9b9c2c9c451",
  "parents": [
    "ab7c7b46c35ed1be68d4c020a2f20ee96f68b64b"
  ],
  "author": {
    "name": "David Malcolm",
    "email": "dmalcolm@redhat.com",
    "time": "Mon Dec 23 20:02:54 2019 -0500"
  },
  "committer": {
    "name": "David Malcolm",
    "email": "dmalcolm@redhat.com",
    "time": "Tue Jan 14 21:10:45 2020 -0500"
  },
  "message": "diagnostic_path: avoid printing redundant data\n\nThis patch tweaks the default implementation of diagnostic_path\nprinting (-fdiagnostics-path-format\u003dinline-events) to be less verbose\nfor various common cases.\n\nConsider this synthetic diagnostic from the test plugin:\n\ntest.c: In function \u0027test\u0027:\ntest.c:29:5: error: passing NULL as argument 1 to \u0027PyList_Append\u0027 which\n  requires a non-NULL parameter\n   29 |     PyList_Append(list, item);\n      |     ^~~~~~~~~~~~~~~~~~~~~~~~~\n  \u0027test\u0027: events 1-3\n    |\n    |   25 |   list \u003d PyList_New(0);\n    |      |          ^~~~~~~~~~~~~\n    |      |          |\n    |      |          (1) when \u0027PyList_New\u0027 fails, returning NULL\n    |   26 |\n    |   27 |   for (i \u003d 0; i \u003c count; i++) {\n    |      |   ~~~\n    |      |   |\n    |      |   (2) when \u0027i \u003c count\u0027\n    |   28 |     item \u003d PyLong_FromLong(random());\n    |   29 |     PyList_Append(list, item);\n    |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~\n    |      |     |\n    |      |     (3) when calling \u0027PyList_Append\u0027, passing NULL from (1) as argument 1\n    |\n\nThe diagnostic\u0027s primary location_t is contained within the path, so\nprinting the source code for it at the top before the path is redundant.\n\nAlso, this path is purely intraprocedural, so there\u0027s no point in\nprinting the \"interprocedural margin\" on the left-hand side, and there\u0027s\na single event run, so there\u0027s no point in printing the header for the\nrun.\n\nThis patch simplifies the output for the above to:\n\ntest.c: In function \u0027test\u0027:\ntest.c:29:5: error: passing NULL as argument 1 to \u0027PyList_Append\u0027 which\n  requires a non-NULL parameter\n   25 |   list \u003d PyList_New(0);\n      |          ^~~~~~~~~~~~~\n      |          |\n      |          (1) when \u0027PyList_New\u0027 fails, returning NULL\n   26 |\n   27 |   for (i \u003d 0; i \u003c count; i++) {\n      |   ~~~\n      |   |\n      |   (2) when \u0027i \u003c count\u0027\n   28 |     item \u003d PyLong_FromLong(random());\n   29 |     PyList_Append(list, item);\n      |     ~~~~~~~~~~~~~~~~~~~~~~~~~\n      |     |\n      |     (3) when calling \u0027PyList_Append\u0027, passing NULL from (1) as argument 1\n\nThe patch replaces the diagnostic_context\u0027s print_path callback with an\nobject with two vfuncs, allowing for eliding diagnostic_show_locus for\nthe rich_location in favor of just printing the path for the common case\nof a single location_t that\u0027s within the path, no fix-it hints or\nlabels, and -fdiagnostics-path-format\u003dinline-events.\n\nThis went through several iterations; in one iteration I attempted to\nuse a small class hierarchy of per enum diagnostics_output_format\npath_printer subclasses; this didn\u0027t work because the option-handling\nis done in opts.o:common_handle_option, which is in\nOBJS-libcommon-target, which isn\u0027t \"tree-ish\".  So this version has\na single implementation subclass in tree-diagnostic-path.cc.\n\nThis patch contains the non-analyzer changes; a follow-up updates the\nexpected output for the analyzer testsuite.\n\ngcc/ChangeLog:\n\t* diagnostic-format-json.cc (diagnostic_output_format_init): For\n\tthe JSON case, update for conversion from a print_path callback to\n\ta m_path_printer object, deleting any such object.\n\t* diagnostic-show-locus.c (diagnostic_show_locus): Call any\n\tpath_printer\u0027s maybe_print_path_rather_than_richloc and\n\tpotentially bail out early.\n\t* diagnostic.c (diagnostic_initialize): Initializer m_path_printer\n\tand make_json_for_path.\n\t(diagnostic_finish): Delete any m_path_printer.\n\t(diagnostic_show_any_path): Update to call any m_path_printer\u0027s\n\tprint_path vfunc.\n\t(rich_location::path_makes_location_redundant_p): New function.\n\t* diagnostic.h (class path_printer): New class.\n\t(diagnostic_context::print_path): Replace this callback with...\n\t(diagnostic_context::m_path_printer): ...this object pointer.\n\t(diagnostic_context::make_json_for_path): Fix overlong line.\n\t* doc/invoke.texi (-fdiagnostics-path-format\u003dinline-events):\n\tUpdate intraprocedural example to reflect removal of event run\n\theader and interprocedural margin.  Add sentence describing\n\thow source code for location can be elided.\n\t(-fdiagnostics-show-path-depths): Fix reference to pertinent\n\toption.\n\t* tree-diagnostic-path.cc: (path_summary::m_path): New field.\n\t(path_summary::path_summary): Initialize it.\n\t(print_fndecl): Likewise.\n\t(path_summary::print): Add param \"need_event_header\".  Determine\n\tif the path is interprocedural vs purely intraprocedural.  Only\n\tprint headers for event-runs if we need to, or if there\u0027s more\n\tthan one event-run.  Only print the \"interprocedural border\" for\n\tinterprocedural paths.  Only print the function name in event-run\n\theaders for interprocedural paths.\n\t(default_tree_diagnostic_path_printer): Replace with...\n\t(class impl_path_printer): ...this class.\n\t(path_printer::make_tree_default): New function.\n\t(selftest::test_intraprocedural_path): Update expected result for\n\tabove changes; do with and without requiring event headers.\n\t* tree-diagnostic.c (tree_diagnostics_defaults): Replace\n\tinitialization of print_path with that for m_path_printer.\n\t* tree-diagnostic.h (default_tree_diagnostic_path_printer): Delete decl.\n\ngcc/testsuite/ChangeLog:\n\t* gcc.dg/plugin/diagnostic-path-format-default.c: Update expected\n\toutput to remove source code from diagnostic locus, made redundant\n\tby path.\n\t* gcc.dg/plugin/diagnostic-path-format-inline-events-1.c:\n\tLikewise.\n\t* gcc.dg/plugin/diagnostic-path-format-inline-events-2.c:\n\tLikewise.\n\t* gcc.dg/plugin/diagnostic-path-format-inline-events-3.c:\n\tLikewise.\n\t* gcc.dg/plugin/diagnostic-test-paths-2.c: Likewise; also\n\tremove redundant event run header and interprocedual margin.\n\t* gcc.dg/plugin/diagnostic-test-paths-2a.c: New test.\n\t* gcc.dg/plugin/diagnostic-test-paths-4.c: Update expected output\n\tto remove source code from diagnostic locus, made redundant by\n\tpath.\n\t* gcc.dg/plugin/diagnostic_plugin_test_paths.c\n\t(class pass_test_show_path): Add an m_dummy_label field and\n\tinitialize it in the ctor.\n\t(example_1): Add a \"dummy_label\" param.  Use it to optionally add\n\ta labelled to the rich_location.\n\t(pass_test_show_path::execute): Pass m_dummy_label to the call to\n\texample_1.\n\t(make_pass_test_show_path): Delete.\n\t(plugin_init): Look for a \"dummy_label\" plugin argument and use\n\tit to initialize the pass\u0027s m_dummy_label field.  Call new directly\n\tto avoid passing around such params.\n\t* gcc.dg/plugin/plugin.exp (plugin_test_list): Add new test.\n\nlibcpp/ChangeLog:\n\t* include/line-map.h\n\t(rich_location::path_makes_location_redundant_p): New decl.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "7bda5c4ba8344360ff02f56874a5f45ff1e6a6a0",
      "old_mode": 33188,
      "old_path": "gcc/diagnostic-format-json.cc",
      "new_id": "e3dc7f1a566651f32c0c0e20e93f931fe5557272",
      "new_mode": 33188,
      "new_path": "gcc/diagnostic-format-json.cc"
    },
    {
      "type": "modify",
      "old_id": "4618b4edb7d19846e2ce74ad07fc26212d66e761",
      "old_mode": 33188,
      "old_path": "gcc/diagnostic-show-locus.c",
      "new_id": "4c4af80a8d2882a5eb980620f3dde7d6de998893",
      "new_mode": 33188,
      "new_path": "gcc/diagnostic-show-locus.c"
    },
    {
      "type": "modify",
      "old_id": "72afd7c6adf08fcce462e851daafce69b935f17f",
      "old_mode": 33188,
      "old_path": "gcc/diagnostic.c",
      "new_id": "5b817ec7eca99b73890a8014399b4b2d297f6512",
      "new_mode": 33188,
      "new_path": "gcc/diagnostic.c"
    },
    {
      "type": "modify",
      "old_id": "307dbcfb34a6f8257ce7d6b51903e75bff0bf131",
      "old_mode": 33188,
      "old_path": "gcc/diagnostic.h",
      "new_id": "afb02658fbc3e96cdf0ee23c36818a0d5501e98d",
      "new_mode": 33188,
      "new_path": "gcc/diagnostic.h"
    },
    {
      "type": "modify",
      "old_id": "d8b94d837a968954b985350da396ea6d4a477e25",
      "old_mode": 33188,
      "old_path": "gcc/doc/invoke.texi",
      "new_id": "13742042de298fea871943c22c4767cef79853b9",
      "new_mode": 33188,
      "new_path": "gcc/doc/invoke.texi"
    },
    {
      "type": "modify",
      "old_id": "5712dbd647250850bf6aa81d916b6370ed81961f",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c",
      "new_id": "d0ad8d6b987d75a865a972375fb2360e53c4332c",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c"
    },
    {
      "type": "modify",
      "old_id": "430d81737718b070280684c10faddbd437f55016",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-inline-events-1.c",
      "new_id": "5fc005a767b3ca11de65a033cd56d51bc783909b",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-inline-events-1.c"
    },
    {
      "type": "modify",
      "old_id": "c2bfabec9101216669d7e893eb444f2c9e5bfde6",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-inline-events-2.c",
      "new_id": "7072308185cdc241b9816f25018658c661ebe11d",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-inline-events-2.c"
    },
    {
      "type": "modify",
      "old_id": "386cac91c41575fa708538fce8de6d5be1acf299",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-inline-events-3.c",
      "new_id": "7e619da6ec77a20820bb0e06e5bd6ff748a961e8",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-inline-events-3.c"
    },
    {
      "type": "modify",
      "old_id": "946a234dd236cbfd1be1aa843b235c20d9835b92",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c",
      "new_id": "29f0a848f52ecd3457ef3a5ee19bfc217b3b1465",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e8dc5bf82155c64eac847fa049421e9a31f5e96c",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2a.c"
    },
    {
      "type": "modify",
      "old_id": "847b6d423e40f032449e8ccbb91fe4deb09fb8e5",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-4.c",
      "new_id": "2b5c395940992045f09e37c9e910870aac054728",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-4.c"
    },
    {
      "type": "modify",
      "old_id": "cf05ca3a5d325e6bbf15f678a7f24478b8f963d1",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c",
      "new_id": "fa075057d504e98b072868ff1d65194bf4b183f1",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c"
    },
    {
      "type": "modify",
      "old_id": "c02b008271528262600bff74dbd08d3db74dfb08",
      "old_mode": 33188,
      "old_path": "gcc/testsuite/gcc.dg/plugin/plugin.exp",
      "new_id": "99e3c3d531e31f7d2b89b07e76e2d37be6fa36eb",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/plugin/plugin.exp"
    },
    {
      "type": "modify",
      "old_id": "381a49cb0b4746e79e3b5395fd3788708e3ea455",
      "old_mode": 33188,
      "old_path": "gcc/tree-diagnostic-path.cc",
      "new_id": "381ec77bc346cd72714e4f65a8b5f0dff9e9aa92",
      "new_mode": 33188,
      "new_path": "gcc/tree-diagnostic-path.cc"
    },
    {
      "type": "modify",
      "old_id": "8422714aecbc2de2dafad3f8776d4bfc8ccb26e3",
      "old_mode": 33188,
      "old_path": "gcc/tree-diagnostic.c",
      "new_id": "d1768367d4668f5165e701ed06188cdcfc72338f",
      "new_mode": 33188,
      "new_path": "gcc/tree-diagnostic.c"
    },
    {
      "type": "modify",
      "old_id": "40dc9fa0e8319600feb0e7e833ecd688b5d28574",
      "old_mode": 33188,
      "old_path": "gcc/tree-diagnostic.h",
      "new_id": "9f3175ea423cd561c7fdc6d70df8c836fcbf7ae0",
      "new_mode": 33188,
      "new_path": "gcc/tree-diagnostic.h"
    },
    {
      "type": "modify",
      "old_id": "dbbc13762e39dbcc9206eda5fe9dc27f18cf7145",
      "old_mode": 33188,
      "old_path": "libcpp/include/line-map.h",
      "new_id": "8691cbd13024e8903c70e5a1c5360f3d063d9907",
      "new_mode": 33188,
      "new_path": "libcpp/include/line-map.h"
    }
  ]
}
