diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-13 10:24:30 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-13 10:24:30 +0000 |
commit | c43181ff6d23e293d51d2b3b5c5f809c86fd669f (patch) | |
tree | 7997cc36377ce49f4bd716ec5ebc9904d6b53c72 /libcpp | |
parent | 20d9b9e9b00e45e9c0b16c49af249641378707fc (diff) | |
download | gcc-c43181ff6d23e293d51d2b3b5c5f809c86fd669f.tar.gz |
line-map.h: move linemap_assert and friends higher up within the file
libcpp/ChangeLog:
* include/line-map.h (linemap_assert): Move up within the file to
before all of the map accessor macros.
(linemap_assert_fails): Likewise.
(linemap_check_ordinary): Likewise.
(linemap_macro_expansion_map_p): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223121 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 8 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 71 |
2 files changed, 44 insertions, 35 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index c0f04ac0445..848b3c47496 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,11 @@ +2015-05-13 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (linemap_assert): Move up within the file to + before all of the map accessor macros. + (linemap_assert_fails): Likewise. + (linemap_check_ordinary): Likewise. + (linemap_macro_expansion_map_p): Likewise. + 2015-05-12 David Malcolm <dmalcolm@redhat.com> * directives.c (do_line): Set seen_line_directive on line_table. diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index ddeaf0c1954..51dc09d3fdb 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -279,6 +279,42 @@ struct GTY(()) line_map { } GTY((desc ("%1.reason == LC_ENTER_MACRO"))) d; }; +#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) + +/* Assertion macro to be used in line-map code. */ +#define linemap_assert(EXPR) \ + do { \ + if (! (EXPR)) \ + abort (); \ + } while (0) + +/* Assert that becomes a conditional expression when checking is disabled at + compilation time. Use this for conditions that should not happen but if + they happen, it is better to handle them gracefully rather than crash + randomly later. + Usage: + + if (linemap_assert_fails(EXPR)) handle_error(); */ +#define linemap_assert_fails(EXPR) __extension__ \ + ({linemap_assert (EXPR); false;}) + +/* Assert that MAP encodes locations of tokens that are not part of + the replacement-list of a macro expansion. */ +#define linemap_check_ordinary(LINE_MAP) __extension__ \ + ({linemap_assert (!linemap_macro_expansion_map_p (LINE_MAP)); \ + (LINE_MAP);}) +#else +/* Include EXPR, so that unused variable warnings do not occur. */ +#define linemap_assert(EXPR) ((void)(0 && (EXPR))) +#define linemap_assert_fails(EXPR) (! (EXPR)) +#define linemap_check_ordinary(LINE_MAP) (LINE_MAP) +#endif + +/* Return TRUE if MAP encodes locations coming from a macro + replacement-list at macro expansion point. */ +bool +linemap_macro_expansion_map_p (const struct line_map *); + #define MAP_START_LOCATION(MAP) (MAP)->start_location #define ORDINARY_MAP_FILE_NAME(MAP) \ @@ -571,10 +607,6 @@ extern const struct line_map *linemap_lookup macro expansion, FALSE otherwise. */ bool linemap_tracks_macro_expansion_locs_p (struct line_maps *); -/* Return TRUE if MAP encodes locations coming from a macro - replacement-list at macro expansion point. */ -bool linemap_macro_expansion_map_p (const struct line_map *); - /* Return the name of the macro associated to MACRO_MAP. */ const char* linemap_map_get_macro_name (const struct line_map*); @@ -641,37 +673,6 @@ bool linemap_location_from_macro_expansion_p (const struct line_maps *, #define MAIN_FILE_P(MAP) \ ((linemap_check_ordinary (MAP)->d.ordinary.included_from < 0)) -#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) - -/* Assertion macro to be used in line-map code. */ -#define linemap_assert(EXPR) \ - do { \ - if (! (EXPR)) \ - abort (); \ - } while (0) - -/* Assert that becomes a conditional expression when checking is disabled at - compilation time. Use this for conditions that should not happen but if - they happen, it is better to handle them gracefully rather than crash - randomly later. - Usage: - - if (linemap_assert_fails(EXPR)) handle_error(); */ -#define linemap_assert_fails(EXPR) __extension__ \ - ({linemap_assert (EXPR); false;}) - -/* Assert that MAP encodes locations of tokens that are not part of - the replacement-list of a macro expansion. */ -#define linemap_check_ordinary(LINE_MAP) __extension__ \ - ({linemap_assert (!linemap_macro_expansion_map_p (LINE_MAP)); \ - (LINE_MAP);}) -#else -/* Include EXPR, so that unused variable warnings do not occur. */ -#define linemap_assert(EXPR) ((void)(0 && (EXPR))) -#define linemap_assert_fails(EXPR) (! (EXPR)) -#define linemap_check_ordinary(LINE_MAP) (LINE_MAP) -#endif - /* Encode and return a source_location from a column number. The source line considered is the last source line used to call linemap_line_start, i.e, the last source line which a location was |