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: fix user-owned header bug, and API


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

In order to properly track "user owned" status when leaving a file, we
need to compute this field in linemap_add.  Doing this also removes an
ugly cast in _cpp_do_file_change.

This patch also updates all the other front ends.  This will require
more work when mapped locations are merged to the branch, but those
spots will show up as compile-time errors, so it is no big deal.

The user_owned bit is only useful to front ends.  Non-C front ends can
simply always set it to 'false', and that's what I've done here.

Tom

libcpp/ChangeLog:
2007-11-30  Tom Tromey  <tromey@redhat.com>

	* include/line-map.h (linemap_add): Update.
	* directives.c (_cpp_do_file_change): Update.
	* line-map.c (linemap_add): Add user_owned argument.  Inherit
	user_owned when leaving.
	(linemap_line_start): Update.

gcc/java/ChangeLog:
2007-11-30  Tom Tromey  <tromey@redhat.com>

	* lang.c (java_post_options): Update.
	* jcf-parse.c (give_name_to_class): Update.
	(jcf_parse): Update.
	(duplicate_class_warning): Update.
	(java_parse_file): Update.

gcc/ChangeLog:
2007-11-30  Tom Tromey  <tromey@redhat.com>

	* c-opts.c (finish_options): Update.

gcc/fortran/ChangeLog:
2007-11-30  Tom Tromey  <tromey@redhat.com>

	* scanner.c (get_file): Update.
	(load_file): Update.
	* f95-lang.c (gfc_init): Update

gcc/treelang/ChangeLog:
2007-11-30  Tom Tromey  <tromey@redhat.com>

	* tree1.c (treelang_init): Update.
	(treelang_parse_file): Update.

Index: libcpp/directives.c
===================================================================
--- libcpp/directives.c	(revision 128142)
+++ libcpp/directives.c	(working copy)
@@ -982,14 +982,9 @@
 		     unsigned int sysp, unsigned int user_owned)
 {
   const struct line_map *map = linemap_add (pfile->line_table, reason, sysp,
-					    to_file, file_line);
+					    user_owned, to_file, file_line);
   if (map != NULL)
-    {
-      /* FIXME */
-      struct line_map *m2 = (struct line_map *) map;
-      m2->user_owned = user_owned;
-      linemap_line_start (pfile->line_table, map->to_line, 127);
-    }
+    linemap_line_start (pfile->line_table, map->to_line, 127);
 
   if (pfile->cb.file_change)
     pfile->cb.file_change (pfile, map);
Index: libcpp/line-map.c
===================================================================
--- libcpp/line-map.c	(revision 127650)
+++ libcpp/line-map.c	(working copy)
@@ -1,5 +1,5 @@
 /* Map logical line numbers to (source file, line number) pairs.
-   Copyright (C) 2001, 2003, 2004
+   Copyright (C) 2001, 2003, 2004, 2007
    Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
@@ -86,7 +86,8 @@
 
 const struct line_map *
 linemap_add (struct line_maps *set, enum lc_reason reason,
-	     unsigned int sysp, const char *to_file, unsigned int to_line)
+	     unsigned int sysp, unsigned int user_owned,
+	     const char *to_file, unsigned int to_line)
 {
   struct line_map *map;
   source_location start_location = set->highest_location + 1;
@@ -141,6 +142,7 @@
       if (error || to_file == NULL)
 	{
 	  to_file = from->to_file;
+	  user_owned = from->user_owned;
 	  to_line = SOURCE_LINE (from, from[1].start_location);
 	  sysp = from->sysp;
 	}
@@ -148,6 +150,7 @@
 
   map->reason = reason;
   map->sysp = sysp;
+  map->user_owned = user_owned;
   map->start_location = start_location;
   map->to_file = to_file;
   map->to_line = to_line;
@@ -219,7 +222,8 @@
 	  || last_line != map->to_line
 	  || SOURCE_COLUMN (map, highest) >= (1U << column_bits))
 	map = (struct line_map*) linemap_add (set, LC_RENAME, map->sysp,
-				      map->to_file, to_line);
+					      map->user_owned,
+					      map->to_file, to_line);
       map->column_bits = column_bits;
       r = map->start_location + ((to_line - map->to_line) << column_bits);
     }
Index: libcpp/include/line-map.h
===================================================================
--- libcpp/include/line-map.h	(revision 128142)
+++ libcpp/include/line-map.h	(working copy)
@@ -118,14 +118,15 @@
    The text pointed to by TO_FILE must have a lifetime
    at least as long as the final call to lookup_line ().  An empty
    TO_FILE means standard input.  If reason is LC_LEAVE, and
-   TO_FILE is NULL, then TO_FILE, TO_LINE and SYSP are given their
-   natural values considering the file we are returning to.
+   TO_FILE is NULL, then TO_FILE, TO_LINE, SYSP, and USER_OWNED are
+   given their natural values considering the file we are returning
+   to.
 
    A call to this function can relocate the previous set of
    maps, so any stored line_map pointers should not be used.  */
 extern const struct line_map *linemap_add
   (struct line_maps *, enum lc_reason, unsigned int sysp,
-   const char *to_file, unsigned int to_line);
+   unsigned int user_owned, const char *to_file, unsigned int to_line);
 
 /* Given a logical line, returns the map from which the corresponding
    (source file, line) pair can be deduced.  */
