Skip to content

Commit 431aa89

Browse files
author
nathan
committed
[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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265689 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent ce541b6 commit 431aa89

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

libcpp/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
2018-10-31 Nathan Sidwell <[email protected]>
22

3+
* include/line-map.h (IS_ORDINARY_LOC, IS_MACRO_LOC): New
4+
predicates.
5+
(IS_ADHOC_LOC): Move earlier.
6+
(MAP_ORDINARY_P): Use IS_ORDINARY_LOC.
7+
* line-map.c (linemap_location_from_macro_expansion_p): Use
8+
IS_MACRO_LOC.
9+
310
* include/cpplib.h (cpp_macro_definition_location): Make inline.
411
* macro.c (warn_of_redefinition): Fix comments, examine macro
512
type, use C++ for.

libcpp/include/line-map.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,32 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
558558
#define linemap_assert_fails(EXPR) (! (EXPR))
559559
#endif
560560

561+
/* Get whether location LOC is an ad-hoc, ordinary or macro location. */
562+
563+
inline bool
564+
IS_ORDINARY_LOC (source_location loc)
565+
{
566+
return loc < LINE_MAP_MAX_LOCATION;
567+
}
568+
569+
inline bool
570+
IS_ADHOC_LOC (source_location loc)
571+
{
572+
return loc > MAX_SOURCE_LOCATION;
573+
}
574+
575+
inline bool
576+
IS_MACRO_LOC (source_location loc)
577+
{
578+
return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
579+
}
580+
561581
/* Categorize line map kinds. */
562582

563583
inline bool
564584
MAP_ORDINARY_P (const line_map *map)
565585
{
566-
return map->start_location < LINE_MAP_MAX_LOCATION;
586+
return IS_ORDINARY_LOC (map->start_location);
567587
}
568588

569589
/* 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 *,
10371057

10381058
extern source_range get_range_from_loc (line_maps *set, source_location loc);
10391059

1040-
/* Get whether location LOC is an ad-hoc location. */
1041-
1042-
inline bool
1043-
IS_ADHOC_LOC (source_location loc)
1044-
{
1045-
return (loc & MAX_SOURCE_LOCATION) != loc;
1046-
}
1047-
10481060
/* Get whether location LOC is a "pure" location, or
10491061
whether it is an ad-hoc location, or embeds range information. */
10501062

libcpp/line-map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ linemap_location_from_macro_expansion_p (const struct line_maps *set,
12381238
location = set->location_adhoc_data_map.data[location
12391239
& MAX_SOURCE_LOCATION].locus;
12401240

1241-
return location >= LINE_MAP_MAX_LOCATION;
1241+
return IS_MACRO_LOC (location);
12421242
}
12431243

12441244
/* Given two virtual locations *LOC0 and *LOC1, return the first

0 commit comments

Comments
 (0)