Skip to content

Commit 3ce1a21

Browse files
author
dmalcolm
committedMay 20, 2015
libcpp: Eliminate most of the non-const/reference-returning inline fns
gcc/java/ChangeLog: * jcf-parse.c (set_source_filename): Replace write through ORDINARY_MAP_FILE_NAME with direct access to "to_file". libcpp/ChangeLog: * include/line-map.h (MAP_START_LOCATION): Eliminate the non-const variant, and tweak comment for the const variant. (ORDINARY_MAP_STARTING_LINE_NUMBER): Drop the non-const variant. (ORDINARY_MAP_INCLUDER_FILE_INDEX): Likewise. (ORDINARY_MAP_IN_SYSTEM_HEADER_P): Likewise. (SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Delete. (ORDINARY_MAP_FILE_NAME): Drop the non-const variant. (MACRO_MAP_MACRO): Likewise. (MACRO_MAP_NUM_MACRO_TOKENS): Likewise. (MACRO_MAP_LOCATIONS): Likewise. (MACRO_MAP_EXPANSION_POINT_LOCATION): Likewise. * line-map.c (linemap_add): Replace writes through macros with direct field accesses. (linemap_enter_macro): Likewise. (linemap_line_start): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223435 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 3ec9c44 commit 3ce1a21

File tree

5 files changed

+39
-101
lines changed

5 files changed

+39
-101
lines changed
 

‎gcc/java/ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-05-20 David Malcolm <dmalcolm@redhat.com>
2+
3+
* jcf-parse.c (set_source_filename): Replace write through
4+
ORDINARY_MAP_FILE_NAME with direct access to "to_file".
5+
16
2015-04-18 Trevor Saunders <tsaunders@mozilla.com>
27

38
* jcf-io.c: Adjust for hash_table changes.

‎gcc/java/jcf-parse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ set_source_filename (JCF *jcf, int index)
374374
}
375375

376376
sfname = find_sourcefile (sfname);
377-
ORDINARY_MAP_FILE_NAME (LINEMAPS_LAST_ORDINARY_MAP (line_table)) = sfname;
377+
LINEMAPS_LAST_ORDINARY_MAP (line_table)->to_file = sfname;
378378
if (current_class == main_class) main_input_filename = sfname;
379379
}
380380

‎libcpp/ChangeLog

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2015-05-20 David Malcolm <dmalcolm@redhat.com>
2+
3+
* include/line-map.h (MAP_START_LOCATION): Eliminate the non-const
4+
variant, and tweak comment for the const variant.
5+
(ORDINARY_MAP_STARTING_LINE_NUMBER): Drop the non-const variant.
6+
(ORDINARY_MAP_INCLUDER_FILE_INDEX): Likewise.
7+
(ORDINARY_MAP_IN_SYSTEM_HEADER_P): Likewise.
8+
(SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Delete.
9+
(ORDINARY_MAP_FILE_NAME): Drop the non-const variant.
10+
(MACRO_MAP_MACRO): Likewise.
11+
(MACRO_MAP_NUM_MACRO_TOKENS): Likewise.
12+
(MACRO_MAP_LOCATIONS): Likewise.
13+
(MACRO_MAP_EXPANSION_POINT_LOCATION): Likewise.
14+
* line-map.c (linemap_add): Replace writes through macros with
15+
direct field accesses.
16+
(linemap_enter_macro): Likewise.
17+
(linemap_line_start): Likewise.
18+
119
2015-05-19 David Malcolm <dmalcolm@redhat.com>
220

321
* directives.c (do_line): Strengthen local "map" from

‎libcpp/include/line-map.h

+1-85
Original file line numberDiff line numberDiff line change
@@ -343,23 +343,14 @@ linemap_check_macro (const line_map *map)
343343
return (const line_map_macro *)map;
344344
}
345345

346-
/* Read the start location of MAP, as an rvalue. */
346+
/* Read the start location of MAP. */
347347

348348
inline source_location
349349
MAP_START_LOCATION (const line_map *map)
350350
{
351351
return map->start_location;
352352
}
353353

354-
/* Access the start location of MAP as a reference
355-
(e.g. as an lvalue). */
356-
357-
inline source_location&
358-
MAP_START_LOCATION (line_map *map)
359-
{
360-
return map->start_location;
361-
}
362-
363354
/* Get the starting line number of ordinary map MAP. */
364355

