aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2020-11-30 10:42:13 +0000
committerPhilip Herron <philip.herron@embecosm.com>2020-11-30 10:42:13 +0000
commitac742ebc793e3e7a443cca4d9165686445ea81be (patch)
tree71c29414cf8a0ff0fd815cdc894ef7c5c5409944
parent4a9f0d53b81be96b5fe3731a5408bd981158b8e0 (diff)
downloadgcc-ac742ebc793e3e7a443cca4d9165686445ea81be.zip
gcc-ac742ebc793e3e7a443cca4d9165686445ea81be.tar.gz
gcc-ac742ebc793e3e7a443cca4d9165686445ea81be.tar.bz2
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.
-rw-r--r--gcc/rust/rust-session-manager.cc10
1 files changed, 7 insertions, 3 deletions
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<Lexer> parser (std::move (lex));
// generate crate from parser