This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
source location reorg patch 1/n
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Zack Weinberg <zack at codesourcery dot com>
- Date: Thu, 01 May 2003 19:37:44 +0100
- Subject: source location reorg patch 1/n
- Organization: Codesourcery LLC
Zack,
this is the non-trivial remainder of the source location reorganization.
Following this I can incrementally change the source to hide the underlying
representation of a location_t.
booted & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2003-05-01 Nathan Sidwell <nathan@codesourcery.com>
* Makefile.in (TREE_H): Replace location.h with input.h.
(GTFILES) Remove location.h
(gt-lists.h): Replace gt-location.h with gt-input.h
* input.h (input_filename, input_line): Remove variables.
(location_s, location_t): Move from location.h.
(input_location): New.
(input_filename, input_line): New #defines.
* location.h: Remove.
* tree.h: Replace location.h with input.h.
(input_filename, input_line): Remove.
* scan.h (input_line): Remove.
* diagnostic.h: Replace location.h with input.h.
* gcc.h (input_filename, input_filename_length): Remove declarations.
* toplev.c (input_filename, input_line): Remove.
(input_location): Define.
(push_srcloc, pop_srcloc): Adjust.
* diagnostic.c (diagnostic_report_current_module): Adjust.
f
* lex.c (ffelex_file_pop_): Adjust file_stack member use.
(ffelex_file_push_): Likewise.
(ffelex_hash_): Likewise.
java
* lex.h (input_lineno): Remove declaration.
* parse-scan.y: #include input.h.
(input_filename): Remove declaration.
(input_location): Add definition.
(input_line): Remove definition.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1044
diff -c -3 -p -r1.1044 Makefile.in
*** Makefile.in 29 Apr 2003 20:34:45 -0000 1.1044
--- Makefile.in 1 May 2003 16:56:46 -0000
*************** RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H)
*** 633,639 ****
RTL_H = $(RTL_BASE_H) genrtl.h
PARAMS_H = params.h params.def
TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h version.h builtins.def \
! location.h
BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h $(PARTITION_H) \
hard-reg-set.h
COVERAGE_H = coverage.h gcov-io.h gcov-iov.h
--- 633,639 ----
RTL_H = $(RTL_BASE_H) genrtl.h
PARAMS_H = params.h params.def
TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h version.h builtins.def \
! input.h
BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h $(PARTITION_H) \
hard-reg-set.h
COVERAGE_H = coverage.h gcov-io.h gcov-iov.h
*************** s-preds: genpreds$(build_exeext) $(srcdi
*** 1968,1979 ****
$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
$(STAMP) s-preds
! GTFILES = $(srcdir)/location.h $(srcdir)/coretypes.h $(srcdir)/cpplib.h \
$(host_xm_file_list) $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) \
$(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \
$(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
$(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/ssa.h $(srcdir)/insn-addr.h \
! $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/location.h \
$(srcdir)/c-common.h $(srcdir)/c-tree.h \
$(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
$(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
--- 1968,1979 ----
$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
$(STAMP) s-preds
! GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h $(srcdir)/cpplib.h \
$(host_xm_file_list) $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) \
$(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \
$(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
$(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/ssa.h $(srcdir)/insn-addr.h \
! $(srcdir)/cselib.h $(srcdir)/basic-block.h \
$(srcdir)/c-common.h $(srcdir)/c-tree.h \
$(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
$(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
*************** gt-lists.h gt-alias.h gt-cselib.h gt-fol
*** 1999,2005 ****
gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h \
gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \
gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \
! gt-c-pragma.h gt-c-objc-common.h gtype-c.h gt-location.h \
gt-stringpool.h : s-gtype ; @true
gtyp-gen.h: Makefile
--- 1999,2005 ----
gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h \
gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \
gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \
! gt-c-pragma.h gt-c-objc-common.h gtype-c.h gt-input.h \
gt-stringpool.h : s-gtype ; @true
gtyp-gen.h: Makefile
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.c,v
retrieving revision 1.106
diff -c -3 -p -r1.106 diagnostic.c
*** diagnostic.c 1 May 2003 16:13:28 -0000 1.106
--- diagnostic.c 1 May 2003 16:57:41 -0000
*************** diagnostic_report_current_module (contex
*** 1383,1393 ****
if (p == input_file_stack->next)
output_verbatim (&context->buffer,
"In file included from %s:%d",
! p->name, p->line);
else
output_verbatim (&context->buffer,
",\n from %s:%d",
! p->name, p->line);
output_verbatim (&context->buffer, ":\n");
diagnostic_set_last_module (context);
}
--- 1383,1393 ----
if (p == input_file_stack->next)
output_verbatim (&context->buffer,
"In file included from %s:%d",
! p->location.file, p->location.line);
else
output_verbatim (&context->buffer,
",\n from %s:%d",
! p->location.file, p->location.line);
output_verbatim (&context->buffer, ":\n");
diagnostic_set_last_module (context);
}
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.h,v
retrieving revision 1.53
diff -c -3 -p -r1.53 diagnostic.h
*** diagnostic.h 30 Apr 2003 12:54:29 -0000 1.53
--- diagnostic.h 1 May 2003 16:57:41 -0000
*************** Software Foundation, 59 Temple Place - S
*** 23,29 ****
#define GCC_DIAGNOSTIC_H
#include "obstack.h"
! #include "location.h"
/* The type of a text to be formatted according a format specification
along with a list of things. */
--- 23,29 ----
#define GCC_DIAGNOSTIC_H
#include "obstack.h"
! #include "input.h"
/* The type of a text to be formatted according a format specification
along with a list of things. */
Index: gcc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.h,v
retrieving revision 1.13
diff -c -3 -p -r1.13 gcc.h
*** gcc.h 10 Mar 2003 23:41:37 -0000 1.13
--- gcc.h 1 May 2003 16:58:33 -0000
***************
*** 1,5 ****
/* Header file for modules that link with gcc.c
! Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GCC.
--- 1,5 ----
/* Header file for modules that link with gcc.c
! Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GCC.
*************** struct spec_function
*** 57,64 ****
extern int do_spec PARAMS ((const char *));
extern void record_temp_file PARAMS ((const char *, int, int));
extern void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
- extern const char *input_filename;
- extern size_t input_filename_length;
extern void fatal PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
extern void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
--- 57,62 ----
Index: input.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/input.h,v
retrieving revision 1.9
diff -c -3 -p -r1.9 input.h
*** input.h 1 May 2003 16:13:28 -0000 1.9
--- input.h 1 May 2003 16:58:33 -0000
*************** along with GCC; see the file COPYING. I
*** 19,42 ****
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
! /* Source file current line is coming from. */
! extern const char *input_filename;
! /* Top-level source file. */
! extern const char *main_input_filename;
! /* Line number in current source file. */
! extern int input_line;
! /* Stream for reading from input file. */
! extern FILE *finput;
! struct file_stack
! {
! const char *name;
! struct file_stack *next;
! int line;
! };
/* Stack of currently pending input files.
The line member is not accurate for the innermost file on the stack. */
--- 19,50 ----
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
! #ifndef GCC_INPUT_H
! #define GCC_INPUT_H
! /* The data structure used to record a location in a translation unit. */
! struct location_s GTY (())
! {
! /* The name of the source file involved. */
! const char *file;
!
! /* The line-location in the source file. */
! int line;
! };
! typedef struct location_s location_t;
! struct file_stack
! {
! struct file_stack *next;
! location_t location;
! };
! /* Top-level source file. */
! extern const char *main_input_filename;
! extern location_t input_location;
! #define input_line (input_location.line)
! #define input_filename (input_location.file)
/* Stack of currently pending input files.
The line member is not accurate for the innermost file on the stack. */
*************** extern int input_file_stack_tick;
*** 47,49 ****
--- 55,59 ----
extern void push_srcloc PARAMS ((const char *name, int line));
extern void pop_srcloc PARAMS ((void));
+
+ #endif
Index: location.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/location.h,v
retrieving revision 1.1
diff -c -3 -p -r1.1 location.h
*** location.h 10 Jul 2002 10:36:27 -0000 1.1
--- location.h 1 May 2003 16:58:41 -0000
***************
*** 1,38 ****
- /* Definition of location data type used in various part of GCC
- Copyright (C) 2002 Free Software Foundation, Inc.
- Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- In other words, you are welcome to use, share and improve this program.
- You are forbidden to forbid anyone else to use, share and improve
- what you give them. Help stamp out software-hoarding! */
-
- #ifndef GCC_LOCATION_H
- #define GCC_LOCATION_H
-
- /* The data structure used to record a location in a translation unit. */
- struct location_s GTY (())
- {
- /* The name of the source file involved. */
- const char *file;
-
- /* The line-location in the source file. */
- int line;
- };
- typedef struct location_s location_t;
-
- #endif
-
--- 0 ----
Index: scan.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/scan.h,v
retrieving revision 1.18
diff -c -3 -p -r1.18 scan.h
*** scan.h 1 May 2003 16:13:29 -0000 1.18
--- scan.h 1 May 2003 16:58:42 -0000
*************** extern int get_token _PARAMS ((FILE *, s
*** 77,80 ****
extern int source_lineno;
extern sstring source_filename;
- /* Current physical line number */
- extern int input_line;
--- 77,79 ----
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.748
diff -c -3 -p -r1.748 toplev.c
*** toplev.c 1 May 2003 16:13:29 -0000 1.748
--- toplev.c 1 May 2003 16:58:55 -0000
*************** const char *progname;
*** 149,168 ****
int save_argc;
char **save_argv;
- /* Name of current original source file (what was input to cpp).
- This comes from each #-command in the actual input. */
-
- const char *input_filename;
-
/* Name of top-level original source file (what was input to cpp).
This comes from the #-command at the beginning of the actual input.
If there isn't any there, then this is the cc1 input file name. */
const char *main_input_filename;
! /* Current line number in real source file. */
! int input_line;
/* Nonzero if it is unsafe to create any new pseudo registers. */
int no_new_pseudos;
--- 149,163 ----
int save_argc;
char **save_argv;
/* Name of top-level original source file (what was input to cpp).
This comes from the #-command at the beginning of the actual input.
If there isn't any there, then this is the cc1 input file name. */
const char *main_input_filename;
! /* Current position in real source file. */
! location_t input_location;
/* Nonzero if it is unsafe to create any new pseudo registers. */
int no_new_pseudos;
*************** push_srcloc (file, line)
*** 2147,2160 ****
struct file_stack *fs;
if (input_file_stack)
! {
! input_file_stack->name = input_filename;
! input_file_stack->line = input_line;
! }
fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
! fs->name = input_filename = file;
! fs->line = input_line = line;
fs->next = input_file_stack;
input_file_stack = fs;
input_file_stack_tick++;
--- 2142,2153 ----
struct file_stack *fs;
if (input_file_stack)
! input_file_stack->location = input_location;
fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
! input_filename = file;
! input_line = line;
! fs->location = input_location;
fs->next = input_file_stack;
input_file_stack = fs;
input_file_stack_tick++;
*************** pop_srcloc ()
*** 2175,2184 ****
input_file_stack_tick++;
if (input_file_stack)
! {
! input_filename = input_file_stack->name;
! input_line = input_file_stack->line;
! }
else
{
input_filename = NULL;
--- 2168,2174 ----
input_file_stack_tick++;
if (input_file_stack)
! input_location = input_file_stack->location;
else
{
input_filename = NULL;
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.399
diff -c -3 -p -r1.399 tree.h
*** tree.h 1 May 2003 16:13:30 -0000 1.399
--- tree.h 1 May 2003 16:59:16 -0000
*************** Software Foundation, 59 Temple Place - S
*** 24,30 ****
#include "machmode.h"
#include "version.h"
! #include "location.h"
/* Codes of tree nodes */
--- 24,30 ----
#include "machmode.h"
#include "version.h"
! #include "input.h"
/* Codes of tree nodes */
*************** extern const char *function_cannot_inlin
*** 2777,2789 ****
extern int real_zerop PARAMS ((tree));
/* Declare commonly used variables for tree structure. */
-
- /* Points to the name of the input file from which the current input
- being parsed originally came (before it went into cpp). */
- extern const char *input_filename;
-
- /* Current line number in input file. */
- extern int input_line;
/* Nonzero means lvalues are limited to those valid in pedantic ANSI C.
Zero means allow extended lvalues. */
--- 2777,2782 ----
Index: f/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/lex.c,v
retrieving revision 1.37
diff -c -3 -p -r1.37 lex.c
*** f/lex.c 1 May 2003 16:13:35 -0000 1.37
--- f/lex.c 1 May 2003 17:03:45 -0000
*************** ffelex_file_pop_ (const char *filename)
*** 796,802 ****
input_file_stack = p->next;
free (p);
input_file_stack_tick++;
! (*debug_hooks->end_source_file) (input_file_stack->line);
}
else
error ("#-lines for entering and leaving files don't match");
--- 796,802 ----
input_file_stack = p->next;
free (p);
input_file_stack_tick++;
! (*debug_hooks->end_source_file) (input_file_stack->location.line);
}
else
error ("#-lines for entering and leaving files don't match");
*************** ffelex_file_pop_ (const char *filename)
*** 804,810 ****
/* Now that we've pushed or popped the input stack,
update the name in the top element. */
if (input_file_stack)
! input_file_stack->name = filename;
}
static void
--- 804,810 ----
/* Now that we've pushed or popped the input stack,
update the name in the top element. */
if (input_file_stack)
! input_file_stack->location.file = filename;
}
static void
*************** ffelex_file_push_ (int old_lineno, const
*** 813,821 ****
struct file_stack *p
= (struct file_stack *) xmalloc (sizeof (struct file_stack));
! input_file_stack->line = old_lineno;
p->next = input_file_stack;
! p->name = filename;
input_file_stack = p;
input_file_stack_tick++;
--- 813,821 ----
struct file_stack *p
= (struct file_stack *) xmalloc (sizeof (struct file_stack));
! input_file_stack->location.line = old_lineno;
p->next = input_file_stack;
! p->location.file = filename;
input_file_stack = p;
input_file_stack_tick++;
*************** ffelex_file_push_ (int old_lineno, const
*** 824,830 ****
/* Now that we've pushed or popped the input stack,
update the name in the top element. */
if (input_file_stack)
! input_file_stack->name = filename;
}
/* Prepare to finish a statement-in-progress by sending the current
--- 824,830 ----
/* Now that we've pushed or popped the input stack,
update the name in the top element. */
if (input_file_stack)
! input_file_stack->location.file = filename;
}
/* Prepare to finish a statement-in-progress by sending the current
*************** ffelex_hash_ (FILE *finput)
*** 1260,1266 ****
{
/* Update the name in the top element of input_file_stack. */
if (input_file_stack)
! input_file_stack->name = input_filename;
if (token != NULL)
ffelex_token_kill (token);
--- 1260,1266 ----
{
/* Update the name in the top element of input_file_stack. */
if (input_file_stack)
! input_file_stack->location.file = input_filename;
if (token != NULL)
ffelex_token_kill (token);
Index: java/lex.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.h,v
retrieving revision 1.33
diff -c -3 -p -r1.33 lex.h
*** java/lex.h 1 May 2003 16:13:36 -0000 1.33
--- java/lex.h 1 May 2003 17:05:17 -0000
*************** The Free Software Foundation is independ
*** 29,35 ****
/* Extern global variables declarations */
extern FILE *finput;
- extern int input_lineno;
/* A Unicode character, as read from the input file */
typedef unsigned short unicode_t;
--- 29,34 ----
Index: java/parse-scan.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse-scan.y,v
retrieving revision 1.31
diff -c -3 -p -r1.31 parse-scan.y
*** java/parse-scan.y 1 May 2003 16:13:36 -0000 1.31
--- java/parse-scan.y 1 May 2003 17:05:18 -0000
*************** definitions and other extensions. */
*** 41,52 ****
#include "system.h"
#include "coretypes.h"
#include "tm.h"
!
#include "obstack.h"
#include "toplev.h"
- extern char *input_filename;
extern FILE *finput, *out;
/* Obstack for the lexer. */
struct obstack temporary_obstack;
--- 41,55 ----
#include "system.h"
#include "coretypes.h"
#include "tm.h"
! #include "input.h"
#include "obstack.h"
#include "toplev.h"
extern FILE *finput, *out;
+
+ /* Current position in real source file. */
+
+ location_t input_location;
/* Obstack for the lexer. */
struct obstack temporary_obstack;
*************** struct obstack temporary_obstack;
*** 54,64 ****
/* The current parser context. */
static struct parser_ctxt *ctxp;
! /* Error and warning counts, current line number, because they're used
! elsewhere */
int java_error_count;
int java_warning_count;
- int input_line;
/* Tweak default rules when necessary. */
static int absorber;
--- 57,65 ----
/* The current parser context. */
static struct parser_ctxt *ctxp;
! /* Error and warning counts, because they're used elsewhere */
int java_error_count;
int java_warning_count;
/* Tweak default rules when necessary. */
static int absorber;