365356
inline linenum_type
@@ -368,15 +359,6 @@ ORDINARY_MAP_STARTING_LINE_NUMBER (const line_map_ordinary *ord_map)
368359
return ord_map->to_line;
369360
}
370361

371-
/* Access the starting line number of ordinary map MAP by
372-
reference (e.g. as an lvalue). */
373-
374-
inline linenum_type&
375-
ORDINARY_MAP_STARTING_LINE_NUMBER (line_map_ordinary *ord_map)
376-
{
377-
return ord_map->to_line;
378-
}
379-
380362
/* Get the index of the ordinary map at whose end
381363
ordinary map MAP was included.
382364
@@ -388,14 +370,6 @@ ORDINARY_MAP_INCLUDER_FILE_INDEX (const line_map_ordinary *ord_map)
388370
return ord_map->included_from;
389371
}
390372

391-
/* As above, but by reference (e.g. as an lvalue). */
392-
393-
inline int&
394-
ORDINARY_MAP_INCLUDER_FILE_INDEX (line_map_ordinary *ord_map)
395-
{
396-
return ord_map->included_from;
397-
}
398-
399373
/* Return a positive value if map encodes locations from a system
400374
header, 0 otherwise. Returns 1 if ordinary map MAP encodes locations
401375
in a system header and 2 if it encodes locations in a C system header
@@ -407,14 +381,6 @@ ORDINARY_MAP_IN_SYSTEM_HEADER_P (const line_map_ordinary *ord_map)
407381
return ord_map->sysp;
408382
}
409383

410-
/* As above, but by reference (e.g. as an lvalue). */
411-
412-
inline unsigned char &
413-
ORDINARY_MAP_IN_SYSTEM_HEADER_P (line_map_ordinary *ord_map)
414-
{
415-
return ord_map->sysp;
416-
}
417-
418384
/* Get the number of the low-order source_location bits used for a
419385
column number within ordinary map MAP. */
420386

@@ -424,16 +390,6 @@ ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (const line_map_ordinary *ord_map)
424390
return ord_map->column_bits;
425391
}
426392

427-
/* Set the number of the low-order source_location bits used for a
428-
column number within ordinary map MAP. */
429-
430-
inline void
431-
SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (line_map_ordinary *ord_map,
432-
int col_bits)
433-
{
434-
ord_map->column_bits = col_bits;
435-
}
436-
437393
/* Get the filename of ordinary map MAP. */
438394

439395
inline const char *
@@ -442,14 +398,6 @@ ORDINARY_MAP_FILE_NAME (const line_map_ordinary *ord_map)
442398
return ord_map->to_file;
443399
}
444400

445-
/* As above, but by reference (e.g. as an lvalue). */
446-
447-
inline const char * &
448-
ORDINARY_MAP_FILE_NAME (line_map_ordinary *ord_map)
449-
{
450-
return ord_map->to_file;
451-
}
452-
453401
/* Get the cpp macro whose expansion gave birth to macro map MAP. */
454402

455403
inline cpp_hashnode *
@@ -458,14 +406,6 @@ MACRO_MAP_MACRO (const line_map_macro *macro_map)
458406
return macro_map->macro;
459407
}
460408

461-
/* As above, but by reference (e.g. as an lvalue). */
462-
463-
inline cpp_hashnode * &
464-
MACRO_MAP_MACRO (line_map_macro *macro_map)
465-
{
466-
return macro_map->macro;
467-
}
468-
469409
/* Get the number of tokens inside the replacement-list of the macro
470410
that led to macro map MAP. */
471411

@@ -475,14 +415,6 @@ MACRO_MAP_NUM_MACRO_TOKENS (const line_map_macro *macro_map)
475415
return macro_map->n_tokens;
476416
}
477417

478-
/* As above, but by reference (e.g. as an lvalue). */
479-
480-
inline unsigned int &
481-
MACRO_MAP_NUM_MACRO_TOKENS (line_map_macro *macro_map)
482-
{
483-
return macro_map->n_tokens;
484-
}
485-
486418
/* Get the array of pairs of locations within macro map MAP.
487419
See the declaration of line_map_macro for more information. */
488420

@@ -492,14 +424,6 @@ MACRO_MAP_LOCATIONS (const line_map_macro *macro_map)
492424
return macro_map->macro_locations;
493425
}
494426

