From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id D2FF03846917 for ; Tue, 21 Feb 2023 12:04:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2FF03846917 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-wr1-x436.google.com with SMTP id v3so4085990wrp.2 for ; Tue, 21 Feb 2023 04:04:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; 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=LoBWNt2H423ffTCV+quVu51FTvLZC+vkHJ/9OLOj3J4=; b=T7WIADggMD+SNs+g/HkviHoWfwGcLJ1bV0NvB+GFHElmj4sm3haYYdwRYSmVBiw1o+ gIFE+t21xCJaFwLVnZspydpGZuzESNXQjkhMBNroexas4Vyjaun7aU4WdlMRI8je/Gdk BWXpyX0bS573ECIhtg3AxF5EYwUhqA9jEE5qzgPjcmnBvxY5hdPPAJXJKeIzkum4DeHF FfXNd/rDXxewX4eA0KFZP6CTCG0XVEBHegqXGPVmtsdJFrC5HOWROpCnaGonTLUturmf wf0IzECS11NpjiTfsbstxB3g7wesYhiFtJ4pY+M8IUPO5JUQybP0V+U9rbJbGGJY/bCd Cz0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LoBWNt2H423ffTCV+quVu51FTvLZC+vkHJ/9OLOj3J4=; b=e99nENiZR9oiC/wkrNZmTnlZ8MHmM4d0r7dLk3O/fCRWzwPosqAmcmbjG6vHy932dN EUg1SSo/3+KgXRzpeiENKF3QCWkbM01zn83dljWfUYPuQVu7u823MOq5sRo01PQg1dC+ rNbnFUmzqATcctXKbs33ZYTM4G0cQMUm2Ij2+XP2riOEd5tytYHrYYIhqSBxWW3qBv9v FqDwZvvnzMcxest/hayEv1rLN6EfwGestw+tFj2PfzGciZifB/PZvrjJN0P8KlOMO3K9 3cYJhSTR8JDUOGPvMsFIqu/81DGVZDYXxzVUXIQOJyzYIkdrFEajfP3COEDcXEC6Tn2H nBcA== X-Gm-Message-State: AO0yUKUDjZMAXT3Csf9uu/QnxxY+BbrHqwOeqCsWbm3X5GQ/AeUfm56D cBD1JwDvePhxpOZtTB/GcyXM X-Google-Smtp-Source: AK7set/wWX4olFtlnkHic4E3r/grSi6z2QLA0zrgYs+wDeli5J96PD3+lQmwEoM18OiTA7yesTCUHA== X-Received: by 2002:a5d:6501:0:b0:2c5:5701:8d03 with SMTP id x1-20020a5d6501000000b002c557018d03mr4270174wru.13.1676981061421; Tue, 21 Feb 2023 04:04:21 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:20 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Dave Subject: [committed 070/103] gccrs: add Location to AST::Visibility Date: Tue, 21 Feb 2023 13:02:00 +0100 Message-Id: <20230221120230.596966-71-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-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.8 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=ham 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: Dave gcc/rust/ChangeLog: * ast/rust-item.h: Add location member. * hir/rust-ast-lower.cc (translate_visibility): Pass location argument. * hir/tree/rust-hir-item.h: Fix constructor to accept Location argument. --- gcc/rust/ast/rust-item.h | 19 +++++++++++++------ gcc/rust/hir/rust-ast-lower.cc | 3 ++- gcc/rust/hir/tree/rust-hir-item.h | 6 ++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index d66dd615319..17d11e4de38 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -625,13 +625,15 @@ private: VisType vis_type; // Only assigned if vis_type is IN_PATH SimplePath in_path; + Location locus; // should this store location info? public: // Creates a Visibility - TODO make constructor protected or private? - Visibility (VisType vis_type, SimplePath in_path) - : vis_type (vis_type), in_path (std::move (in_path)) + Visibility (VisType vis_type, SimplePath in_path, + Location locus = Location ()) + : vis_type (vis_type), in_path (std::move (in_path)), locus (locus) {} VisType get_vis_type () const { return vis_type; } @@ -648,6 +650,8 @@ public: // Returns whether visibility is public or not. bool is_public () const { return vis_type != PRIV && !is_error (); } + Location get_locus () const { return locus; } + // Creates an error visibility. static Visibility create_error () { @@ -672,21 +676,24 @@ public: static Visibility create_crate (Location crate_tok_location) { return Visibility (PUB_CRATE, - SimplePath::from_str ("crate", crate_tok_location)); + SimplePath::from_str ("crate", crate_tok_location), + crate_tok_location); } // Creates a public visibility with self-relative paths static Visibility create_self (Location self_tok_location) { return Visibility (PUB_SELF, - SimplePath::from_str ("self", self_tok_location)); + SimplePath::from_str ("self", self_tok_location), + self_tok_location); } // Creates a public visibility with parent module-relative paths static Visibility create_super (Location super_tok_location) { return Visibility (PUB_SUPER, - SimplePath::from_str ("super", super_tok_location)); + SimplePath::from_str ("super", super_tok_location), + super_tok_location); } // Creates a private visibility @@ -698,7 +705,7 @@ public: // Creates a public visibility with a given path or whatever. static Visibility create_in_path (SimplePath in_path) { - return Visibility (PUB_IN_PATH, std::move (in_path)); + return Visibility (PUB_IN_PATH, std::move (in_path), in_path.get_locus ()); } std::string as_string () const; diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index fdf8abe3ed3..2e25be75a5a 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -50,7 +50,8 @@ translate_visibility (const AST::Visibility &vis) case AST::Visibility::PUB_SUPER: case AST::Visibility::PUB_IN_PATH: return Visibility (Visibility::VisType::RESTRICTED, - ASTLoweringSimplePath::translate (vis.get_path ())); + ASTLoweringSimplePath::translate (vis.get_path ()), + vis.get_locus ()); break; } diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 7f665159572..f7bf1f879c8 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -571,13 +571,15 @@ public: private: VisType vis_type; HIR::SimplePath path; + Location locus; // should this store location info? public: Visibility (VisType vis_type, - HIR::SimplePath path = HIR::SimplePath::create_empty ()) - : vis_type (vis_type), path (std::move (path)) + HIR::SimplePath path = HIR::SimplePath::create_empty (), + Location locus = Location ()) + : vis_type (vis_type), path (std::move (path)), locus (locus) {} // Returns whether visibility is in an error state. -- 2.39.1