Skip to content

Commit ac742eb

Browse files
committed
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.
1 parent 4a9f0d5 commit ac742eb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

gcc/rust/rust-session-manager.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ Session::init ()
279279

280280
// derived values from hook
281281
options.target_data.init_derived_values ();
282+
283+
// setup singleton linemap
284+
linemap = rust_get_linemap ();
285+
286+
// setup backend to GCC GIMPLE
287+
backend = rust_get_backend ();
282288
}
283289

284290
/* Initialise default options. Actually called before handle_option, unlike init
@@ -416,12 +422,10 @@ Session::parse_file (const char *filename)
416422
rust_fatal_error (Location (), "cannot open filename %s: %m", filename);
417423
}
418424

419-
Backend *backend = rust_get_backend ();
420-
421425
// parse file here
422426
/* create lexer and parser - these are file-specific and so aren't instance
423427
* variables */
424-
Lexer lex (filename, std::move (file_wrap), rust_get_linemap ());
428+
Lexer lex (filename, std::move (file_wrap), linemap);
425429
Parser<Lexer> parser (std::move (lex));
426430

427431
// generate crate from parser

0 commit comments

Comments
 (0)