public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] macrotranscriber: Add location info
@ 2022-06-08 12:06 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:06 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:45ca46018f034e50d37e6fdcd3d0de9c0ce74927
commit 45ca46018f034e50d37e6fdcd3d0de9c0ce74927
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Wed Feb 16 13:03:45 2022 +0100
macrotranscriber: Add location info
Diff:
---
gcc/rust/ast/rust-macro.h | 12 +++++++-----
gcc/rust/parse/rust-parse-impl.h | 3 ++-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h
index 2d59b1852db..ef50e4a3015 100644
--- a/gcc/rust/ast/rust-macro.h
+++ b/gcc/rust/ast/rust-macro.h
@@ -277,15 +277,16 @@ struct MacroTranscriber
{
private:
DelimTokenTree token_tree;
-
- // TODO: should store location information?
+ Location locus;
public:
- MacroTranscriber (DelimTokenTree token_tree)
- : token_tree (std::move (token_tree))
+ MacroTranscriber (DelimTokenTree token_tree, Location locus)
+ : token_tree (std::move (token_tree)), locus (locus)
{}
std::string as_string () const { return token_tree.as_string (); }
+
+ Location get_locus () const { return locus; }
};
// A macro rule? Matcher and transcriber pair?
@@ -310,7 +311,8 @@ public:
{
// FIXME: Once #928 is merged, give location to MacroMatcher
return MacroRule (MacroMatcher::create_error (Location ()),
- MacroTranscriber (DelimTokenTree::create_empty ()));
+ MacroTranscriber (DelimTokenTree::create_empty (),
+ Location ()));
}
std::string as_string () const;
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index b500c871795..ef0ad40a781 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -1691,7 +1691,8 @@ Parser<ManagedTokenSource>::parse_macro_rule ()
}
// parse transcriber (this is just a delim token tree)
- AST::MacroTranscriber transcriber (parse_delim_token_tree ());
+ Location token_tree_loc = lexer.peek_token ()->get_locus ();
+ AST::MacroTranscriber transcriber (parse_delim_token_tree (), token_tree_loc);
return AST::MacroRule (std::move (matcher), std::move (transcriber));
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:06 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:06 [gcc/devel/rust/master] macrotranscriber: Add location info 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).