diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-28 10:10:07 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-28 10:23:31 +0200 |
commit | 471cff253a1c67cf4a85c0a91695e7e6d7803a5e (patch) | |
tree | be2cc0785ed1ca6b71fa40c91ebc0b3cdbcf0ac7 | |
parent | ffb38df2eb370eacdf35f6273d6c450eb4940a21 (diff) | |
download | gcc-471cff253a1c67cf4a85c0a91695e7e6d7803a5e.zip gcc-471cff253a1c67cf4a85c0a91695e7e6d7803a5e.tar.gz gcc-471cff253a1c67cf4a85c0a91695e7e6d7803a5e.tar.bz2 |
ast: Add location info to remaining meta items
-rw-r--r-- | gcc/rust/ast/rust-ast-full-test.cc | 23 | ||||
-rw-r--r-- | 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 f15a191..92325f1 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<MetaWord> ( - new MetaWord (identifier->as_string (), identifier->get_locus ())); + return std::unique_ptr<MetaWord> (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<MetaNameValueStr> ( - 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<MetaListNameValueStr> ( - 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<MetaListPaths> ( - 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<AttrInputMetaItemContainer> 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<AttrInputMetaItemContainer> 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 5270d11..1bf8912 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<SimplePath> paths; public: - MetaListPaths (Identifier ident, std::vector<SimplePath> paths) - : ident (std::move (ident)), paths (std::move (paths)) + MetaListPaths (Identifier ident, Location ident_locus, + std::vector<SimplePath> 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<MetaNameValueStr> strs; - // FIXME add location info - public: - MetaListNameValueStr (Identifier ident, std::vector<MetaNameValueStr> strs) - : ident (std::move (ident)), strs (std::move (strs)) + MetaListNameValueStr (Identifier ident, Location ident_locus, + std::vector<MetaNameValueStr> strs) + : ident (std::move (ident)), ident_locus (ident_locus), + strs (std::move (strs)) {} std::string as_string () const override; |