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 rename fileline typedef -> source_location


Some people suggested that 'fileline' may not be the best name
for the magic cookies managed by line-map.c.  One reason is that
we want to add column number support, so fileline is misleading.
The word 'location' is ambiguous (since it can also refer to a
location in memory).  Also, he postfix '_t' violates Posix
naming convenstion.  Zack suggested 'source_location' and I've
seen no objections.

So I propose the attached patch, at least for the tree-ssa branch.
I suggest it should be also checked into 3.4, to mark what is the
preferred typedef and avoid potential future merge complications.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-11-28  Per Bothner  <pbothner@apple.com>

	* line-map.h (source_location):  New typedef.
	(fileline):  Redefined as source_location.
	(struct line_map, linemap_add, linemap_lookup):  Replace filefile
	by source_location.
	* line-map.c (linemap_add, linemap_lookup):  Use source_location.

Index: line-map.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/line-map.h,v
retrieving revision 1.9.18.4
diff -u -p -r1.9.18.4 line-map.h
--- line-map.h	28 Sep 2003 06:06:29 -0000	1.9.18.4
+++ line-map.h	29 Nov 2003 02:06:43 -0000
@@ -1,5 +1,5 @@
 /* Map logical line numbers to (source file, line number) pairs.
-   Copyright (C) 2001
+   Copyright (C) 2001, 2003
    Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
@@ -32,8 +32,9 @@ enum lc_reason {LC_ENTER = 0, LC_LEAVE, 
 
 /* A logical line number, i,e, an "index" into a line_map.  */
 /* Long-term, we want to use this to replace struct location_s (in input.h),
-   and effectively typedef fileline location_t.  */
-typedef unsigned int fileline;
+   and effectively typedef source_location location_t.  */
+typedef unsigned int source_location;
+typedef source_location fileline; /* deprecated name */
 
 /* The logical line FROM_LINE maps to physical source file TO_FILE at
    line TO_LINE, and subsequently one-to-one until the next line_map
@@ -47,7 +48,7 @@ struct line_map
 {
   const char *to_file;
   unsigned int to_line;
-  fileline from_line;
+  source_location from_line;
   int included_from;
   ENUM_BITFIELD (lc_reason) reason : CHAR_BIT;
   unsigned char sysp;
@@ -92,11 +93,12 @@ extern void linemap_free (struct line_ma
    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,
-   fileline from_line, const char *to_file, unsigned int to_line);
+   source_location from_line, 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.  */
-extern const struct line_map *linemap_lookup (struct line_maps *, fileline);
+extern const struct line_map *linemap_lookup
+  (struct line_maps *, source_location);
 
 /* Print the file names and line numbers of the #include commands
    which led to the map MAP, if any, to stderr.  Nothing is output if
Index: line-map.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/line-map.c,v
retrieving revision 1.6.18.5
diff -u -p -r1.6.18.5 line-map.c
--- line-map.c	20 Aug 2003 20:44:25 -0000	1.6.18.5
+++ line-map.c	29 Nov 2003 02:06:43 -0000
@@ -1,5 +1,5 @@
 /* Map logical line numbers to (source file, line number) pairs.
-   Copyright (C) 2001
+   Copyright (C) 2001, 2003
    Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@ linemap_free (struct line_maps *set)
 
 const struct line_map *
 linemap_add (struct line_maps *set, enum lc_reason reason,
-	     unsigned int sysp, unsigned int from_line,
+	     unsigned int sysp, source_location from_line,
 	     const char *to_file, unsigned int to_line)
 {
   struct line_map *map;
@@ -166,7 +166,7 @@ linemap_add (struct line_maps *set, enum
    the list is sorted and we can use a binary search.  */
 
 const struct line_map *
-linemap_lookup (struct line_maps *set, unsigned int line)
+linemap_lookup (struct line_maps *set, source_location line)
 {
   unsigned int md, mn = 0, mx = set->used;
 

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