From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id B013F385700A for ; Wed, 5 Apr 2023 14:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B013F385700A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x329.google.com with SMTP id j18-20020a05600c1c1200b003ee5157346cso23815089wms.1 for ; Wed, 05 Apr 2023 07:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703534; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=51PEspkDcmiXoo4pzo1UuUsXRaxb+ly/OpVFXeCOfn8=; b=BEbFgVbNg7SyYWhZDQONk40y72NHMxAgXMbsm7W527X5bsGpD6OOCilrDGrwnsYjRP QpO+yLPlOchBs2c08eCY001XujtFpwDmXGs+e5I3BcrF2jCYz0g7FBfYJFaJvel1+lDW GzQ2v4JXE/CDAM4/B0qTBmB1lssOo6R8ZW7rvTjeLu0TkwzmAXN8yPSIjiVx5CEkjtBj LYPb0a31Mr0qBAs/7+R5nMuthcXXTjUSEXO+o70hebv3ZTRCrIjRuPMqpdkNvMGukwVb jgdEp/j3MI9FMTPXjj3LQTUdK2ZF9YrEkgbxX1yRssxDTtemXReRx8NRhoBKh1xFnevU eZJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703534; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=51PEspkDcmiXoo4pzo1UuUsXRaxb+ly/OpVFXeCOfn8=; b=QguFP7XLAHiOuLDsZpAfttiTp1DvnmS5cxLTlE8ZcQWxJCkPnx8t2LhGqEx1KMWCXF DR+F461FrWwEoH7ttbXRJ8A+y6aWHaeK35M6hD687lDdSvawKBOwJDh7rjHUXaIxmGV7 FmxKpj1RyO7lSyb66OzpDVurOIjGZQczdaTDR4WNRc1wOpSXsVfhqsv3+DyNRdGsgtbx L4sXTM82dAa3uibGgKTIcqtN/VvsA2MfkGelqkuqVaMPJLU0oxcAQ2mgU/HdyxjUfpNx f7facv7rQiG+D4By81ma62iTcgZhTmRJDFyUD9ebO+jU2sOXBHHIW7CeXILhytojtJr8 g3fA== X-Gm-Message-State: AAQBX9dMsQ1Al3xPquT12pmTZRI1qyN4dVaEX1q9XukxTs/KvEyOLlpo /Kr31nLoY4EufcmNj9JCpZYR X-Google-Smtp-Source: AKy350b7QtVaOZWbqxpomO0QGnashs8ErubH0pCvgT4GuSpYTpfrUzh8GphZUxxKRVyZ47/oWaQ/Uw== X-Received: by 2002:a7b:c85a:0:b0:3ef:7594:48cc with SMTP id c26-20020a7bc85a000000b003ef759448ccmr4803354wml.23.1680703534429; Wed, 05 Apr 2023 07:05:34 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:05:33 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, mxlol233 Subject: [committed 09/88] gccrs: Add get_locus function for abstract class MetaItemInner. Date: Wed, 5 Apr 2023 16:02:53 +0200 Message-Id: <20230405140411.3016563-10-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com> References: <20230405140411.3016563-1-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: mxlol233 This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print diagnostics on some sub-classes of MetaItemInner. gcc/rust/ChangeLog: * ast/rust-ast.h: Add get_locus method. * ast/rust-expr.h: Likewise. * ast/rust-macro.h: Likewise. Signed-off-by: Xiao Ma --- gcc/rust/ast/rust-ast.h | 2 ++ gcc/rust/ast/rust-expr.h | 8 ++++++++ gcc/rust/ast/rust-macro.h | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 5f18233eb0f..d30e6d494f2 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -630,6 +630,8 @@ public: virtual ~MetaItemInner (); + virtual Location get_locus () const = 0; + virtual std::string as_string () const = 0; virtual void accept_vis (ASTVisitor &vis) = 0; diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index c58fae5e564..34bc6993ab6 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -150,6 +150,8 @@ public: std::string as_string () const override { return lit_expr.as_string (); } + Location get_locus () const override { return lit_expr.get_locus (); } + void accept_vis (ASTVisitor &vis) override; bool check_cfg_predicate (const Session &session) const override; @@ -178,6 +180,12 @@ public: return path.as_string () + " = " + lit.as_string (); } + // There are two Locations in MetaItemPathLit (path and lit_expr), + // we have no idea use which of them, just simply return UNKNOWN_LOCATION + // now. + // Maybe we will figure out when we really need the location in the future. + Location get_locus () const override { return Location (UNKNOWN_LOCATION); } + void accept_vis (ASTVisitor &vis) override; bool check_cfg_predicate (const Session &session) const override; diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index bff8c7ac6fb..4226c6919ff 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -725,6 +725,8 @@ public: return path; } + Location get_locus () const override { return path.get_locus (); } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -778,6 +780,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return path.get_locus (); } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -805,6 +809,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -847,6 +853,8 @@ public: return std::unique_ptr (clone_meta_item_inner_impl ()); } + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -885,6 +893,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -919,6 +929,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; -- 2.40.0