From: Owen Avery Date: Tue, 11 Jul 2023 00:15:19 +0000 (-0400) Subject: gccrs: Remove Location typedef X-Git-Tag: basepoints/gcc-15~2281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=886d56d0c54ec73cabae64558f63e7963c9bb90a;p=thirdparty%2Fgcc.git gccrs: Remove Location typedef gcc/rust/ChangeLog: * rust-location.h (typedef Location): Remove. * expand/rust-proc-macro.cc (register_callback): Replace Location constructor with UNDEF_LOCATION. * ast/rust-ast-collector.h: Replace Location with location_t. * checks/errors/privacy/rust-privacy-reporter.cc: Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.cc: Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.h: Likewise. * checks/errors/rust-feature-gate.cc: Likewise. * checks/errors/rust-feature-gate.h: Likewise. * metadata/rust-imports.h: Likewise. * resolve/rust-ast-resolve-path.h: Likewise. * resolve/rust-name-resolver.h: Likewise. * rust-backend.h: Likewise. * rust-diagnostics.h: Likewise. * rust-gcc.cc: Likewise. * rust-linemap.h: Likewise. * util/rust-attributes.cc: Likewise. * util/rust-hir-map.cc: Likewise. * util/rust-hir-map.h: Likewise. * util/rust-token-converter.cc: Likewise. Signed-off-by: Owen Avery --- diff --git a/gcc/rust/ast/rust-ast-collector.h b/gcc/rust/ast/rust-ast-collector.h index 792f8bed723f..2dae423240e6 100644 --- a/gcc/rust/ast/rust-ast-collector.h +++ b/gcc/rust/ast/rust-ast-collector.h @@ -160,7 +160,7 @@ public: void visit (Visitable &v); void visit (LoopLabel &label); - void visit (Literal &lit, Location locus = UNDEF_LOCATION); + void visit (Literal &lit, location_t locus = UNDEF_LOCATION); void visit (FunctionParam ¶m); void visit (Attribute &attrib); diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc index c656e761dccc..2c9f4b75a065 100644 --- a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc +++ b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc @@ -112,7 +112,7 @@ is_child_module (Analysis::Mappings &mappings, NodeId parent, // FIXME: This function needs a lot of refactoring void PrivacyReporter::check_for_privacy_violation (const NodeId &use_id, - const Location &locus) + const location_t locus) { NodeId ref_node_id = UNKNOWN_NODEID; @@ -172,7 +172,7 @@ PrivacyReporter::check_for_privacy_violation (const NodeId &use_id, void PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings, const TyTy::BaseType *ty, - const Location &locus) + const location_t locus) { // Avoids repeating commong argument such as `use_id` or `locus` since we're // doing a lot of recursive calls here diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.h b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.h index af35ccf33255..b8fb7cffb45b 100644 --- a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.h +++ b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.h @@ -56,7 +56,7 @@ private: * @param locus Location of said expression/statement */ void check_for_privacy_violation (const NodeId &use_id, - const Location &locus); + const location_t locus); /** * Internal function used by `check_type_privacy` when dealing with complex @@ -65,7 +65,7 @@ types */ void check_base_type_privacy (Analysis::NodeMapping &node_mappings, const TyTy::BaseType *ty, - const Location &locus); + const location_t locus); /** * Check the privacy of an explicit type. diff --git a/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.cc b/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.cc index a800f65297d1..907479071b74 100644 --- a/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.cc +++ b/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.cc @@ -25,7 +25,7 @@ namespace Privacy { bool PubRestrictedVisitor::is_restriction_valid (NodeId item_id, - const Location &locus) + const location_t locus) { ModuleVisibility visibility; diff --git a/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.h b/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.h index 7ac4b31cdc52..d04bdfb262ef 100644 --- a/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.h +++ b/gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.h @@ -87,7 +87,7 @@ public: * * @return true if the visibility restriction is valid, false otherwise. */ - bool is_restriction_valid (NodeId item_id, const Location &locus); + bool is_restriction_valid (NodeId item_id, const location_t locus); virtual void visit (HIR::Module &mod); virtual void visit (HIR::ExternCrate &crate); diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc index 920b4128e027..3e12ee0bad95 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.cc +++ b/gcc/rust/checks/errors/rust-feature-gate.cc @@ -65,7 +65,7 @@ FeatureGate::check (AST::Crate &crate) } void -FeatureGate::gate (Feature::Name name, Location loc, +FeatureGate::gate (Feature::Name name, location_t loc, const std::string &error_msg) { if (!valid_features.count (name)) diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h index fb9105f72063..5462af598cd9 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.h +++ b/gcc/rust/checks/errors/rust-feature-gate.h @@ -186,7 +186,7 @@ public: void visit (AST::BareFunctionType &type) override {} private: - void gate (Feature::Name name, Location loc, const std::string &error_msg); + void gate (Feature::Name name, location_t loc, const std::string &error_msg); void check_rustc_attri (const std::vector &attributes); std::set valid_features; }; diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc index 69de9894688c..e9e79181646b 100644 --- a/gcc/rust/expand/rust-proc-macro.cc +++ b/gcc/rust/expand/rust-proc-macro.cc @@ -89,7 +89,7 @@ register_callback (void *handle, Symbol, std::string symbol_name, void *addr = dlsym (handle, symbol_name.c_str ()); if (addr == nullptr) { - rust_error_at (Location (), + rust_error_at (UNDEF_LOCATION, "Callback registration symbol (%s) missing from " "proc macro, wrong version?", symbol_name.c_str ()); diff --git a/gcc/rust/metadata/rust-imports.h b/gcc/rust/metadata/rust-imports.h index 71d2ff8262b4..a497c6745174 100644 --- a/gcc/rust/metadata/rust-imports.h +++ b/gcc/rust/metadata/rust-imports.h @@ -76,7 +76,7 @@ public: // Given an error if the next LENGTH bytes do not match BYTES. // Advance the read position by LENGTH. - void require_bytes (Location, const char *bytes, size_t length); + void require_bytes (location_t, const char *bytes, size_t length); // Advance the read position by SKIP bytes. void advance (size_t skip) @@ -115,7 +115,7 @@ public: const std::string &relative_import_path); static std::pair, std::vector> - try_package_in_directory (const std::string &, Location); + try_package_in_directory (const std::string &, location_t); // Constructor. Import (std::unique_ptr, location_t); diff --git a/gcc/rust/resolve/rust-ast-resolve-path.h b/gcc/rust/resolve/rust-ast-resolve-path.h index 841ff386227a..7aae19b5eac2 100644 --- a/gcc/rust/resolve/rust-ast-resolve-path.h +++ b/gcc/rust/resolve/rust-ast-resolve-path.h @@ -43,7 +43,7 @@ private: void resolve_simple_path_segments (CanonicalPath prefix, size_t offs, const std::vector &segs, - NodeId expr_node_id, Location expr_locus); + NodeId expr_node_id, location_t expr_locus); }; } // namespace Resolver diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h index 86a847a66650..23d3c1c26c00 100644 --- a/gcc/rust/resolve/rust-name-resolver.h +++ b/gcc/rust/resolve/rust-name-resolver.h @@ -71,14 +71,14 @@ public: CrateNum get_crate_num () const { return crate_num; } NodeId get_node_id () const { return node_id; } - std::map &get_declarations () { return decls_within_rib; } + std::map &get_declarations () { return decls_within_rib; } private: CrateNum crate_num; NodeId node_id; std::map path_mappings; std::map reverse_path_mappings; - std::map decls_within_rib; + std::map decls_within_rib; std::map> references; std::map decl_type_mappings; }; diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h index f5048f0611d1..d4679ca9d86d 100644 --- a/gcc/rust/rust-backend.h +++ b/gcc/rust/rust-backend.h @@ -56,7 +56,7 @@ public: {} typed_identifier (const std::string &a_name, tree a_type, - Location a_location) + location_t a_location) : name (a_name), type (a_type), location (a_location) {} }; @@ -229,7 +229,7 @@ public: // Supported values of OP are enumerated in ArithmeticOrLogicalOperator. virtual tree arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op, tree left, tree right, - Location loc) + location_t loc) = 0; // Return an expression for the operation LEFT OP RIGHT. @@ -239,14 +239,14 @@ public: // variable which will contain the result of that operation. virtual tree arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op, - tree left, tree right, Location loc, - Bvariable *receiver) + tree left, tree right, + location_t loc, Bvariable *receiver) = 0; // Return an expression for the operation LEFT OP RIGHT. // Supported values of OP are enumerated in ComparisonOperator. virtual tree comparison_expression (ComparisonOperator op, tree left, - tree right, Location loc) + tree right, location_t loc) = 0; // Return an expression for the operation LEFT OP RIGHT. @@ -340,7 +340,7 @@ public: // The statements will be added after the block is created. virtual tree block (tree function, tree enclosing, const std::vector &vars, - Location start_location, Location end_location) + location_t start_location, location_t end_location) = 0; // Add the statements to a block. The block is created first. Then diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 4f00c7e2336e..552689136efb 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -1090,24 +1090,24 @@ TABLE_TO_MAP(E0794), }; extern void -rust_internal_error_at (const Location, const char *fmt, ...) +rust_internal_error_at (const location_t, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3) RUST_ATTRIBUTE_NORETURN; extern void -rust_error_at (const Location, const char *fmt, ...) +rust_error_at (const location_t, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); extern void -rust_error_at (const Location, const ErrorCode, const char *fmt, ...) +rust_error_at (const location_t, const ErrorCode, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (3, 4); extern void -rust_warning_at (const Location, int opt, const char *fmt, ...) +rust_warning_at (const location_t, int opt, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (3, 4); extern void -rust_fatal_error (const Location, const char *fmt, ...) +rust_fatal_error (const location_t, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3) RUST_ATTRIBUTE_NORETURN; extern void -rust_inform (const Location, const char *fmt, ...) +rust_inform (const location_t, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); // rich locations @@ -1135,12 +1135,12 @@ rust_close_quote (); // clang-format off extern void -rust_be_internal_error_at (const Location, const std::string &errmsg) +rust_be_internal_error_at (const location_t, const std::string &errmsg) RUST_ATTRIBUTE_NORETURN; extern void -rust_be_error_at (const Location, const std::string &errmsg); +rust_be_error_at (const location_t, const std::string &errmsg); extern void -rust_be_error_at (const Location, const ErrorCode, +rust_be_error_at (const location_t, const ErrorCode, const std::string &errmsg); extern void rust_be_error_at (const rich_location &, const std::string &errmsg); @@ -1148,12 +1148,12 @@ extern void rust_be_error_at (const rich_location &, const ErrorCode, const std::string &errmsg); extern void -rust_be_warning_at (const Location, int opt, const std::string &warningmsg); +rust_be_warning_at (const location_t, int opt, const std::string &warningmsg); extern void -rust_be_fatal_error (const Location, const std::string &errmsg) +rust_be_fatal_error (const location_t, const std::string &errmsg) RUST_ATTRIBUTE_NORETURN; extern void -rust_be_inform (const Location, const std::string &infomsg); +rust_be_inform (const location_t, const std::string &infomsg); extern void rust_be_get_quotechars (const char **open_quote, const char **close_quote); extern bool diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 119b02d44b20..a6a67bbb159d 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -186,7 +186,8 @@ public: tree arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op, tree left, tree right, - Location, Bvariable *receiver); + location_t, + Bvariable *receiver); tree comparison_expression (ComparisonOperator op, tree left, tree right, location_t); @@ -231,7 +232,7 @@ public: // Blocks. - tree block (tree, tree, const std::vector &, Location, + tree block (tree, tree, const std::vector &, location_t, location_t); void block_add_statements (tree, const std::vector &); @@ -255,7 +256,7 @@ public: Bvariable *static_chain_variable (tree, const std::string &, tree, location_t); - Bvariable *temporary_variable (tree, tree, tree, tree, bool, Location, + Bvariable *temporary_variable (tree, tree, tree, tree, bool, location_t, tree *); // Labels. @@ -783,7 +784,7 @@ Gcc_backend::function_type_varadic ( tree Gcc_backend::function_ptr_type (tree result_type, const std::vector ¶meters, - Location /* locus */) + location_t /* locus */) { tree args = NULL_TREE; tree *pp = &args; @@ -2084,7 +2085,7 @@ Gcc_backend::statement_list (const std::vector &statements) tree Gcc_backend::block (tree fndecl, tree enclosing, const std::vector &vars, - Location start_location, location_t) + location_t start_location, location_t) { tree block_tree = make_node (BLOCK); if (enclosing == NULL) diff --git a/gcc/rust/rust-linemap.h b/gcc/rust/rust-linemap.h index 219bf1de1e60..905e256972a5 100644 --- a/gcc/rust/rust-linemap.h +++ b/gcc/rust/rust-linemap.h @@ -63,7 +63,7 @@ public: // Produce a human-readable description of a Location, e.g. // "foo.rust:10". Returns an empty string for predeclared, builtin or // unknown locations. - static std::string location_to_string (Location loc); + static std::string location_to_string (location_t loc); private: // Whether we are currently reading a file. diff --git a/gcc/rust/rust-location.h b/gcc/rust/rust-location.h index 0b94d7ba3565..db756dd1d368 100644 --- a/gcc/rust/rust-location.h +++ b/gcc/rust/rust-location.h @@ -29,6 +29,4 @@ // Used to replace Location default constructor #define UNDEF_LOCATION UNKNOWN_LOCATION -typedef location_t Location; - #endif // !defined(RUST_LOCATION_H) diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 8b133cc7e7d2..33097a84e1f0 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -122,7 +122,7 @@ is_builtin (const AST::Attribute &attribute, BuiltinAttrDefinition &builtin) * characters. */ static void -check_doc_alias (const std::string &alias_input, const Location &locus) +check_doc_alias (const std::string &alias_input, const location_t locus) { // FIXME: The locus here is for the whole attribute. Can we get the locus // of the alias input instead? diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 4c70fe045b09..9df7fe9e63a2 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -797,7 +797,7 @@ Mappings::insert_location (HirId id, location_t locus) locations[id] = locus; } -Location +location_t Mappings::lookup_location (HirId id) { auto it = locations.find (id); diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 5bd9cad7d3ae..b78d4c229746 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -172,7 +172,7 @@ public: bool lookup_hir_to_node (HirId id, NodeId *ref); void insert_location (HirId id, location_t locus); - Location lookup_location (HirId id); + location_t lookup_location (HirId id); bool resolve_nodeid_to_stmt (NodeId id, HIR::Stmt **stmt); @@ -383,7 +383,7 @@ private: std::map hirPatternMappings; std::map lang_item_mappings; std::map paths; - std::map locations; + std::map locations; std::map nodeIdToHirMappings; std::map hirIdToNodeMappings; diff --git a/gcc/rust/util/rust-token-converter.cc b/gcc/rust/util/rust-token-converter.cc index e0794f38eefb..d9fb85caa83e 100644 --- a/gcc/rust/util/rust-token-converter.cc +++ b/gcc/rust/util/rust-token-converter.cc @@ -57,7 +57,7 @@ convert (location_t location) return ProcMacro::Span::make_span (location, 0); } -static Location +static location_t convert (ProcMacro::Span span) { return span.start;