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]

Re: gengtype improvements for plugins, thirdround! patch 3/7 [inputfile]


2010/9/21 Basile Starynkevitch <basile@starynkevitch.net>:
> The gengtype-lex.l & gengtype-parse.c files need to include fatal.h
> because it is used from gengtype.h

OK. In that case bonus points for a follow-up patch that includes
fatal.h from gengtype.h and updates Makefile accordingly :)

> Since struct location_s is no longer used inside GCC, the hack in
> new_structure to handle it is removed.

This is excellent, but it really should be a separate patch.

-/* The plugin input files and their number; in that case only
-   a single file is produced.  */
-static char** plugin_files;
+/* The plugin input files and their number; in plugin mode only a
+   single file is produced.  */
+static input_file** plugin_files;

Please remove the comment part after semicolon (the comment should
explain plugin_files definition, the numer of output files is
irrelevant to that definition)

-/* The gt- output file name for F.  */
+/* The gt- output file name for INPF.  */

 static const char *
-get_file_gtfilename (const char *f)
+get_file_gtfilename (const input_file *inpf)

Drop the empty line between the comment and the definition.

@@ -4424,89 +4384,142 @@ print_version (void)
 static void
 parse_program_options (int argc, char**argv)
 {
-    int opt = -1;
+  int opt = -1;
[...two hundred lines or so of indentation changes follow...]

These parse_program_options changes only fix indentation in the first
patch, so please fix the first patch and this will disappear. If there
were any real code changes here, I couldn't tell through all those
formatting changes.

-      for (i = 0; i < num_gt_files; i++) {
-	parse_file (gt_files[i]);
-	DBGPRINTF ("parsed file #%d %s", (int) i, gt_files[i]);
-      }
+      for (i = 0; i < num_gt_files; i++)
+	{
+	  parse_file (get_input_file_name (gt_files[i]));
+	  DBGPRINTF ("parsed file #%d %s", (int) i, get_input_file_name
(gt_files[i]));
+	}

Same here. (Here at least I can see the non-formatting code change)

+	    if (relp)
+	      /* The input file is a GCC source file, we use a double
+		 colon after anonymous.  To be sure s is truly unique,
+		 we also use anonymous_count.  */
+	      s = xasprintf ("anonymous::%s:%d::%d",
+			     relp, lexer_line.line, anonymous_count);
+	    else
+	      /* The input file is outside of GCC source tree, we use
+		 a single colon after anonymous.  To be sure s is
+		 truly unique, we also use anonymous_count.  */
+	      s = xasprintf ("anonymous:%s:%d::%d",
+			     get_input_file_name (lexer_line.file),
+			     lexer_line.line, anonymous_count);

Here and in similar following fragments, please add { } on if and else
clauses (too many visual lines).

As far as I'm concerned, the non-magic patch would be OK with these changes.

> ########## gcc/ChangeLog entry is
> 2010-09-20 ÂJeremie Salvucci Â<jeremie.salvucci@free.fr>
> Â Â Â Â Â ÂBasile Starynkevitch Â<basile@starynkevitch.net>
>
> Â Â Â Â* gengtype.c (get_output_file_name, plugin_files)
> Â Â Â Â(get_file_srcdir_relative_path, nb_plugin_files): moved to gengtype.h.
> Â Â Â Â(get_file_basename, get_file_realbasename, get_file_langdir): Use
> Â Â Â Âan input_file as argument.
> Â Â Â Â(error_at_line): Use input_file-s.
> Â Â Â Â(gt_files, num_gt_files, this_file, system_h_file): Declared as
> Â Â Â Âinput_file-s.
> Â Â Â Â(lang_dir_names, num_lang_dirs): No static.
> Â Â Â Â(get_lang_bitmap, set_lang_bitmap): Moved to gengtype.h.
> Â Â Â Â(read_input_list): Use input_file-s.
> Â Â Â Â(new_structure): Remove location_s hack.
> Â Â Â Â(creat_field_all, get_file_realbasename)
> Â Â Â Â(get_file_srcdir_relative_path, get_file_basename)
> Â Â Â Â(get_file_langdir, get_file_gtfilename)
> Â Â Â Â(get_output_file_with_visibility, get_output_file_name)
> Â Â Â Â(put_mangled_filename): Use input_file-s.
> Â Â Â Â(struct flist): Removed name and added file field.
> Â Â Â Â(output_type_enum): Use input_file-s.
> Â Â Â Â(finish_root_table, write_roots): Use file not name field of
> Â Â Â Âstruct flist.
> Â Â Â Â(dump_fileloc, parse_program_options): Use input_file-s.
>
> Â Â Â Â* gengtype.h (struct input_file_st, input_file): New structure and
> Â Â Â Âtype.
> Â Â Â Â(INPUT_FILE_MAGIC, CHECK_INPUT_FILE_MAGIC): New macros.
> Â Â Â Â(gt_files, num_gt_files): New variables moved from gengtype.c.
> Â Â Â Â(this_file, system_h_file): New variables.
> Â Â Â Â(input_file_by_name): Declared new function.
> Â Â Â Â(get_input_file_name): New inline function.
> Â Â Â Â(get_lang_bitmap, set_lang_bitmap): Moved from gengtype.c and
> Â Â Â Âupdated.
> Â Â Â Â(struct fileloc): field file changed type.
> Â Â Â Â(lang_dir_names, num_lang_dirs): moved from gengtype.c.
> Â Â Â Â(get_output_file_with_visibility, get_output_file_name): Use
> Â Â Â Âinput_file-s.
>
> Â Â Â Â* gengtype-lex.l: ÂUpdated copyright year. Included errors.h.
> Â Â Â Â(yybegin): use input_file-s.
>
> Â Â Â Â* gengtype-parse.c: Â Updated copyright year. Included errors.h.
> Â Â Â Â(parse_error): Use input_file-s.
> Â Â Â Â(type): Generate anonymous names differently for GCC source input
> Â Â Â Âand other input.

-- 
Laurynas


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