495-
/* As above, but by reference (e.g. as an lvalue). */
496-
497-
inline source_location * &
498-
MACRO_MAP_LOCATIONS (line_map_macro *macro_map)
499-
{
500-
return macro_map->macro_locations;
501-
}
502-
503427
/* Get the location of the expansion point of the macro map MAP. */
504428

505429
inline source_location
@@ -508,14 +432,6 @@ MACRO_MAP_EXPANSION_POINT_LOCATION (const line_map_macro *macro_map)
508432
return macro_map->expansion;
509433
}
510434

511-
/* As above, but by reference (e.g. as an lvalue). */
512-
513-
inline source_location &
514-
MACRO_MAP_EXPANSION_POINT_LOCATION (line_map_macro *macro_map)
515-
{
516-
return macro_map->expansion;
517-
}
518-
519435
/* The abstraction of a set of location maps. There can be several
520436
types of location maps. This abstraction contains the attributes
521437
that are independent from the type of the map.

‎libcpp/line-map.c

+14-15
Original file line numberDiff line numberDiff line change
@@ -381,31 +381,30 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
381381
}
382382
}
383383

384-
ORDINARY_MAP_IN_SYSTEM_HEADER_P (map) = sysp;
385-
MAP_START_LOCATION (map) = start_location;
386-
ORDINARY_MAP_FILE_NAME (map) = to_file;
387-
ORDINARY_MAP_STARTING_LINE_NUMBER (map) = to_line;
384+
map->sysp = sysp;
385+
map->start_location = start_location;
386+
map->to_file = to_file;
387+
map->to_line = to_line;
388388
LINEMAPS_ORDINARY_CACHE (set) = LINEMAPS_ORDINARY_USED (set) - 1;
389-
SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map, 0);
389+
map->column_bits = 0;
390390
set->highest_location = start_location;
391391
set->highest_line = start_location;
392392
set->max_column_hint = 0;
393393

394394
if (reason == LC_ENTER)
395395
{
396-
ORDINARY_MAP_INCLUDER_FILE_INDEX (map) =
396+
map->included_from =
397397
set->depth == 0 ? -1 : (int) (LINEMAPS_ORDINARY_USED (set) - 2);
398398
set->depth++;
399399
if (set->trace_includes)
400400
trace_include (set, map);
401401
}
402402
else if (reason == LC_RENAME)
403-
ORDINARY_MAP_INCLUDER_FILE_INDEX (map) =
404-
ORDINARY_MAP_INCLUDER_FILE_INDEX (&map[-1]);
403+
map->included_from = ORDINARY_MAP_INCLUDER_FILE_INDEX (&map[-1]);
405404
else if (reason == LC_LEAVE)
406405
{
407406
set->depth--;
408-
ORDINARY_MAP_INCLUDER_FILE_INDEX (map) =
407+
map->included_from =
409408
ORDINARY_MAP_INCLUDER_FILE_INDEX (INCLUDED_FROM (set, map - 1));
410409
}
411410

@@ -464,14 +463,14 @@ linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node,
464463

465464
map = linemap_check_macro (new_linemap (set, LC_ENTER_MACRO));
466465

467-
MAP_START_LOCATION (map) = start_location;
468-
MACRO_MAP_MACRO (map) = macro_node;
469-
MACRO_MAP_NUM_MACRO_TOKENS (map) = num_tokens;
470-
MACRO_MAP_LOCATIONS (map)
466+
map->start_location = start_location;
467+
map->macro = macro_node;
468+
map->n_tokens = num_tokens;
469+
map->macro_locations
471470
= (source_location*) reallocator (NULL,
472471
2 * num_tokens
473472
* sizeof (source_location));
474-
MACRO_MAP_EXPANSION_POINT_LOCATION (map) = expansion;
473+
map->expansion = expansion;
475474
memset (MACRO_MAP_LOCATIONS (map), 0,
476475
num_tokens * sizeof (source_location));
477476

@@ -580,7 +579,7 @@ linemap_line_start (struct line_maps *set, linenum_type to_line,
580579
ORDINARY_MAP_IN_SYSTEM_HEADER_P (map),
581580
ORDINARY_MAP_FILE_NAME (map),
582581
to_line)));
583-
SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map, column_bits);
582+
map->column_bits = column_bits;
584583
r = (MAP_START_LOCATION (map)
585584
+ ((to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
586585
<< column_bits));

0 commit comments

Comments
 (0)
Please sign in to comment.