aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog9
-rw-r--r--libcpp/include/line-map.h15
-rw-r--r--libcpp/line-map.cc22
3 files changed, 44 insertions, 2 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index eef6ec7..8c10718 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,12 @@
+2025-06-11 David Malcolm <dmalcolm@redhat.com>
+
+ PR other/116792
+ * include/line-map.h (typedef expanded_location): Convert to...
+ (struct expanded_location): ...this.
+ (operator==): New decl, for expanded_location.
+ (operator!=): Likewise.
+ * line-map.cc (operator==): New decl, for expanded_location.
+
2025-05-07 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/108900
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 75cc1ad..83ebbde 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1280,7 +1280,7 @@ linemap_location_before_p (const line_maps *set,
return linemap_compare_locations (set, loc_a, loc_b) >= 0;
}
-typedef struct
+struct expanded_location
{
/* The name of the source file involved. */
const char *file;
@@ -1294,7 +1294,18 @@ typedef struct
/* In a system header?. */
bool sysp;
-} expanded_location;
+};
+
+extern bool
+operator== (const expanded_location &a,
+ const expanded_location &b);
+inline bool
+operator!= (const expanded_location &a,
+ const expanded_location &b)
+{
+ return !(a == b);
+}
+
/* This is enum is used by the function linemap_resolve_location
below. The meaning of the values is explained in the comment of
diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
index cf65571..284af57 100644
--- a/libcpp/line-map.cc
+++ b/libcpp/line-map.cc
@@ -1949,6 +1949,28 @@ linemap_expand_location (const line_maps *set,
return xloc;
}
+bool
+operator== (const expanded_location &a,
+ const expanded_location &b)
+{
+ /* "file" can be null; for them to be equal they must both
+ have either null or nonnull values, and if non-null
+ they must compare as equal. */
+ if ((a.file == nullptr) != (b.file == nullptr))
+ return false;
+ if (a.file && strcmp (a.file, b.file))
+ return false;
+
+ if (a.line != b.line)
+ return false;
+ if (a.column != b.column)
+ return false;
+ if (a.data != b.data)
+ return false;
+ if (a.sysp != b.sysp)
+ return false;
+ return true;
+}
/* Dump line map at index IX in line table SET to STREAM. If STREAM
is NULL, use stderr. IS_MACRO is true if the caller wants to