This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[incremental] Patch: FYI: make main file user-owned


I'm checking this in on the incremental-compiler branch.

This makes the C lexer consider the main source file to be "user
owned".  Also it makes it a bit friendlier to debug the token hunk
code -- saving the starting token offset in a local makes it possible
to go "up" from any point in parsing and still find the start of the
current hunk.

Tom

ChangeLog:
2007-10-01  Tom Tromey  <tromey@redhat.com>

	* c-parser.c (c_parser_translation_unit): Make next_token a
	local.
	* c-lex.c (fe_file_change): Mark main file as user-owned.

Index: c-lex.c
===================================================================
--- c-lex.c	(revision 128142)
+++ c-lex.c	(working copy)
@@ -268,7 +268,7 @@
 
   update_header_times (new_map->to_file);
   in_system_header = new_map->sysp != 0;
-  lstate->user_owned = new_map->user_owned;
+  lstate->user_owned = new_map->user_owned || MAIN_FILE_P (new_map);
 #ifdef USE_MAPPED_LOCATION
   input_location = new_map->start_location;
 #else
Index: c-parser.c
===================================================================
--- c-parser.c	(revision 128823)
+++ c-parser.c	(working copy)
@@ -1798,12 +1798,15 @@
       do
 	{
 	  struct parsed_hunk *last_used = NULL;
+	  /* It is a bit friendlier for debugging to copy this into a
+	     local.  */
+	  size_t next_token = parser->next_token;
 
 	  ggc_collect ();
 
 	  /* Skip all the hunks that we've handled.  */
 	  while (parser->first_hunk
-		 && parser->next_token >= parser->first_hunk->next_token)
+		 && next_token >= parser->first_hunk->next_token)
 	    {
 	      last_used = parser->first_hunk;
 	      parser->first_hunk = parser->first_hunk->next;
@@ -1813,7 +1816,7 @@
 	     hunk, and there was a hunk open, close it and save its
 	     contents.  */
 	  if (parser->first_hunk
-	      && parser->next_token == parser->first_hunk->start_token)
+	      && next_token == parser->first_hunk->start_token)
 	    {
 	      if (parser->prev_hunk && parsed_any)
 		{
@@ -1829,14 +1832,14 @@
 	     user-owned header, then we choose to hunk by the
 	     declaration, and not by file change events.  FIXME: this
 	     means compilations by root can be somewhat weird.  */
-	  if (!parser->buffer[parser->next_token].in_system_header
-	      && parser->buffer[parser->next_token].user_owned)
+	  if (!parser->buffer[next_token].in_system_header
+	      && parser->buffer[next_token].user_owned)
 	    {
 	      struct parsed_hunk isolani;
 	      /* We don't really need to set all the fields here, but
 		 it does let us modify the functions that might refer
 		 to this structure without being overly careful.  */
-	      isolani.start_token = parser->next_token;
+	      isolani.start_token = next_token;
 	      isolani.next_token = c_parser_find_decl_boundary (parser);
 	      isolani.next = NULL;
 
@@ -1877,7 +1880,7 @@
 	      continue;
 	    }
 	  else if (parser->first_hunk
-		   && parser->next_token == parser->first_hunk->start_token)
+		   && next_token == parser->first_hunk->start_token)
 	    {
 	      /* This will map in the saved bindings and update the
 		 token pointer as side effects.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]