From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 613FF381A7F7; Wed, 8 Jun 2022 12:39:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 613FF381A7F7 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] ast: Add location info to MetaWord X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 34c73a75cf0043d3b9bb222c1c506aae18f27195 X-Git-Newrev: ffb38df2eb370eacdf35f6273d6c450eb4940a21 Message-Id: <20220608123924.613FF381A7F7@sourceware.org> Date: Wed, 8 Jun 2022 12:39:24 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 12:39:24 -0000 https://gcc.gnu.org/g:ffb38df2eb370eacdf35f6273d6c450eb4940a21 commit ffb38df2eb370eacdf35f6273d6c450eb4940a21 Author: Arthur Cohen Date: Thu Apr 28 10:05:55 2022 +0200 ast: Add location info to MetaWord Diff: --- gcc/rust/ast/rust-ast-full-test.cc | 5 ++--- gcc/rust/ast/rust-macro.h | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index 5c8e04fcbbc..f15a1913717 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -4125,7 +4125,7 @@ AttributeParser::parse_meta_item_inner () skip_token (); // FIXME: We probably need a Location here as well return std::unique_ptr ( - new MetaWord (identifier->as_string ())); + new MetaWord (identifier->as_string (), identifier->get_locus ())); } if (peek_token (1)->get_id () == EQUAL) @@ -4731,8 +4731,7 @@ MetaItemSeq::to_attribute () const Attribute MetaWord::to_attribute () const { - // FIXME: How do we get a location here? - return Attribute (SimplePath::from_str (ident, Location ()), nullptr); + return Attribute (SimplePath::from_str (ident, ident_locus), nullptr); } Attribute diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 4b0a41217a0..5270d11ee61 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -759,9 +759,12 @@ protected: class MetaWord : public MetaItem { Identifier ident; + Location ident_locus; public: - MetaWord (Identifier ident) : ident (std::move (ident)) {} + MetaWord (Identifier ident, Location ident_locus) + : ident (std::move (ident)), ident_locus (ident_locus) + {} std::string as_string () const override { return ident; }