]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Remove Location typedef
authorOwen Avery <powerboat9.gamer@gmail.com>
Tue, 11 Jul 2023 00:15:19 +0000 (20:15 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:56:03 +0000 (18:56 +0100)
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 <powerboat9.gamer@gmail.com>
20 files changed:
gcc/rust/ast/rust-ast-collector.h
gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
gcc/rust/checks/errors/privacy/rust-privacy-reporter.h
gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.cc
gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.h
gcc/rust/checks/errors/rust-feature-gate.cc
gcc/rust/checks/errors/rust-feature-gate.h
gcc/rust/expand/rust-proc-macro.cc
gcc/rust/metadata/rust-imports.h
gcc/rust/resolve/rust-ast-resolve-path.h
gcc/rust/resolve/rust-name-resolver.h
gcc/rust/rust-backend.h
gcc/rust/rust-diagnostics.h
gcc/rust/rust-gcc.cc
gcc/rust/rust-linemap.h
gcc/rust/rust-location.h
gcc/rust/util/rust-attributes.cc
gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h
gcc/rust/util/rust-token-converter.cc

index 792f8bed723feef2dded31a89ab404963815432f..2dae423240e62fc2b24f855fe439adf07c0d11f8 100644 (file)
@@ -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 &param);
   void visit (Attribute &attrib);
index c656e761dcccb88650f2bde0dd9d417b6d2482ad..2c9f4b75a065274d05af475781a24b8f7fdf07c3 100644 (file)
@@ -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
index af35ccf332555988277a675cc2d43b2b7b821fc6..b8fb7cffb45ba8f9927ac75d96bcdc77db81ad07 100644 (file)
@@ -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.
index a800f65297d1f5f24d02ba513a88a1fadfc4ce58..907479071b74d569e0d045427fad73c986bab338 100644 (file)
@@ -25,7 +25,7 @@ namespace Privacy {
 
 bool
 PubRestrictedVisitor::is_restriction_valid (NodeId item_id,
-                                           const Location &locus)
+                                           const location_t locus)
 {
   ModuleVisibility visibility;
 
index 7ac4b31cdc520fc62c384c3ea90d6e5f29ec82b9..d04bdfb262efbe669df2e5a73aa543efaac2b253 100644 (file)
@@ -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);
index 920b4128e027aab75fd57e8759e49ca646ec35af..3e12ee0bad9535bcd2294ad36fb3802592a7cabe 100644 (file)
@@ -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))
index fb9105f720634a24103f8aee2b1bbe5790473c01..5462af598cd92bf9880ff190c1cb7be45dc5d209 100644 (file)
@@ -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<AST::Attribute> &attributes);
   std::set<Feature::Name> valid_features;
 };
index 69de9894688c5546b54280b558971bfc3014e09e..e9e79181646bae865f603586d40763d6fefbdf23 100644 (file)
@@ -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 ());
index 71d2ff8262b42ebf96d2041799ddf269c2f767df..a497c67451743effabed0b075d0510c60f7492ac 100644 (file)
@@ -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::unique_ptr<Stream>, std::vector<ProcMacro::Procmacro>>
-  try_package_in_directory (const std::string &, Location);
+  try_package_in_directory (const std::string &, location_t);
 
   // Constructor.
   Import (std::unique_ptr<Stream>, location_t);
index 841ff386227ab9a2f308a2da2367960dd1e96ce6..7aae19b5eac255af2dfd22d207867122736f5aab 100644 (file)
@@ -43,7 +43,7 @@ private:
   void
   resolve_simple_path_segments (CanonicalPath prefix, size_t offs,
                                const std::vector<AST::SimplePathSegment> &segs,
-                               NodeId expr_node_id, Location expr_locus);
+                               NodeId expr_node_id, location_t expr_locus);
 };
 
 } // namespace Resolver
