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]

PATCH to improve -dD output


This improvees output of -dD to avoid redundant
#1 <built-in>
and
#1 <command-line>
lines.  E.g. given the command:

./cc1 -E -quiet -dD -Dfoo=1 -Dbar - </dev/null

Instead of this:

# 1 "<stdin>"
# 1 "<built-in>"
#define __STDC_HOSTED__ 1
# 1 "<built-in>"
#define __GNUC__ 4
# 1 "<built-in>"
#define __GNUC_MINOR__ 1
...
# 1 "<command line>"
#define foo 1
# 1 "<command line>"
#define bar 1
# 1 "<stdin>"

we get:

# 1 "<stdin>"
# 1 "<built-in>"
#define __STDC_HOSTED__ 1
#define __GNUC__ 4
#define __GNUC_MINOR__ 1
...
# 1 "<command-line>"
#define foo 1
#define bar 1
# 1 "<stdin>"

Ok for mainline?
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/
2005-10-12  Per Bothner  <per@bothner.com>

	Suppress extra '#1 <built-in> or '#1 <command line>' on -dD output.
	* c-opts.c (finish_options): Use internal line 0 for <command-line>.
	* c-ppoutput.c (cb_define): Don't increment line 0.

Index: c-opts.c
===================================================================q
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.148
diff -u -p -r1.148 c-opts.c
--- c-opts.c	19 Jul 2005 12:09:31 -0000	1.148
+++ c-opts.c	12 Oct 2005 16:37:28 -0000
@@ -1325,7 +1325,10 @@ finish_options (void)
 	 their acceptance on the -std= setting.  */
       cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99);
 
-      cpp_change_file (parse_in, LC_RENAME, _("<command line>"));
+      cb_file_change (parse_in,
+		      linemap_add (&line_table, LC_RENAME, 0,
+				   _("<command-line>"), 0));
+
       for (i = 0; i < deferred_count; i++)
 	{
 	  struct deferred_opt *opt = &deferred_opts[i];
Index: c-ppoutput.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-ppoutput.c,v
retrieving revision 1.25
diff -u -p -r1.25 c-ppoutput.c
--- c-ppoutput.c	25 Jun 2005 01:59:23 -0000	1.25
+++ c-ppoutput.c	12 Oct 2005 16:37:28 -0000
@@ -322,7 +323,8 @@ cb_define (cpp_reader *pfile, source_loc
     fputs ((const char *) NODE_NAME (node), print.outf);
 
   putc ('\n', print.outf);
-  print.src_line++;
+  if (linemap_lookup (&line_table, line)->to_line != 0)
+    print.src_line++;
 }
 
 static void

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