From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 743E83819EB3; Wed, 8 Jun 2022 12:39:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 743E83819EB3 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 remaining meta items X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: ffb38df2eb370eacdf35f6273d6c450eb4940a21 X-Git-Newrev: 471cff253a1c67cf4a85c0a91695e7e6d7803a5e Message-Id: <20220608123929.743E83819EB3@sourceware.org> Date: Wed, 8 Jun 2022 12:39:29 +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:29 -0000 https://gcc.gnu.org/g:471cff253a1c67cf4a85c0a91695e7e6d7803a5e commit 471cff253a1c67cf4a85c0a91695e7e6d7803a5e Author: Arthur Cohen Date: Thu Apr 28 10:10:07 2022 +0200 ast: Add location info to remaining meta items Diff: --- gcc/rust/ast/rust-ast-full-test.cc | 23 ++++++++++------------- gcc/rust/ast/rust-macro.h | 16 ++++++++++------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index f15a1913717..92325f1e4f3 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -4118,14 +4118,14 @@ AttributeParser::parse_meta_item_inner () return parse_path_meta_item (); } - auto &identifier = peek_token (); + auto ident = peek_token ()->as_string (); + auto ident_locus = peek_token ()->get_locus (); + if (is_end_meta_item_tok (peek_token (1)->get_id ())) { // meta word syntax skip_token (); - // FIXME: We probably need a Location here as well - return std::unique_ptr ( - new MetaWord (identifier->as_string (), identifier->get_locus ())); + return std::unique_ptr (new MetaWord (ident, ident_locus)); } if (peek_token (1)->get_id () == EQUAL) @@ -4145,9 +4145,8 @@ AttributeParser::parse_meta_item_inner () std::string raw_value = unquote_string (std::move (value)); return std::unique_ptr ( - new MetaNameValueStr (identifier->as_string (), - identifier->get_locus (), - std::move (raw_value), locus)); + new MetaNameValueStr (ident, ident_locus, std::move (raw_value), + locus)); } else { @@ -4189,7 +4188,7 @@ AttributeParser::parse_meta_item_inner () if (!meta_name_value_str_items.empty ()) { return std::unique_ptr ( - new MetaListNameValueStr (identifier->as_string (), + new MetaListNameValueStr (ident, ident_locus, std::move (meta_name_value_str_items))); } @@ -4228,7 +4227,7 @@ AttributeParser::parse_meta_item_inner () if (!path_items.empty ()) { return std::unique_ptr ( - new MetaListPaths (identifier->as_string (), std::move (path_items))); + new MetaListPaths (ident, ident_locus, std::move (path_items))); } rust_error_at (Linemap::unknown_location (), @@ -4749,8 +4748,7 @@ MetaListPaths::to_attribute () const std::unique_ptr new_seq_container ( new AttrInputMetaItemContainer (std::move (new_seq))); - // FIXME: How do we get a location here? - return Attribute (SimplePath::from_str (ident, Location ()), + return Attribute (SimplePath::from_str (ident, ident_locus), std::move (new_seq_container)); } @@ -4765,8 +4763,7 @@ MetaListNameValueStr::to_attribute () const std::unique_ptr new_seq_container ( new AttrInputMetaItemContainer (std::move (new_seq))); - // FIXME: How do we get a location here? - return Attribute (SimplePath::from_str (ident, Location ()), + return Attribute (SimplePath::from_str (ident, ident_locus), std::move (new_seq_container)); } diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 5270d11ee61..1bf8912083a 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -829,11 +829,14 @@ protected: class MetaListPaths : public MetaItem { Identifier ident; + Location ident_locus; std::vector paths; public: - MetaListPaths (Identifier ident, std::vector paths) - : ident (std::move (ident)), paths (std::move (paths)) + MetaListPaths (Identifier ident, Location ident_locus, + std::vector paths) + : ident (std::move (ident)), ident_locus (ident_locus), + paths (std::move (paths)) {} std::string as_string () const override; @@ -860,13 +863,14 @@ protected: class MetaListNameValueStr : public MetaItem { Identifier ident; + Location ident_locus; std::vector strs; - // FIXME add location info - public: - MetaListNameValueStr (Identifier ident, std::vector strs) - : ident (std::move (ident)), strs (std::move (strs)) + MetaListNameValueStr (Identifier ident, Location ident_locus, + std::vector strs) + : ident (std::move (ident)), ident_locus (ident_locus), + strs (std::move (strs)) {} std::string as_string () const override;