index 86a847a66650afe0e592555eb65cd589ca8ced7f..23d3c1c26c00f93ad9959940c67d8f7f7282a6ef 100644 (file)
@@ -71,14 +71,14 @@ public:
 
   CrateNum get_crate_num () const { return crate_num; }
   NodeId get_node_id () const { return node_id; }
-  std::map<NodeId, Location> &get_declarations () { return decls_within_rib; }
+  std::map<NodeId, location_t> &get_declarations () { return decls_within_rib; }
 
 private:
   CrateNum crate_num;
   NodeId node_id;
   std::map<CanonicalPath, NodeId> path_mappings;
   std::map<NodeId, CanonicalPath> reverse_path_mappings;
-  std::map<NodeId, Location> decls_within_rib;
+  std::map<NodeId, location_t> decls_within_rib;
   std::map<NodeId, std::set<NodeId>> references;
   std::map<NodeId, ItemType> decl_type_mappings;
 };
index f5048f0611d111bb022de5cffdbc49ada194fa9d..d4679ca9d86d1b456ca15a5395471db042616938 100644 (file)
@@ -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<Bvariable *> &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
index 4f00c7e2336e4c2e76b7063ed5429107731b7312..552689136efb35f779b5818d0c1ebc0a96c6e8e9 100644 (file)
@@ -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
index 119b02d44b206c0b7593fb454f10a3e13f2b6863..a6a67bbb159dbc1aef5a62d8f950a4ae15087cd9 100644 (file)
@@ -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<Bvariable *> &, Location,
+  tree block (tree, tree, const std::vector<Bvariable *> &, location_t,
              location_t);
 
   void block_add_statements (tree, const std::vector<tree> &);
@@ -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<tree> &parameters,
-                               Location /* locus */)
+                               location_t /* locus */)
 {
   tree args = NULL_TREE;
   tree *pp = &args;
@@ -2084,7 +2085,7 @@ Gcc_backend::statement_list (const std::vector<tree> &statements)
 tree
 Gcc_backend::block (tree fndecl, tree enclosing,
                    const std::vector<Bvariable *> &vars,
-                   Location start_location, location_t)
+                   location_t start_location, location_t)
 {
   tree block_tree = make_node (BLOCK);
   if (enclosing == NULL)
index 219bf1de1e6083a5a2b31bfd976f6dc725e79019..905e256972a5b327df68180bc91808ff6f3afa48 100644 (file)
@@ -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.
index 0b94d7ba3565f5e1a959f31a7095695adb856b19..db756dd1d36802f4860177538ad829c8564541b3 100644 (file)
@@ -29,6 +29,4 @@
 // Used to replace Location default constructor
 #define UNDEF_LOCATION UNKNOWN_LOCATION
 
-typedef location_t Location;
-
 #endif // !defined(RUST_LOCATION_H)
index 8b133cc7e7d265a9ed24f6fa972bbe16113067ee..33097a84e1f093c8d69660ce4e6ffebefbedd514 100644 (file)
@@ -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?
index 4c70fe045b096f616a795da8e67756635a41bf48..9df7fe9e63a2038fe91eecd1112cc1135f8b1193 100644 (file)
@@ -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);
index 5bd9cad7d3ae63b1dff1d76f23d7b137fe227db3..b78d4c229746fa81c56b72c27424533f57c6fa20 100644 (file)
@@ -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<HirId, HIR::Pattern *> hirPatternMappings;
   std::map<RustLangItem::ItemType, DefId> lang_item_mappings;
   std::map<NodeId, const Resolver::CanonicalPath> paths;
-  std::map<NodeId, Location> locations;
+  std::map<NodeId, location_t> locations;
   std::map<NodeId, HirId> nodeIdToHirMappings;
   std::map<HirId, NodeId> hirIdToNodeMappings;
 
index e0794f38eefbb23a72a1620edd4c77e8ecbeb08f..d9fb85caa83ebf992c0210be0714d29399b44b8c 100644 (file)
@@ -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;