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/ast/rust-item.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/ast/rust-item.h')
-rw-r--r-- | gcc/rust/ast/rust-item.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 32fb56f..dac76f5 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -977,6 +977,8 @@ private: Location locus; ModuleKind kind; + // Name of the file including the module + std::string outer_filename; // bool has_inner_attrs; std::vector<Attribute> inner_attrs; // bool has_items; @@ -998,10 +1000,11 @@ public: // Unloaded module constructor Module (Identifier module_name, Visibility visibility, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, Location locus, + std::string outer_filename) : VisItem (std::move (visibility), std::move (outer_attrs)), module_name (module_name), locus (locus), kind (ModuleKind::UNLOADED), - inner_attrs (std::vector<Attribute> ()), + outer_filename (outer_filename), inner_attrs (std::vector<Attribute> ()), items (std::vector<std::unique_ptr<Item>> ()) {} @@ -1013,7 +1016,8 @@ public: std::vector<Attribute> outer_attrs = std::vector<Attribute> ()) : VisItem (std::move (visibility), std::move (outer_attrs)), module_name (name), locus (locus), kind (ModuleKind::LOADED), - inner_attrs (std::move (inner_attrs)), items (std::move (items)) + outer_filename (std::string ()), inner_attrs (std::move (inner_attrs)), + items (std::move (items)) {} // Copy constructor with vector clone @@ -1049,6 +1053,9 @@ public: return *this; } + // Search for the filename associated with an external module + std::string get_filename (); + void accept_vis (ASTVisitor &vis) override; /* Override that runs the function recursively on all items contained within |