Index: gcc/java/jcf-parse.c
===================================================================
--- gcc/java/jcf-parse.c	(revision 130518)
+++ gcc/java/jcf-parse.c	(working copy)
@@ -1210,7 +1210,7 @@
       {
       tree source_name = identifier_subst (class_name, "", '.', '/', ".java");
       const char *sfname = IDENTIFIER_POINTER (source_name);
-      linemap_add (&line_table, LC_ENTER, false, sfname, 0);
+      linemap_add (&line_table, LC_ENTER, false, false, sfname, 0);
       input_location = linemap_line_start (&line_table, 0, 1);
       file_start_location = input_location;
       DECL_SOURCE_LOCATION (TYPE_NAME (this_class)) = input_location;
@@ -1498,7 +1498,7 @@
     annotation_write_byte (JV_DONE_ATTR);
 
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
+  linemap_add (&line_table, LC_LEAVE, false, false, NULL, 0);
 #endif
 
   /* The fields of class_type_node are already in correct order. */
@@ -1533,7 +1533,7 @@
 {
   location_t warn_loc;
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_RENAME, 0, filename, 0);
+  linemap_add (&line_table, LC_RENAME, 0, 0, filename, 0);
   warn_loc = linemap_line_start (&line_table, 0, 1);
 #else
   warn_loc.file = filename;
@@ -1927,7 +1927,7 @@
 	  main_jcf->read_state = finput;
 	  main_jcf->filbuf = jcf_filbuf_from_stdio;
 #ifdef USE_MAPPED_LOCATION
-	  linemap_add (&line_table, LC_ENTER, false, filename, 0);
+	  linemap_add (&line_table, LC_ENTER, false, false, filename, 0);
 	  input_location = linemap_line_start (&line_table, 0, 1);
 #endif
 	  if (open_in_zip (main_jcf, filename, NULL, 0) <  0)
@@ -1936,7 +1936,7 @@
 	  /* Register all the classes defined there.  */
 	  process_zip_dir (main_jcf->read_state);
 #ifdef USE_MAPPED_LOCATION
-	  linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
+	  linemap_add (&line_table, LC_LEAVE, false, false, NULL, 0);
 #endif
 	  parse_zip_file_entries ();
 	}
@@ -1951,7 +1951,7 @@
 	  java_parser_context_restore_global ();
 	  java_pop_parser_context (1);
 #ifdef USE_MAPPED_LOCATION
-	  linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
+	  linemap_add (&line_table, LC_LEAVE, false, false, NULL, 0);
 #endif
 #endif
 	}
