tree-diagnostic-path.cc: properly handle ad-hoc wrappers of UNKNOWN_LOCATION
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 20 Dec 2019 16:20:44 +0000 (11:20 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 15 Jan 2020 01:42:04 +0000 (20:42 -0500)
In the reproducer for PR analyzer/58237 I noticed that some events that
were missing locations were also missing text; for example event 3 here:

    |   15 |   while (fgets(buf, 10, fp) != NULL)
    |      |         ~
    |      |         |
    |      |         (2) following 'false' branch...
    |
  'f1': event 3
    |
    |cc1:
    |

The root cause is that the path_summary-printing code doesn't consider
ad-hoc locations when looking for reserved locations, and so fails to
detect an unknown location for the case where an unknown location has
been wrapped into an ad-hoc location to record a block.

This patch fixes the issue by using get_pure_location, thus looking
through ad-hoc wrappers, improving the result to:

    |   15 |   while (fgets(buf, 10, fp) != NULL)
    |      |         ~
    |      |         |
    |      |         (2) following 'false' branch...
    |
  'f1': event 3
    |
    |cc1:
    | (3): ...to here
    |

gcc/ChangeLog:
* tree-diagnostic-path.cc (path_summary::event_range::print):
When testing for UNKNOWN_LOCATION, look through ad-hoc wrappers
using get_pure_location.

gcc/ChangeLog
gcc/tree-diagnostic-path.cc

index 56e7995305ee4c9e63e2c6ac620b26de7cfdda75..2837364ae16fb6d108ef5bdf63311f8d6a2abe16 100644 (file)
@@ -1,3 +1,9 @@
+2020-01-14  David Malcolm  <dmalcolm@redhat.com>
+
+       * tree-diagnostic-path.cc (path_summary::event_range::print):
+       When testing for UNKNOWN_LOCATION, look through ad-hoc wrappers
+       using get_pure_location.
+
 2020-01-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/93262
index 9e2ff1053b621d879e949285e483d9d3af487e4b..381a49cb0b4746e79e3b5395fd3788708e3ea455 100644 (file)
@@ -172,7 +172,7 @@ class path_summary
         In particular the label for the event won't get printed.
         Fail more gracefully in this case by showing the event
         index and text, at no particular location.  */
-      if (initial_loc <= BUILTINS_LOCATION)
+      if (get_pure_location (initial_loc) <= BUILTINS_LOCATION)
        {
          for (unsigned i = m_start_idx; i <= m_end_idx; i++)
            {