Commit 22d66382 by Mikhail Maltsev Committed by Jeff Law

[PATCH 2/9] ENABLE_CHECKING refactoring: libcpp

[PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
        * include/line-map.h: Use CHECKING_P instead of ENABLE_CHECKING.
        * init.c: Likewise.
        * macro.c (struct macro_arg_token_iter, set_arg_token,
        macro_arg_token_iter_init, macro_arg_token_iter_forward,
        macro_arg_token_iter_get_token, macro_arg_token_iter_get_location,
        alloc_expanded_arg_mem, _cpp_backup_tokens): Likewise.

From-SVN: r229154
parent 44f92b59
2015-10-21 Mikhail Maltsev <maltsevm@gmail.com> 2015-10-21 Mikhail Maltsev <maltsevm@gmail.com>
* include/line-map.h: Use CHECKING_P instead of ENABLE_CHECKING.
* init.c: Likewise.
* macro.c (struct macro_arg_token_iter, set_arg_token,
macro_arg_token_iter_init, macro_arg_token_iter_forward,
macro_arg_token_iter_get_token, macro_arg_token_iter_get_location,
alloc_expanded_arg_mem, _cpp_backup_tokens): Likewise.
* config.in: Regenerate. * config.in: Regenerate.
* configure: Regenerate. * configure: Regenerate.
* configure.ac (CHECKING_P): Define. * configure.ac (CHECKING_P): Define.
......
...@@ -272,7 +272,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { ...@@ -272,7 +272,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
source_location expansion; source_location expansion;
}; };
#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) #if CHECKING_P && (GCC_VERSION >= 2007)
/* Assertion macro to be used in line-map code. */ /* Assertion macro to be used in line-map code. */
#define linemap_assert(EXPR) \ #define linemap_assert(EXPR) \
......
...@@ -535,7 +535,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted) ...@@ -535,7 +535,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
/* Sanity-checks are dependent on command-line options, so it is /* Sanity-checks are dependent on command-line options, so it is
called as a subroutine of cpp_read_main_file (). */ called as a subroutine of cpp_read_main_file (). */
#if ENABLE_CHECKING #if CHECKING_P
static void sanity_checks (cpp_reader *); static void sanity_checks (cpp_reader *);
static void sanity_checks (cpp_reader *pfile) static void sanity_checks (cpp_reader *pfile)
{ {
......
...@@ -73,7 +73,7 @@ struct macro_arg_token_iter ...@@ -73,7 +73,7 @@ struct macro_arg_token_iter
-ftrack-macro-expansion is used this location tracks loci across -ftrack-macro-expansion is used this location tracks loci across
macro expansion. */ macro expansion. */
const source_location *location_ptr; const source_location *location_ptr;
#ifdef ENABLE_CHECKING #if CHECKING_P
/* The number of times the iterator went forward. This useful only /* The number of times the iterator went forward. This useful only
when checking is enabled. */ when checking is enabled. */
size_t num_forwards; size_t num_forwards;
...@@ -1310,14 +1310,11 @@ set_arg_token (macro_arg *arg, const cpp_token *token, ...@@ -1310,14 +1310,11 @@ set_arg_token (macro_arg *arg, const cpp_token *token,
if (loc != NULL) if (loc != NULL)
{ {
#ifdef ENABLE_CHECKING /* We can't set the location of a stringified argument
if (kind == MACRO_ARG_TOKEN_STRINGIFIED token and we can't set any location if we aren't tracking
|| !track_macro_exp_p) macro expansion locations. */
/* We can't set the location of a stringified argument gcc_checking_assert (kind != MACRO_ARG_TOKEN_STRINGIFIED
token and we can't set any location if we aren't tracking && track_macro_exp_p);
macro expansion locations. */
abort ();
#endif
*loc = location; *loc = location;
} }
} }
...@@ -1403,7 +1400,7 @@ macro_arg_token_iter_init (macro_arg_token_iter *iter, ...@@ -1403,7 +1400,7 @@ macro_arg_token_iter_init (macro_arg_token_iter *iter,
iter->location_ptr = NULL; iter->location_ptr = NULL;
if (track_macro_exp_p) if (track_macro_exp_p)
iter->location_ptr = get_arg_token_location (arg, kind); iter->location_ptr = get_arg_token_location (arg, kind);
#ifdef ENABLE_CHECKING #if CHECKING_P
iter->num_forwards = 0; iter->num_forwards = 0;
if (track_macro_exp_p if (track_macro_exp_p
&& token_ptr != NULL && token_ptr != NULL
...@@ -1428,14 +1425,14 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it) ...@@ -1428,14 +1425,14 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it)
it->location_ptr++; it->location_ptr++;
break; break;
case MACRO_ARG_TOKEN_STRINGIFIED: case MACRO_ARG_TOKEN_STRINGIFIED:
#ifdef ENABLE_CHECKING #if CHECKING_P
if (it->num_forwards > 0) if (it->num_forwards > 0)
abort (); abort ();
#endif #endif
break; break;
} }
#ifdef ENABLE_CHECKING #if CHECKING_P
it->num_forwards++; it->num_forwards++;
#endif #endif
} }
...@@ -1444,7 +1441,7 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it) ...@@ -1444,7 +1441,7 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it)
static const cpp_token * static const cpp_token *
macro_arg_token_iter_get_token (const macro_arg_token_iter *it) macro_arg_token_iter_get_token (const macro_arg_token_iter *it)
{ {
#ifdef ENABLE_CHECKING #if CHECKING_P
if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED
&& it->num_forwards > 0) && it->num_forwards > 0)
abort (); abort ();
...@@ -1458,7 +1455,7 @@ macro_arg_token_iter_get_token (const macro_arg_token_iter *it) ...@@ -1458,7 +1455,7 @@ macro_arg_token_iter_get_token (const macro_arg_token_iter *it)
static source_location static source_location
macro_arg_token_iter_get_location (const macro_arg_token_iter *it) macro_arg_token_iter_get_location (const macro_arg_token_iter *it)
{ {
#ifdef ENABLE_CHECKING #if CHECKING_P
if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED
&& it->num_forwards > 0) && it->num_forwards > 0)
abort (); abort ();
...@@ -2144,11 +2141,9 @@ tokens_buff_add_token (_cpp_buff *buffer, ...@@ -2144,11 +2141,9 @@ tokens_buff_add_token (_cpp_buff *buffer,
static void static void
alloc_expanded_arg_mem (cpp_reader *pfile, macro_arg *arg, size_t capacity) alloc_expanded_arg_mem (cpp_reader *pfile, macro_arg *arg, size_t capacity)
{ {
#ifdef ENABLE_CHECKING gcc_checking_assert (arg->expanded == NULL
if (arg->expanded != NULL && arg->expanded_virt_locs == NULL);
|| arg->expanded_virt_locs != NULL)
abort ();
#endif
arg->expanded = XNEWVEC (const cpp_token *, capacity); arg->expanded = XNEWVEC (const cpp_token *, capacity);
if (CPP_OPTION (pfile, track_macro_expansion)) if (CPP_OPTION (pfile, track_macro_expansion))
arg->expanded_virt_locs = XNEWVEC (source_location, capacity); arg->expanded_virt_locs = XNEWVEC (source_location, capacity);
...@@ -2709,10 +2704,7 @@ _cpp_backup_tokens (cpp_reader *pfile, unsigned int count) ...@@ -2709,10 +2704,7 @@ _cpp_backup_tokens (cpp_reader *pfile, unsigned int count)
{ {
macro_context *m = pfile->context->c.mc; macro_context *m = pfile->context->c.mc;
m->cur_virt_loc--; m->cur_virt_loc--;
#ifdef ENABLE_CHECKING gcc_checking_assert (m->cur_virt_loc >= m->virt_locs);
if (m->cur_virt_loc < m->virt_locs)
abort ();
#endif
} }
else else
abort (); abort ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment