From patchwork Tue Oct 31 21:15:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 160350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp27345vqx; Tue, 31 Oct 2023 14:16:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLjtSbcukK9vofO8r8kQ4Z2MdQZkLzeE9P8laXNkNPlTiF98EF/xbCresPih1l9l3Y3lUG X-Received: by 2002:a05:620a:2448:b0:779:e352:6db9 with SMTP id h8-20020a05620a244800b00779e3526db9mr16415675qkn.30.1698787013213; Tue, 31 Oct 2023 14:16:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698787013; cv=pass; d=google.com; s=arc-20160816; b=tg4TJGewNltkFw7fO0r5XG/oCrjGv3qWkRxf0sWpu4/MZHtmsG8rsKJqcq+SzYoS83 pLRWUvq/CjklRx7jPRw32ScplFxNTphDoAcNJAgCnKJqW6OpEI2h1/7N6RGBAlDU4Waw wsIEqfqNqq4ANvA1gbVuMmYUIltKsFTLGKLB1SWqQ34l4jjkX2cTH0WtJFTnETWRDMFl 6qef47lonCth8HW3gf8XbbPz1rlZ0tRNSJKzpHEUTkQ/vgDfB9IYL78FevOKdZG/PIVN MSAd/5irjloTNUhYrVtZcKpJQjgT3FwzF+BQf4AikVRXJFQACwgZze6fdl83SOsBS7/B 9y5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=SvgCGSzcndPDkhTHigX9+JND7uac6MIBx7wnVZFvEKs=; fh=NXemEfxTRbZtBxUkxR2ehQUaYlcDfMdzPkO8MChVQE4=; b=WwsN4XZI6fBEmkVaVdTsT3w7ZXKDMpyQrJ6iKB2UnqW+Q3Agr2wR+yGImiPvtQBGMi QIPGcr6msW1dazKMD7C6qVNE+2MU/LAu+wYQS6TpIJT64J41AptDs84J5qrWHe24+wt3 aM1mRnX4t4JucQOmIx9B3iRX7DueCY1433xpACh30mVzVgseZHdn+WADgaIqITi0Dtcj /ostLJsSWXhV4VitQ3vw7Qh0etamJdRfzID6J7FO3uA0tXNIX/Vimk7yCmqGYrRnboEf /RJPw4ou4TJAHw3w2uO+Luzj1Evj/Nt93cIJYMjCRUvR8MMl1RFnfMwN2pfz/jlaHop+ +DdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZGUZrIXX; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m8-20020a05620a24c800b0077419a1ea24si1958062qkn.579.2023.10.31.14.16.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 14:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZGUZrIXX; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1A0C3857B93 for ; Tue, 31 Oct 2023 21:16:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 51B0B3858C52 for ; Tue, 31 Oct 2023 21:16:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 51B0B3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 51B0B3858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698786966; cv=none; b=YShSRR5tp8BuVFF6b0aLLzxp4ftKOGpqPZVD0bQV4YdZRH2sa3Yk0wXHz+Uzfa4WsrjQ3mKYZDv378o8y+i09C0qlnU8LnT7aY4ov10c5Tsmr5VECGUnvLEMCdweHcqEyL9NBftT5pRnrdUpxu3PPagPmOWC2HQzYA44CmDfIGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698786966; c=relaxed/simple; bh=2TwlA8KkMGoud/fpGTIG9Z6RCbmWP0Ju/bnwwSUMWxw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=U5V+w5D2hgnh5v9lLLrW1jzLQndTRdSOV9owg9yTorTA0Xurlwpl96SxjGkAoydx99piY4Wqpc6dMbaI0Fo3tiY5YAlQCGopFOhmT1nq8iztOWPu1bQVULiwpES+Ef1HaY2K+kWaCReC50S2QcfDYiYGCsTk04kC834D+BdQV6k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698786963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SvgCGSzcndPDkhTHigX9+JND7uac6MIBx7wnVZFvEKs=; b=ZGUZrIXXnmnZVJn4kWurzT4DO58B4RK3i8ANSLd0mIqI40M5iuyoUujKZ6d7FYcmIUlexl 6NvADZ0gLObkRIzQB+g9o9Xzok5NJdALQjrjNL+iefJQVNep4Tro2O9j2eKjfLMMijkAiv v8C/YeksjCuR9naEAnCkxhdgzCsuUOQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-GO17I3mLOAm4FuRgsr5wTA-1; Tue, 31 Oct 2023 17:16:02 -0400 X-MC-Unique: GO17I3mLOAm4FuRgsr5wTA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE94F185A781 for ; Tue, 31 Oct 2023 21:16:01 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.8.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A58122026D4C; Tue, 31 Oct 2023 21:16:01 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] libcpp: eliminate MACRO_MAP_EXPANSION_POINT_LOCATION Date: Tue, 31 Oct 2023 17:15:59 -0400 Message-Id: <20231031211559.1907917-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781307291329991044 X-GMAIL-MSGID: 1781307291329991044 This patch eliminates the function "MACRO_MAP_EXPANSION_POINT_LOCATION" (which hasn't been a macro since r6-739-g0501dbd932a7e9) in favor of a new line_map_macro::get_expansion_point_location accessor. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5049-gb0f19336f247c6. gcc/c-family/ChangeLog: * c-warn.cc (warn_for_multistatement_macros): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. gcc/cp/ChangeLog: * module.cc (ordinary_loc_of): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. (module_state::note_location): Update for renaming of field. (module_state::write_macro_maps): Likewise. gcc/ChangeLog: * input.cc (dump_location_info): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. * tree-diagnostic.cc (maybe_unwind_expanded_macro_loc): Likewise. libcpp/ChangeLog: * include/line-map.h (line_map_macro::get_expansion_point_location): New accessor. (line_map_macro::expansion): Rename field to... (line_map_macro::mexpansion): Rename field to... (MACRO_MAP_EXPANSION_POINT_LOCATION): Delete this function. * line-map.cc (linemap_enter_macro): Update for renaming of field. (linemap_macro_map_loc_to_exp_point): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. --- gcc/c-family/c-warn.cc | 2 +- gcc/cp/module.cc | 6 +++--- gcc/input.cc | 4 ++-- gcc/tree-diagnostic.cc | 2 +- libcpp/include/line-map.h | 19 ++++++++++--------- libcpp/line-map.cc | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index 9ab83a9a84a..bc889cee6b9 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -2951,7 +2951,7 @@ warn_for_multistatement_macros (location_t body_loc, location_t next_loc, while (linemap_macro_expansion_map_p (guard_map)) { const line_map_macro *mm = linemap_check_macro (guard_map); - guard_loc_exp = MACRO_MAP_EXPANSION_POINT_LOCATION (mm); + guard_loc_exp = mm->get_expansion_point_location (); guard_map = linemap_lookup (line_table, guard_loc_exp); if (guard_map == body_map) return; diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 539518d7923..c1c8c226bc1 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13937,7 +13937,7 @@ ordinary_loc_of (line_maps *lmaps, location_t from) /* Find the ordinary location nearest FROM. */ const line_map *map = linemap_lookup (lmaps, from); const line_map_macro *mac_map = linemap_check_macro (map); - from = MACRO_MAP_EXPANSION_POINT_LOCATION (mac_map); + from = mac_map->get_expansion_point_location (); } } return from; @@ -15779,7 +15779,7 @@ module_state::note_location (location_t loc) slot->remap = 0; // Expansion locations could themselves be from a // macro, we need to note them all. - note_location (mac_map->expansion); + note_location (mac_map->m_expansion); gcc_checking_assert (mac_map->n_tokens); location_t tloc = UNKNOWN_LOCATION; for (unsigned ix = mac_map->n_tokens * 2; ix--;) @@ -16375,7 +16375,7 @@ module_state::write_macro_maps (elf_out *to, range_t &info, unsigned *crc_p) sec.u (iter->remap); sec.u (mac->n_tokens); sec.cpp_node (mac->macro); - write_location (sec, mac->expansion); + write_location (sec, mac->m_expansion); const location_t *locs = mac->macro_locations; /* There are lots of identical runs. */ location_t prev = UNKNOWN_LOCATION; diff --git a/gcc/input.cc b/gcc/input.cc index fd09fccb0e3..6256d81f531 100644 --- a/gcc/input.cc +++ b/gcc/input.cc @@ -1530,9 +1530,9 @@ dump_location_info (FILE *stream) map->start_location, (map->start_location + MACRO_MAP_NUM_MACRO_TOKENS (map))); - inform (MACRO_MAP_EXPANSION_POINT_LOCATION (map), + inform (map->get_expansion_point_location (), "expansion point is location %i", - MACRO_MAP_EXPANSION_POINT_LOCATION (map)); + map->get_expansion_point_location ()); fprintf (stream, " map->start_location: %u\n", map->start_location); diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index a600f0e9f64..cae400cf372 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -217,7 +217,7 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context, This is the locus 2/ of the earlier comment. */ location_t resolved_exp_loc = linemap_resolve_location (line_table, - MACRO_MAP_EXPANSION_POINT_LOCATION (iter->map), + iter->map->get_expansion_point_location (), LRK_MACRO_DEFINITION_LOCATION, NULL); diagnostic_append_note (context, resolved_exp_loc, diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index cb934e6b9b3..635d6d3077c 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -461,6 +461,15 @@ struct cpp_hashnode; The offset from START_LOCATION is used to index into MACRO_LOCATIONS; this holds the original location of the token. */ struct GTY((tag ("2"))) line_map_macro : public line_map { + + /* Get the location of the expansion point of this macro map. */ + + location_t + get_expansion_point_location () const + { + return m_expansion; + } + /* Base is 4 bytes. */ /* The number of tokens inside the replacement-list of MACRO. */ @@ -535,7 +544,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { by the map that was current right before the current one. It could have been either a macro or an ordinary map, depending on if we are in a nested expansion context not. */ - location_t expansion; + location_t m_expansion; /* Size is 20 or 32 (4 bytes padding on 64-bit). */ }; @@ -705,14 +714,6 @@ MACRO_MAP_LOCATIONS (const line_map_macro *macro_map) return macro_map->macro_locations; } -/* Get the location of the expansion point of the macro map MAP. */ - -inline location_t -MACRO_MAP_EXPANSION_POINT_LOCATION (const 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.cc b/libcpp/line-map.cc index cd173530149..cc9e14aa61e 100644 --- a/libcpp/line-map.cc +++ b/libcpp/line-map.cc @@ -782,7 +782,7 @@ linemap_enter_macro (class line_maps *set, struct cpp_hashnode *macro_node, map->macro_locations = (location_t*) set->m_reallocator (nullptr, 2 * num_tokens * sizeof (location_t)); - map->expansion = expansion; + map->m_expansion = expansion; memset (MACRO_MAP_LOCATIONS (map), 0, 2 * num_tokens * sizeof (location_t)); @@ -1225,7 +1225,7 @@ linemap_macro_map_loc_to_exp_point (const line_map_macro *map, linemap_assert ((location - MAP_START_LOCATION (map)) < MACRO_MAP_NUM_MACRO_TOKENS (map)); - return MACRO_MAP_EXPANSION_POINT_LOCATION (map); + return map->get_expansion_point_location (); } /* LOCATION is the source location of a token that belongs to a macro