mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-11 02:57:14 +08:00
[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
This commit is contained in:
parent
c9fb347ea1
commit
87bacc2b39
@ -1,5 +1,12 @@
|
|||||||
2018-10-31 Nathan Sidwell <nathan@acm.org>
|
2018-10-31 Nathan Sidwell <nathan@acm.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
* include/cpplib.h (cpp_macro_definition_location): Make inline.
|
* include/cpplib.h (cpp_macro_definition_location): Make inline.
|
||||||
* macro.c (warn_of_redefinition): Fix comments, examine macro
|
* macro.c (warn_of_redefinition): Fix comments, examine macro
|
||||||
type, use C++ for.
|
type, use C++ for.
|
||||||
|
@ -558,12 +558,32 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
|
|||||||
#define linemap_assert_fails(EXPR) (! (EXPR))
|
#define linemap_assert_fails(EXPR) (! (EXPR))
|
||||||
#endif
|
#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. */
|
/* Categorize line map kinds. */
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
MAP_ORDINARY_P (const line_map *map)
|
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
|
/* 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);
|
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
|
/* Get whether location LOC is a "pure" location, or
|
||||||
whether it is an ad-hoc location, or embeds range information. */
|
whether it is an ad-hoc location, or embeds range information. */
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ linemap_location_from_macro_expansion_p (const struct line_maps *set,
|
|||||||
location = set->location_adhoc_data_map.data[location
|
location = set->location_adhoc_data_map.data[location
|
||||||
& MAX_SOURCE_LOCATION].locus;
|
& MAX_SOURCE_LOCATION].locus;
|
||||||
|
|
||||||
return location >= LINE_MAP_MAX_LOCATION;
|
return IS_MACRO_LOC (location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given two virtual locations *LOC0 and *LOC1, return the first
|
/* Given two virtual locations *LOC0 and *LOC1, return the first
|
||||||
|
Loading…
Reference in New Issue
Block a user