]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Set start_location to 0 if we ran out of line map space
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 24 Aug 2018 23:37:53 +0000 (23:37 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Fri, 24 Aug 2018 23:37:53 +0000 (16:37 -0700)
With profiledbootstrap and --with-build-config=bootstrap-lto, linemap_add
may create a macro map when we run out of line map space.  This patch
changes start_location to UNKNOWN_LOCATION (0) in this case.

Tested with profiledbootstrap and --with-build-config=bootstrap-lto on
Linux/x86-64.

PR bootstrap/86872
* line-map.c (pure_location_p): Return true if linemap_lookup
returns NULL.
(linemap_add): Set start_location to 0 if we run out of line map
space.

From-SVN: r263845

libcpp/ChangeLog
libcpp/line-map.c

index de6f5421b12d98218ddf6459a4abbd77041fe844..cbf4cbf704209ad85e22e26e46e4022505397084 100644 (file)
@@ -1,3 +1,11 @@
+2018-08-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR bootstrap/86872
+       * line-map.c (pure_location_p): Return true if linemap_lookup
+       returns NULL.
+       (linemap_add): Set start_location to 0 if we run out of line map
+       space.
+
 2018-08-20  Nathan Sidwell  <nathan@acm.org>
 
        * include/cpplib.h: Fixup some whitespace.
index f0e6318e412cd8823ee5fcdd08fe86d6d950efaa..b5e1f13da357dc7d3c15e2303e282622a14d6367 100644 (file)
@@ -304,6 +304,8 @@ pure_location_p (line_maps *set, source_location loc)
     return false;
 
   const line_map *map = linemap_lookup (set, loc);
+  if (map == NULL)
+    return true;
   const line_map_ordinary *ordmap = linemap_check_ordinary (map);
 
   if (loc & ((1U << ordmap->m_range_bits) - 1))
@@ -492,6 +494,11 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
     }
 
   linemap_assert (reason != LC_ENTER_MACRO);
+
+  if (start_location >= LINE_MAP_MAX_LOCATION)
+    /* We ran out of line map space.   */
+    start_location = 0;
+
   line_map_ordinary *map
     = linemap_check_ordinary (new_linemap (set, start_location));
   map->reason = reason;