aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-10-31 14:57:13 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-10-31 14:57:13 +0000
commit87bacc2b392f48951491bf6454d7d6bcde127c90 (patch)
tree2f2758bb919239d08146f1801e6c722d58eb633c /libcpp/include
parentc9fb347ea14cd8f519a71374c97547044413a71f (diff)
downloadgcc-87bacc2b392f48951491bf6454d7d6bcde127c90.zip
gcc-87bacc2b392f48951491bf6454d7d6bcde127c90.tar.gz
gcc-87bacc2b392f48951491bf6454d7d6bcde127c90.tar.bz2
[4/7] Preprocessor location-kind predicates
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02040.html * include/line-map.h (IS_ORDINARY_LOC, IS_MACRO_LOC): New predicates. (IS_ADHOC_LOC): Move earlier. (MAP_ORDINARY_P): Use IS_ORDINARY_LOC. * line-map.c (linemap_location_from_macro_expansion_p): Use IS_MACRO_LOC. From-SVN: r265689
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/line-map.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 23f0e4a..ae9780e 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -558,12 +558,32 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
#define linemap_assert_fails(EXPR) (! (EXPR))
#endif
+/* Get whether location LOC is an ad-hoc, ordinary or macro location. */
+
+inline bool
+IS_ORDINARY_LOC (source_location loc)
+{
+ return loc < LINE_MAP_MAX_LOCATION;
+}
+
+inline bool
+IS_ADHOC_LOC (source_location loc)
+{
+ return loc > MAX_SOURCE_LOCATION;
+}
+
+inline bool
+IS_MACRO_LOC (source_location loc)
+{
+ return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
+}
+
/* Categorize line map kinds. */
inline bool
MAP_ORDINARY_P (const line_map *map)
{
- return map->start_location < LINE_MAP_MAX_LOCATION;
+ return IS_ORDINARY_LOC (map->start_location);
}
/* Return TRUE if MAP encodes locations coming from a macro
@@ -1037,14 +1057,6 @@ extern source_location get_location_from_adhoc_loc (struct line_maps *,
extern source_range get_range_from_loc (line_maps *set, source_location loc);
-/* Get whether location LOC is an ad-hoc location. */
-
-inline bool
-IS_ADHOC_LOC (source_location loc)
-{
- return (loc & MAX_SOURCE_LOCATION) != loc;
-}
-
/* Get whether location LOC is a "pure" location, or
whether it is an ad-hoc location, or embeds range information. */