Skip to content

Commit 45ca460

Browse files
committed
macrotranscriber: Add location info
1 parent a5272f3 commit 45ca460

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

gcc/rust/ast/rust-macro.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,16 @@ struct MacroTranscriber
277277
{
278278
private:
279279
DelimTokenTree token_tree;
280-
281-
// TODO: should store location information?
280+
Location locus;
282281

283282
public:
284-
MacroTranscriber (DelimTokenTree token_tree)
285-
: token_tree (std::move (token_tree))
283+
MacroTranscriber (DelimTokenTree token_tree, Location locus)
284+
: token_tree (std::move (token_tree)), locus (locus)
286285
{}
287286

288287
std::string as_string () const { return token_tree.as_string (); }
288+
289+
Location get_locus () const { return locus; }
289290
};
290291

291292
// A macro rule? Matcher and transcriber pair?
@@ -310,7 +311,8 @@ struct MacroRule
310311
{
311312
// FIXME: Once #928 is merged, give location to MacroMatcher
312313
return MacroRule (MacroMatcher::create_error (Location ()),
313-
MacroTranscriber (DelimTokenTree::create_empty ()));
314+
MacroTranscriber (DelimTokenTree::create_empty (),
315+
Location ()));
314316
}
315317

316318
std::string as_string () const;

gcc/rust/parse/rust-parse-impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,8 @@ Parser<ManagedTokenSource>::parse_macro_rule ()
16911691
}
16921692

16931693
// parse transcriber (this is just a delim token tree)
1694-
AST::MacroTranscriber transcriber (parse_delim_token_tree ());
1694+
Location token_tree_loc = lexer.peek_token ()->get_locus ();
1695+
AST::MacroTranscriber transcriber (parse_delim_token_tree (), token_tree_loc);
16951696

16961697
return AST::MacroRule (std::move (matcher), std::move (transcriber));
16971698
}

0 commit comments

Comments
 (0)