When dumping a range of tokens, I was not properly counting the tokens to be ...
13 years, 8 months ago
(2011-09-08 18:44:15 UTC)
#1
When dumping a range of tokens, I was not properly counting the tokens
to be dumped, which resulted in empty output when dumping a range
of tokens in the middle of a large array.
I also reduced the size of the window to print. It was too large to
be useful.
Tested on x86_64. Committed to branch.
Diego.
* parser.c (cp_lexer_dump_tokens): Properly count number of printed
tokens to know when to stop.
(cp_debug_parser): Reduce token window size to 20.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 700ca64..a46edba 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -259,7 +259,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
cp_token *start_token, unsigned num,
cp_token *curr_token)
{
- unsigned i;
+ unsigned i, nprinted;
cp_token *token;
bool do_print;
@@ -281,7 +281,8 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
}
do_print = false;
- for (i = 0; VEC_iterate (cp_token, buffer, i, token) && i < num; i++)
+ nprinted = 0;
+ for (i = 0; VEC_iterate (cp_token, buffer, i, token) && nprinted < num; i++)
{
if (token == start_token)
do_print = true;
@@ -289,6 +290,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
if (!do_print)
continue;
+ nprinted++;
if (token == curr_token)
fprintf (file, "[[");
@@ -462,7 +464,7 @@ cp_debug_parser_tokens (FILE *file, cp_parser *parser, int
window_size)
void
cp_debug_parser (FILE *file, cp_parser *parser)
{
- const size_t window_size = 200;
+ const size_t window_size = 20;
if (file == NULL)
file = stderr;
--
This patch is available for review at http://codereview.appspot.com/4991046
Issue 4991046: [pph] Fix token dumping within a window
(Closed)
Created 13 years, 8 months ago by Diego Novillo
Modified 13 years, 7 months ago
Reviewers:
Base URL:
Comments: 0