Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1148)

Issue 4991046: [pph] Fix token dumping within a window (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 10 months ago by Diego Novillo
Modified:
12 years, 8 months ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -3 lines) Patch
M gcc/cp/parser.c View 4 chunks +5 lines, -3 lines 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years, 10 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
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b