aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog5
-rw-r--r--libcpp/include/line-map.h4
-rw-r--r--libcpp/line-map.cc11
3 files changed, 20 insertions, 0 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 8c10718..3c5bae1 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,8 @@
+2025-06-17 Jason Merrill <jason@redhat.com>
+
+ * line-map.cc (linemap_location_from_module_p): Add.
+ * include/line-map.h: Declare it.
+
2025-06-11 David Malcolm <dmalcolm@redhat.com>
PR other/116792
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 83ebbde..21a59af 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1111,6 +1111,10 @@ extern location_t linemap_module_loc
extern void linemap_module_reparent
(line_maps *, location_t loc, location_t new_parent);
+/* TRUE iff the location comes from a module import. */
+extern bool linemap_location_from_module_p
+ (const line_maps *, location_t);
+
/* Restore the linemap state such that the map at LWM-1 continues.
Return start location of the new map. */
extern location_t linemap_module_restore
diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
index 284af57..33701b5 100644
--- a/libcpp/line-map.cc
+++ b/libcpp/line-map.cc
@@ -767,6 +767,17 @@ linemap_module_restore (line_maps *set, line_map_uint_t lwm)
return 0;
}
+/* TRUE iff the location comes from a module import. */
+
+bool
+linemap_location_from_module_p (const line_maps *set, location_t loc)
+{
+ const line_map_ordinary *map = linemap_ordinary_map_lookup (set, loc);
+ while (map && map->reason != LC_MODULE)
+ map = linemap_included_from_linemap (set, map);
+ return !!map;
+}
+
/* Returns TRUE if the line table set tracks token locations across
macro expansion, FALSE otherwise. */