diff options
Diffstat (limited to 'gcc/rust/metadata')
| -rw-r--r-- | gcc/rust/metadata/rust-export-metadata.cc | 18 | ||||
| -rw-r--r-- | gcc/rust/metadata/rust-export-metadata.h | 2 | ||||
| -rw-r--r-- | gcc/rust/metadata/rust-import-archive.cc | 7 | ||||
| -rw-r--r-- | gcc/rust/metadata/rust-imports.cc | 5 | ||||
| -rw-r--r-- | gcc/rust/metadata/rust-imports.h | 3 |
5 files changed, 15 insertions, 20 deletions
diff --git a/gcc/rust/metadata/rust-export-metadata.cc b/gcc/rust/metadata/rust-export-metadata.cc index 79c5f30..a8d4af1 100644 --- a/gcc/rust/metadata/rust-export-metadata.cc +++ b/gcc/rust/metadata/rust-export-metadata.cc @@ -23,6 +23,7 @@ #include "rust-ast-dump.h" #include "rust-abi.h" #include "rust-item.h" +#include "rust-macro.h" #include "rust-object-export.h" #include "md5.h" @@ -91,8 +92,8 @@ ExportContext::emit_function (const HIR::Function &fn) AST::Function &function = static_cast<AST::Function &> (vis_item); std::vector<std::unique_ptr<AST::ExternalItem>> external_items; - external_items.push_back (std::unique_ptr<AST::ExternalItem> ( - static_cast<AST::ExternalItem *> (&function))); + external_items.emplace_back ( + static_cast<AST::ExternalItem *> (&function)); AST::ExternBlock extern_block (get_string_from_abi (Rust::ABI::RUST), std::move (external_items), @@ -111,14 +112,12 @@ ExportContext::emit_function (const HIR::Function &fn) } void -ExportContext::emit_macro (NodeId macro) +ExportContext::emit_macro (AST::MacroRulesDefinition ¯o) { std::stringstream oss; AST::Dump dumper (oss); - AST::Item *item = mappings.lookup_ast_item (macro).value (); - - dumper.go (*item); + dumper.go (macro); public_interface_buffer += oss.str (); } @@ -195,7 +194,7 @@ PublicInterface::gather_export_data () vis_item.accept_vis (visitor); } - for (const auto ¯o : mappings.get_exported_macros ()) + for (auto ¯o : mappings.get_exported_macros ()) context.emit_macro (macro); } @@ -234,7 +233,7 @@ PublicInterface::write_to_path (const std::string &path) const { // validate path contains correct extension const std::string expected_file_name = expected_metadata_filename (); - const char *path_base_name = basename (path.c_str ()); + const char *path_base_name = lbasename (path.c_str ()); if (strcmp (path_base_name, expected_file_name.c_str ()) != 0) { rust_error_at (UNDEF_LOCATION, @@ -263,8 +262,7 @@ PublicInterface::write_to_path (const std::string &path) const FILE *nfd = fopen (path.c_str (), "wb"); if (nfd == NULL) { - rust_error_at (UNDEF_LOCATION, - "failed to open file %qs for writing: %s", + rust_error_at (UNDEF_LOCATION, "failed to open file %qs for writing: %s", path.c_str (), xstrerror (errno)); return; } diff --git a/gcc/rust/metadata/rust-export-metadata.h b/gcc/rust/metadata/rust-export-metadata.h index ee006cd..7747d95 100644 --- a/gcc/rust/metadata/rust-export-metadata.h +++ b/gcc/rust/metadata/rust-export-metadata.h @@ -48,7 +48,7 @@ public: * directly refer to them using their NodeId. There's no need to keep an HIR * node for them. */ - void emit_macro (NodeId macro); + void emit_macro (AST::MacroRulesDefinition ¯o); const std::string &get_interface_buffer () const; diff --git a/gcc/rust/metadata/rust-import-archive.cc b/gcc/rust/metadata/rust-import-archive.cc index 6c392b0..f64de4e 100644 --- a/gcc/rust/metadata/rust-import-archive.cc +++ b/gcc/rust/metadata/rust-import-archive.cc @@ -7,7 +7,6 @@ #include "rust-system.h" #include "rust-diagnostics.h" #include "rust-imports.h" -#include "rust-make-unique.h" #ifndef O_BINARY #define O_BINARY 0 @@ -684,7 +683,7 @@ public: const Header &operator* () const { return this->header_; } - const Header *operator-> () const { return &this->header_; } + const Header *operator->() const { return &this->header_; } Archive_iterator &operator++ () { @@ -844,7 +843,7 @@ Import::find_archive_export_data (const std::string &filename, int fd, if (!afile.initialize ()) return nullptr; - auto ret = Rust::make_unique<Stream_concatenate> (); + auto ret = std::make_unique<Stream_concatenate> (); bool any_data = false; bool any_members = false; @@ -872,7 +871,7 @@ Import::find_archive_export_data (const std::string &filename, int fd, if (!any_members) { // It's normal to have an empty archive file when using gobuild. - return Rust::make_unique<Stream_from_string> (""); + return std::make_unique<Stream_from_string> (""); } if (!any_data) diff --git a/gcc/rust/metadata/rust-imports.cc b/gcc/rust/metadata/rust-imports.cc index f2ab105..8d5c381 100644 --- a/gcc/rust/metadata/rust-imports.cc +++ b/gcc/rust/metadata/rust-imports.cc @@ -21,7 +21,6 @@ #include "rust-imports.h" #include "rust-object-export.h" #include "rust-export-metadata.h" -#include "rust-make-unique.h" #ifndef O_BINARY #define O_BINARY 0 @@ -259,7 +258,7 @@ Import::find_export_data (const std::string &filename, int fd, // if (memcmp (buf, Metadata::kMagicHeader, sizeof (Metadata::kMagicHeader)) == 0) - return Rust::make_unique<Stream_from_file> (fd); + return std::make_unique<Stream_from_file> (fd); // See if we can read this as an archive. if (Import::is_archive_magic (buf)) @@ -291,7 +290,7 @@ Import::find_object_export_data (const std::string &filename, int fd, if (buf == nullptr) return nullptr; - return Rust::make_unique<Stream_from_buffer> (buf, len); + return std::make_unique<Stream_from_buffer> (buf, len); } // Class Import. diff --git a/gcc/rust/metadata/rust-imports.h b/gcc/rust/metadata/rust-imports.h index a497c67..65a2af1 100644 --- a/gcc/rust/metadata/rust-imports.h +++ b/gcc/rust/metadata/rust-imports.h @@ -11,8 +11,7 @@ namespace Rust { -extern void -add_search_path (const std::string &path); +extern void add_search_path (const std::string &path); class Import { |
