From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110809 invoked by alias); 5 May 2015 18:08:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 110687 invoked by uid 89); 5 May 2015 18:08:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 05 May 2015 18:08:11 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t45I89KM031321 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 5 May 2015 14:08:09 -0400 Received: from c64.redhat.com (vpn-225-80.phx2.redhat.com [10.3.225.80]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t45I86ld012150; Tue, 5 May 2015 14:08:08 -0400 From: David Malcolm To: Jeff Law Cc: gcc-patches@gcc.gnu.org, David Malcolm Subject: [PATCH 5/4] libcpp: Eliminate most of the non-const/reference-returning inline fns Date: Tue, 05 May 2015 18:08:00 -0000 Message-Id: <1430850074-40522-4-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1430850074-40522-1-git-send-email-dmalcolm@redhat.com> References: <5547C538.5000606@redhat.com> <1430850074-40522-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00361.txt.bz2 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. --- gcc/java/jcf-parse.c | 2 +- libcpp/include/line-map.h | 86 +---------------------------------------------- libcpp/line-map.c | 29 ++++++++-------- 3 files changed, 16 insertions(+), 101 deletions(-) diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index e609331..d1c9fc4 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -374,7 +374,7 @@ set_source_filename (JCF *jcf, int index) } sfname = find_sourcefile (sfname); - ORDINARY_MAP_FILE_NAME (LINEMAPS_LAST_ORDINARY_MAP (line_table)) = sfname; + LINEMAPS_LAST_ORDINARY_MAP (line_table)->to_file = sfname; if (current_class == main_class) main_input_filename = sfname; } diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 95a1d85..0530072 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -343,7 +343,7 @@ linemap_check_macro (const line_map *map) return (const line_map_macro *)map; } -/* Read the start location of MAP, as an rvalue. */ +/* Read the start location of MAP. */ inline source_location MAP_START_LOCATION (const line_map *map) @@ -351,15 +351,6 @@ MAP_START_LOCATION (const line_map *map) return map->start_location; } -/* Access the start location of MAP as a reference - (e.g. as an lvalue). */ - -inline source_location& -MAP_START_LOCATION (line_map *map) -{ - return map->start_location; -} - /* Get the starting line number of ordinary map MAP. */ inline linenum_type @@ -368,15 +359,6 @@ ORDINARY_MAP_STARTING_LINE_NUMBER (const line_map_ordinary *ord_map) return ord_map->to_line; } -/* Access the starting line number of ordinary map MAP by - reference (e.g. as an lvalue). */ - -inline linenum_type& -ORDINARY_MAP_STARTING_LINE_NUMBER (line_map_ordinary *ord_map) -{ - return ord_map->to_line; -} - /* Get the index of the ordinary map at whose end ordinary map MAP was included. @@ -388,14 +370,6 @@ ORDINARY_MAP_INCLUDER_FILE_INDEX (const line_map_ordinary *ord_map) return ord_map->included_from; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline int& -ORDINARY_MAP_INCLUDER_FILE_INDEX (line_map_ordinary *ord_map) -{ - return ord_map->included_from; -} - /* Return a positive value if map encodes locations from a system header, 0 otherwise. Returns 1 if ordinary map MAP encodes locations 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) return ord_map->sysp; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline unsigned char & -ORDINARY_MAP_IN_SYSTEM_HEADER_P (line_map_ordinary *ord_map) -{ - return ord_map->sysp; -} - /* Get the number of the low-order source_location bits used for a column number within ordinary map MAP. */ @@ -424,16 +390,6 @@ ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (const line_map_ordinary *ord_map) return ord_map->column_bits; } -/* Set the number of the low-order source_location bits used for a - column number within ordinary map MAP. */ - -inline void -SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (line_map_ordinary *ord_map, - int col_bits) -{ - ord_map->column_bits = col_bits; -} - /* Get the filename of ordinary map MAP. */ inline const char * @@ -442,14 +398,6 @@ ORDINARY_MAP_FILE_NAME (const line_map_ordinary *ord_map) return ord_map->to_file; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline const char * & -ORDINARY_MAP_FILE_NAME (line_map_ordinary *ord_map) -{ - return ord_map->to_file; -} - /* Get the cpp macro whose expansion gave birth to macro map MAP. */ inline cpp_hashnode * @@ -458,14 +406,6 @@ MACRO_MAP_MACRO (const line_map_macro *macro_map) return macro_map->macro; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline cpp_hashnode * & -MACRO_MAP_MACRO (line_map_macro *macro_map) -{ - return macro_map->macro; -} - /* Get the number of tokens inside the replacement-list of the macro that led to macro map MAP. */ @@ -475,14 +415,6 @@ MACRO_MAP_NUM_MACRO_TOKENS (const line_map_macro *macro_map) return macro_map->n_tokens; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline unsigned int & -MACRO_MAP_NUM_MACRO_TOKENS (line_map_macro *macro_map) -{ - return macro_map->n_tokens; -} - /* Get the array of pairs of locations within macro map MAP. See the declaration of line_map_macro for more information. */ @@ -492,14 +424,6 @@ MACRO_MAP_LOCATIONS (const line_map_macro *macro_map) return macro_map->macro_locations; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline source_location * & -MACRO_MAP_LOCATIONS (line_map_macro *macro_map) -{ - return macro_map->macro_locations; -} - /* Get the location of the expansion point of the macro map MAP. */ inline source_location @@ -508,14 +432,6 @@ MACRO_MAP_EXPANSION_POINT_LOCATION (const line_map_macro *macro_map) return macro_map->expansion; } -/* As above, but by reference (e.g. as an lvalue). */ - -inline source_location & -MACRO_MAP_EXPANSION_POINT_LOCATION (line_map_macro *macro_map) -{ - return macro_map->expansion; -} - /* The abstraction of a set of location maps. There can be several types of location maps. This abstraction contains the attributes that are independent from the type of the map. diff --git a/libcpp/line-map.c b/libcpp/line-map.c index e262df4..a5e45e4 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -381,31 +381,30 @@ linemap_add (struct line_maps *set, enum lc_reason reason, } } - ORDINARY_MAP_IN_SYSTEM_HEADER_P (map) = sysp; - MAP_START_LOCATION (map) = start_location; - ORDINARY_MAP_FILE_NAME (map) = to_file; - ORDINARY_MAP_STARTING_LINE_NUMBER (map) = to_line; + map->sysp = sysp; + map->start_location = start_location; + map->to_file = to_file; + map->to_line = to_line; LINEMAPS_ORDINARY_CACHE (set) = LINEMAPS_ORDINARY_USED (set) - 1; - SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map, 0); + map->column_bits = 0; set->highest_location = start_location; set->highest_line = start_location; set->max_column_hint = 0; if (reason == LC_ENTER) { - ORDINARY_MAP_INCLUDER_FILE_INDEX (map) = + map->included_from = set->depth == 0 ? -1 : (int) (LINEMAPS_ORDINARY_USED (set) - 2); set->depth++; if (set->trace_includes) trace_include (set, map); } else if (reason == LC_RENAME) - ORDINARY_MAP_INCLUDER_FILE_INDEX (map) = - ORDINARY_MAP_INCLUDER_FILE_INDEX (&map[-1]); + map->included_from = ORDINARY_MAP_INCLUDER_FILE_INDEX (&map[-1]); else if (reason == LC_LEAVE) { set->depth--; - ORDINARY_MAP_INCLUDER_FILE_INDEX (map) = + map->included_from = ORDINARY_MAP_INCLUDER_FILE_INDEX (INCLUDED_FROM (set, map - 1)); } @@ -464,14 +463,14 @@ linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node, map = linemap_check_macro (new_linemap (set, LC_ENTER_MACRO)); - MAP_START_LOCATION (map) = start_location; - MACRO_MAP_MACRO (map) = macro_node; - MACRO_MAP_NUM_MACRO_TOKENS (map) = num_tokens; - MACRO_MAP_LOCATIONS (map) + map->start_location = start_location; + map->macro = macro_node; + map->n_tokens = num_tokens; + map->macro_locations = (source_location*) reallocator (NULL, 2 * num_tokens * sizeof (source_location)); - MACRO_MAP_EXPANSION_POINT_LOCATION (map) = expansion; + map->expansion = expansion; memset (MACRO_MAP_LOCATIONS (map), 0, num_tokens * sizeof (source_location)); @@ -580,7 +579,7 @@ linemap_line_start (struct line_maps *set, linenum_type to_line, ORDINARY_MAP_IN_SYSTEM_HEADER_P (map), ORDINARY_MAP_FILE_NAME (map), to_line))); - SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map, column_bits); + map->column_bits = column_bits; r = (MAP_START_LOCATION (map) + ((to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map)) << column_bits)); -- 1.8.5.3