From: Pierre-Emmanuel Patry <[email protected]>
The compiler would crash if the file name was requested from the lexer
whilst lexing from a non-file source (mainly string sources). Now return
an empty file name instead.
gcc/rust/ChangeLog:
* lex/rust-lex.h: Return an empty file name when file is missing.
Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/ff525e46e126998eb700a522ee63858a7ce0166f
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4588
gcc/rust/lex/rust-lex.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/lex/rust-lex.h b/gcc/rust/lex/rust-lex.h
index 8d65a6ddf..530eafbe5 100644
--- a/gcc/rust/lex/rust-lex.h
+++ b/gcc/rust/lex/rust-lex.h
@@ -207,7 +207,13 @@ public:
void split_current_token (std::vector<TokenPtr> new_tokens);
Linemap *get_line_map () { return line_map; }
- std::string get_filename () { return std::string (input.get_filename ()); }
+ std::string get_filename ()
+ {
+ if (input.ok ())
+ return std::string (input.get_filename ());
+ else
+ return "";
+ }
private:
void start_line (int current_line, int current_column);
base-commit: 656073dc1b60162bf8684672229ecea089b0632d
--
2.54.0