aboutsummaryrefslogtreecommitdiff
path: root/libcpp/line-map.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-11-04 13:22:10 +0000
committerGitHub <noreply@github.com>2022-11-04 13:22:10 +0000
commit0a59abbfc74c3961fb01323d9fbff8427518fde6 (patch)
treeb17389116bc4da1d022345b7b78eb6fc0fbe4eb0 /libcpp/line-map.cc
parentf8c2fab0c6c11f73fdcb1eb31e8b5b75c2fdbf7f (diff)
parenta7b70c704182db2defd0c0f991c16f4d9219bc2f (diff)
downloadgcc-0a59abbfc74c3961fb01323d9fbff8427518fde6.zip
gcc-0a59abbfc74c3961fb01323d9fbff8427518fde6.tar.gz
gcc-0a59abbfc74c3961fb01323d9fbff8427518fde6.tar.bz2
Merge #1627
1627: Merge GCC mainline/master into gccrs/master r=CohenArthur a=ibuclaw `@doko42` was asking, so here's another merge sync. Co-authored-by: GCC Administrator <gccadmin@gcc.gnu.org> Co-authored-by: Andrew MacLeod <amacleod@redhat.com> Co-authored-by: Liwei Xu <liwei.xu@intel.com> Co-authored-by: Richard Biener <rguenther@suse.de> Co-authored-by: Jakub Jelinek <jakub@redhat.com> Co-authored-by: Andre Vieira <andre.simoesdiasvieira@arm.com> Co-authored-by: Jonathan Wakely <jwakely@redhat.com> Co-authored-by: Martin Jambor <mjambor@suse.cz> Co-authored-by: Joseph Myers <joseph@codesourcery.com> Co-authored-by: Patrick Palka <ppalka@redhat.com> Co-authored-by: Florian Weimer <fweimer@redhat.com> Co-authored-by: Marek Polacek <polacek@redhat.com> Co-authored-by: liuhongt <hongtao.liu@intel.com> Co-authored-by: Martin Liska <mliska@suse.cz> Co-authored-by: Robin Dapp <rdapp@linux.ibm.com> Co-authored-by: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> Co-authored-by: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Diffstat (limited to 'libcpp/line-map.cc')
-rw-r--r--libcpp/line-map.cc38
1 files changed, 31 insertions, 7 deletions
diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
index 391f1d4..50e8043 100644
--- a/libcpp/line-map.cc
+++ b/libcpp/line-map.cc
@@ -67,7 +67,8 @@ location_adhoc_data_hash (const void *l)
return ((hashval_t) lb->locus
+ (hashval_t) lb->src_range.m_start
+ (hashval_t) lb->src_range.m_finish
- + (size_t) lb->data);
+ + (size_t) lb->data
+ + lb->discriminator);
}
/* Compare function for location_adhoc_data hashtable. */
@@ -82,7 +83,8 @@ location_adhoc_data_eq (const void *l1, const void *l2)
return (lb1->locus == lb2->locus
&& lb1->src_range.m_start == lb2->src_range.m_start
&& lb1->src_range.m_finish == lb2->src_range.m_finish
- && lb1->data == lb2->data);
+ && lb1->data == lb2->data
+ && lb1->discriminator == lb2->discriminator);
}
/* Update the hashtable when location_adhoc_data_map::data is reallocated.
@@ -127,13 +129,17 @@ static bool
can_be_stored_compactly_p (line_maps *set,
location_t locus,
source_range src_range,
- void *data)
+ void *data,
+ unsigned discriminator)
{
/* If there's an ad-hoc pointer, we can't store it directly in the
location_t, we need the lookaside. */
if (data)
return false;
+ if (discriminator != 0)
+ return false;
+
/* We only store ranges that begin at the locus and that are sufficiently
"sane". */
if (src_range.m_start != locus)
@@ -168,7 +174,8 @@ location_t
get_combined_adhoc_loc (line_maps *set,
location_t locus,
source_range src_range,
- void *data)
+ void *data,
+ unsigned discriminator)
{
struct location_adhoc_data lb;
struct location_adhoc_data **slot;
@@ -186,7 +193,7 @@ get_combined_adhoc_loc (line_maps *set,
|| pure_location_p (set, locus));
/* Consider short-range optimization. */
- if (can_be_stored_compactly_p (set, locus, src_range, data))
+ if (can_be_stored_compactly_p (set, locus, src_range, data, discriminator))
{
/* The low bits ought to be clear. */
linemap_assert (pure_location_p (set, locus));
@@ -206,15 +213,16 @@ get_combined_adhoc_loc (line_maps *set,
when locus == start == finish (and data is NULL). */
if (locus == src_range.m_start
&& locus == src_range.m_finish
- && !data)
+ && !data && discriminator == 0)
return locus;
- if (!data)
+ if (!data && discriminator == 0)
set->num_unoptimized_ranges++;
lb.locus = locus;
lb.src_range = src_range;
lb.data = data;
+ lb.discriminator = discriminator;
slot = (struct location_adhoc_data **)
htab_find_slot (set->location_adhoc_data_map.htab, &lb, INSERT);
if (*slot == NULL)
@@ -261,6 +269,13 @@ get_data_from_adhoc_loc (const class line_maps *set, location_t loc)
return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data;
}
+unsigned
+get_discriminator_from_adhoc_loc (const class line_maps *set, location_t loc)
+{
+ linemap_assert (IS_ADHOC_LOC (loc));
+ return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].discriminator;
+}
+
/* Return the location for the adhoc loc. */
location_t
@@ -306,6 +321,15 @@ get_range_from_loc (line_maps *set,
return source_range::from_location (loc);
}
+unsigned
+get_discriminator_from_loc (line_maps *set,
+ location_t loc)
+{
+ if (IS_ADHOC_LOC (loc))
+ return get_discriminator_from_adhoc_loc (set, loc);
+ return 0;
+}
+
/* Get whether location LOC is a "pure" location, or
whether it is an ad-hoc location, or embeds range information. */