From ac742ebc793e3e7a443cca4d9165686445ea81be Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Mon, 30 Nov 2020 10:42:13 +0000 Subject: Linemap and Backend are both singletons We can only create on linemap instance to avoid missing locations in error diagnostics. We also only need one instance of the backend. --- gcc/rust/rust-session-manager.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 20c7e34..dd9398b 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -279,6 +279,12 @@ Session::init () // derived values from hook options.target_data.init_derived_values (); + + // setup singleton linemap + linemap = rust_get_linemap (); + + // setup backend to GCC GIMPLE + backend = rust_get_backend (); } /* Initialise default options. Actually called before handle_option, unlike init @@ -416,12 +422,10 @@ Session::parse_file (const char *filename) rust_fatal_error (Location (), "cannot open filename %s: %m", filename); } - Backend *backend = rust_get_backend (); - // parse file here /* create lexer and parser - these are file-specific and so aren't instance * variables */ - Lexer lex (filename, std::move (file_wrap), rust_get_linemap ()); + Lexer lex (filename, std::move (file_wrap), linemap); Parser parser (std::move (lex)); // generate crate from parser -- cgit v1.1