Index: gcc/java/lang.c
===================================================================
--- gcc/java/lang.c	(revision 130053)
+++ gcc/java/lang.c	(working copy)
@@ -653,8 +653,8 @@
 	}
     }
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_ENTER, false, filename, 0);
-  linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0);
+  linemap_add (&line_table, LC_ENTER, false, false, filename, 0);
+  linemap_add (&line_table, LC_RENAME, false, false, "<built-in>", 0);
 #endif
 
   /* Initialize the compiler back end.  */
Index: gcc/fortran/scanner.c
===================================================================
--- gcc/fortran/scanner.c	(revision 130053)
+++ gcc/fortran/scanner.c	(working copy)
@@ -1170,7 +1170,7 @@
     f->inclusion_line = current_file->line;
 
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, reason, false, f->filename, 1);
+  linemap_add (&line_table, reason, false, false, f->filename, 1);
 #endif
 
   return f;
@@ -1537,7 +1537,7 @@
 
   current_file = current_file->up;
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_LEAVE, 0, NULL, 0);
+  linemap_add (&line_table, LC_LEAVE, 0, 0, NULL, 0);
 #endif
   return SUCCESS;
 }
Index: gcc/fortran/f95-lang.c
===================================================================
--- gcc/fortran/f95-lang.c	(revision 130518)
+++ gcc/fortran/f95-lang.c	(working copy)
@@ -319,8 +319,8 @@
 gfc_init (void)
 {
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_ENTER, false, gfc_source_file, 1);
-  linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0);
+  linemap_add (&line_table, LC_ENTER, false, false, gfc_source_file, 1);
+  linemap_add (&line_table, LC_RENAME, false, false, "<built-in>", 0);
 #endif
 
   /* First initialize the backend.  */
Index: gcc/treelang/tree1.c
===================================================================
--- gcc/treelang/tree1.c	(revision 130053)
+++ gcc/treelang/tree1.c	(working copy)
@@ -141,7 +141,7 @@
 #ifndef USE_MAPPED_LOCATION
   input_filename = main_input_filename;
 #else
-  linemap_add (&line_table, LC_ENTER, false, main_input_filename, 1);
+  linemap_add (&line_table, LC_ENTER, false, false, main_input_filename, 1);
 #endif
 
   /* This error will not happen from GCC as it will always create a
@@ -165,7 +165,7 @@
     }
 
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_RENAME, false, "<built-in>", 1);
+  linemap_add (&line_table, LC_RENAME, false, false, "<built-in>", 1);
   linemap_line_start (&line_table, 0, 1);
 #endif
 
@@ -190,7 +190,7 @@
 {
 #ifdef USE_MAPPED_LOCATION
   source_location s;
-  linemap_add (&line_table, LC_RENAME, false, main_input_filename, 1);
+  linemap_add (&line_table, LC_RENAME, false, false, main_input_filename, 1);
   s = linemap_line_start (&line_table, 1, 80);
   input_location = s;
 #else
@@ -201,7 +201,7 @@
   yyparse ();
   cgraph_finalize_compilation_unit ();
 #ifdef USE_MAPPED_LOCATION
-  linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
+  linemap_add (&line_table, LC_LEAVE, false, false, NULL, 0);
 #endif
   cgraph_optimize ();
 }
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c	(revision 130053)
+++ gcc/c-opts.c	(working copy)
@@ -1519,7 +1519,7 @@
       size_t i;
 
       cb_file_change (parse_in,
-		      linemap_add (&line_table, LC_RENAME, 0,
+		      linemap_add (&line_table, LC_RENAME, 0, 0,
 				   _("<built-in>"), 0));
 
       cpp_init_builtins (parse_in, flag_hosted);
@@ -1537,7 +1537,7 @@
       cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99);
 
       cb_file_change (parse_in,
-		      linemap_add (&line_table, LC_RENAME, 0,
+		      linemap_add (&line_table, LC_RENAME, 0, 0,
 				   _("<command-line>"), 0));
 
       for (i = 0; i < deferred_count; i++)


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