public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ast: Add location info to remaining meta items
@ 2022-06-08 12:39 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:471cff253a1c67cf4a85c0a91695e7e6d7803a5e

commit 471cff253a1c67cf4a85c0a91695e7e6d7803a5e
Author: Arthur Cohen <arthur.cohen@embecosm.com>
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<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 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<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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:39 [gcc/devel/rust/master] ast: Add location info to remaining meta items Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).