diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-12 15:06:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 15:06:52 +0000 |
commit | 3610c9b202b3197bd92ce7b8dbabcb86d4641ee6 (patch) | |
tree | a8be78ea928d605ce6ea8f29a896fcbb48f42af4 /gcc/rust/lex/rust-lex.h | |
parent | 7be0232c686a75f98b2ca3c27f7de3139b8999c6 (diff) | |
parent | b4993a629348279023b2c0159169ed62f10ac453 (diff) | |
download | gcc-3610c9b202b3197bd92ce7b8dbabcb86d4641ee6.zip gcc-3610c9b202b3197bd92ce7b8dbabcb86d4641ee6.tar.gz gcc-3610c9b202b3197bd92ce7b8dbabcb86d4641ee6.tar.bz2 |
Merge #613
613: Resolve module filename r=philberty a=CohenArthur
This PR is a first attempt at resolving the filename corresponding to an external module correctly. Some of the cases are not handled yet and a lot of FIXMEs are still here, as I am looking for feedback on certain things:
* Am I correct in assuming that we have to go through directories the C way because we are using C++11 and the `filesystem` header is not available until C++17? Is there some gcc abstraction for this that I'm overlooking?
* How important is the existence of a separate SEPARATOR macro for Windows? From what I'm understanding, the OS also understands normal slashes `/` on top of the backward slashes it usually uses `\`. I don't know what happens when they are mixed and matched or how the file system handles it.
* For review simplicity, outer attributes could be accessed in a later PR. I believe they can already be accessed and looked at but haven't looked into it. I'm also unsure if this would be the right place to implement that outer_attr lookup
Co-authored-by: CohenArthur <arthur.cohen@epita.fr>
Diffstat (limited to 'gcc/rust/lex/rust-lex.h')
-rw-r--r-- | gcc/rust/lex/rust-lex.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/rust/lex/rust-lex.h b/gcc/rust/lex/rust-lex.h index 902745f..1b37a9c 100644 --- a/gcc/rust/lex/rust-lex.h +++ b/gcc/rust/lex/rust-lex.h @@ -14,6 +14,7 @@ struct RAIIFile { private: FILE *file; + const char *filename; void close () { @@ -22,7 +23,7 @@ private: } public: - RAIIFile (const char *filename) + RAIIFile (const char *filename) : filename (filename) { if (strcmp (filename, "-") == 0) file = stdin; @@ -47,6 +48,7 @@ public: ~RAIIFile () { close (); } FILE *get_raw () { return file; } + const char *get_filename () { return filename; } }; class Lexer @@ -136,6 +138,7 @@ public: void split_current_token (TokenId new_left, TokenId new_right); Linemap *get_line_map () { return line_map; } + std::string get_filename () { return std::string (input.get_filename ()); } private: // File for use as input. |