Skip to content

Commit 6114574

Browse files
powerboat9philberty
authored andcommitted
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 <[email protected]>
1 parent 69f6bc9 commit 6114574

20 files changed

+45
-46
lines changed

gcc/rust/ast/rust-ast-collector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class TokenCollector : public ASTVisitor
160160
void visit (Visitable &v);
161161
void visit (LoopLabel &label);
162162

163-
void visit (Literal &lit, Location locus = UNDEF_LOCATION);
163+
void visit (Literal &lit, location_t locus = UNDEF_LOCATION);
164164

165165
void visit (FunctionParam &param);
166166
void visit (Attribute &attrib);

gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ is_child_module (Analysis::Mappings &mappings, NodeId parent,
112112
// FIXME: This function needs a lot of refactoring
113113
void
114114
PrivacyReporter::check_for_privacy_violation (const NodeId &use_id,
115-
const Location &locus)
115+
const location_t locus)
116116
{
117117
NodeId ref_node_id = UNKNOWN_NODEID;
118118

@@ -172,7 +172,7 @@ PrivacyReporter::check_for_privacy_violation (const NodeId &use_id,
172172
void
173173
PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings,
174174
const TyTy::BaseType *ty,
175-
const Location &locus)
175+
const location_t locus)
176176
{
177177
// Avoids repeating commong argument such as `use_id` or `locus` since we're
178178
// doing a lot of recursive calls here

gcc/rust/checks/errors/privacy/rust-privacy-reporter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PrivacyReporter : public HIR::HIRExpressionVisitor,
5656
* @param locus Location of said expression/statement
5757
*/
5858
void check_for_privacy_violation (const NodeId &use_id,
59-
const Location &locus);
59+
const location_t locus);
6060

6161
/**
6262
* Internal function used by `check_type_privacy` when dealing with complex
@@ -65,7 +65,7 @@ types
6565
*/
6666
void check_base_type_privacy (Analysis::NodeMapping &node_mappings,
6767
const TyTy::BaseType *ty,
68-
const Location &locus);
68+
const location_t locus);
6969

7070
/**
7171
* Check the privacy of an explicit type.

gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Privacy {
2525

2626
bool
2727
PubRestrictedVisitor::is_restriction_valid (NodeId item_id,
28-
const Location &locus)
28+
const location_t locus)
2929
{
3030
ModuleVisibility visibility;
3131

gcc/rust/checks/errors/privacy/rust-pub-restricted-visitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class PubRestrictedVisitor : public HIR::HIRVisItemVisitor
8787
*
8888
* @return true if the visibility restriction is valid, false otherwise.
8989
*/
90-
bool is_restriction_valid (NodeId item_id, const Location &locus);
90+
bool is_restriction_valid (NodeId item_id, const location_t locus);
9191

9292
virtual void visit (HIR::Module &mod);
9393
virtual void visit (HIR::ExternCrate &crate);

gcc/rust/checks/errors/rust-feature-gate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ FeatureGate::check (AST::Crate &crate)
6565
}
6666

6767
void
68-
FeatureGate::gate (Feature::Name name, Location loc,
68+
FeatureGate::gate (Feature::Name name, location_t loc,
6969
const std::string &error_msg)
7070
{
7171
if (!valid_features.count (name))

gcc/rust/checks/errors/rust-feature-gate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class FeatureGate : public AST::ASTVisitor
186186
void visit (AST::BareFunctionType &type) override {}
187187

188188
private:
189-
void gate (Feature::Name name, Location loc, const std::string &error_msg);
189+
void gate (Feature::Name name, location_t loc, const std::string &error_msg);
190190
void check_rustc_attri (const std::vector<AST::Attribute> &attributes);
191191
std::set<Feature::Name> valid_features;
192192
};

gcc/rust/expand/rust-proc-macro.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ register_callback (void *handle, Symbol, std::string symbol_name,
8989
void *addr = dlsym (handle, symbol_name.c_str ());
9090
if (addr == nullptr)
9191
{
92-
rust_error_at (Location (),
92+
rust_error_at (UNDEF_LOCATION,
9393
"Callback registration symbol (%s) missing from "
9494
"proc macro, wrong version?",
9595
symbol_name.c_str ());

gcc/rust/metadata/rust-imports.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Import
7676

7777
// Given an error if the next LENGTH bytes do not match BYTES.
7878
// Advance the read position by LENGTH.
79-
void require_bytes (Location, const char *bytes, size_t length);
79+
void require_bytes (location_t, const char *bytes, size_t length);
8080

8181
// Advance the read position by SKIP bytes.
8282
void advance (size_t skip)
@@ -115,7 +115,7 @@ class Import
115115
const std::string &relative_import_path);
116116

117117
static std::pair<std::unique_ptr<Stream>, std::vector<ProcMacro::Procmacro>>
118-
try_package_in_directory (const std::string &, Location);
118+
try_package_in_directory (const std::string &, location_t);
119119

120120
// Constructor.
121121
Import (std::unique_ptr<Stream>, location_t);

gcc/rust/resolve/rust-ast-resolve-path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ResolvePath : public ResolverBase
4343
void
4444
resolve_simple_path_segments (CanonicalPath prefix, size_t offs,
4545
const std::vector<AST::SimplePathSegment> &segs,
46-
NodeId expr_node_id, Location expr_locus);
46+
NodeId expr_node_id, location_t expr_locus);
4747
};
4848

4949
} // namespace Resolver

gcc/rust/resolve/rust-name-resolver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ class Rib
7171

7272
CrateNum get_crate_num () const { return crate_num; }
7373
NodeId get_node_id () const { return node_id; }
74-
std::map<NodeId, Location> &get_declarations () { return decls_within_rib; }
74+
std::map<NodeId, location_t> &get_declarations () { return decls_within_rib; }
7575

7676
private:
7777
CrateNum crate_num;
7878
NodeId node_id;
7979
std::map<CanonicalPath, NodeId> path_mappings;
8080
std::map<NodeId, CanonicalPath> reverse_path_mappings;
81-
std::map<NodeId, Location> decls_within_rib;
81+
std::map<NodeId, location_t> decls_within_rib;
8282
std::map<NodeId, std::set<NodeId>> references;
8383
std::map<NodeId, ItemType> decl_type_mappings;
8484
};

gcc/rust/rust-backend.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Backend
5656
{}
5757

5858
typed_identifier (const std::string &a_name, tree a_type,
59-
Location a_location)
59+
location_t a_location)
6060
: name (a_name), type (a_type), location (a_location)
6161
{}
6262
};
@@ -229,7 +229,7 @@ class Backend
229229
// Supported values of OP are enumerated in ArithmeticOrLogicalOperator.
230230
virtual tree arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
231231
tree left, tree right,
232-
Location loc)
232+
location_t loc)
233233
= 0;
234234

235235
// Return an expression for the operation LEFT OP RIGHT.
@@ -239,14 +239,14 @@ class Backend
239239
// variable which will contain the result of that operation.
240240
virtual tree
241241
arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op,
242-
tree left, tree right, Location loc,
243-
Bvariable *receiver)
242+
tree left, tree right,
243+
location_t loc, Bvariable *receiver)
244244
= 0;
245245

246246
// Return an expression for the operation LEFT OP RIGHT.
247247
// Supported values of OP are enumerated in ComparisonOperator.
248248
virtual tree comparison_expression (ComparisonOperator op, tree left,
249-
tree right, Location loc)
249+
tree right, location_t loc)
250250
= 0;
251251

252252
// Return an expression for the operation LEFT OP RIGHT.
@@ -340,7 +340,7 @@ class Backend
340340
// The statements will be added after the block is created.
341341
virtual tree block (tree function, tree enclosing,
342342
const std::vector<Bvariable *> &vars,
343-
Location start_location, Location end_location)
343+
location_t start_location, location_t end_location)
344344
= 0;
345345

346346
// Add the statements to a block. The block is created first. Then

gcc/rust/rust-diagnostics.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,24 +1090,24 @@ TABLE_TO_MAP(E0794),
10901090
};
10911091

10921092
extern void
1093-
rust_internal_error_at (const Location, const char *fmt, ...)
1093+
rust_internal_error_at (const location_t, const char *fmt, ...)
10941094
RUST_ATTRIBUTE_GCC_DIAG (2, 3)
10951095
RUST_ATTRIBUTE_NORETURN;
10961096
extern void
1097-
rust_error_at (const Location, const char *fmt, ...)
1097+
rust_error_at (const location_t, const char *fmt, ...)
10981098
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
10991099
extern void
1100-
rust_error_at (const Location, const ErrorCode, const char *fmt, ...)
1100+
rust_error_at (const location_t, const ErrorCode, const char *fmt, ...)
11011101
RUST_ATTRIBUTE_GCC_DIAG (3, 4);
11021102
extern void
1103-
rust_warning_at (const Location, int opt, const char *fmt, ...)
1103+
rust_warning_at (const location_t, int opt, const char *fmt, ...)
11041104
RUST_ATTRIBUTE_GCC_DIAG (3, 4);
11051105
extern void
1106-
rust_fatal_error (const Location, const char *fmt, ...)
1106+
rust_fatal_error (const location_t, const char *fmt, ...)
11071107
RUST_ATTRIBUTE_GCC_DIAG (2, 3)
11081108
RUST_ATTRIBUTE_NORETURN;
11091109
extern void
1110-
rust_inform (const Location, const char *fmt, ...)
1110+
rust_inform (const location_t, const char *fmt, ...)
11111111
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
11121112

11131113
// rich locations
@@ -1135,25 +1135,25 @@ rust_close_quote ();
11351135

11361136
// clang-format off
11371137
extern void
1138-
rust_be_internal_error_at (const Location, const std::string &errmsg)
1138+
rust_be_internal_error_at (const location_t, const std::string &errmsg)
11391139
RUST_ATTRIBUTE_NORETURN;
11401140
extern void
1141-
rust_be_error_at (const Location, const std::string &errmsg);
1141+
rust_be_error_at (const location_t, const std::string &errmsg);
11421142
extern void
1143-
rust_be_error_at (const Location, const ErrorCode,
1143+
rust_be_error_at (const location_t, const ErrorCode,
11441144
const std::string &errmsg);
11451145
extern void
11461146
rust_be_error_at (const rich_location &, const std::string &errmsg);
11471147
extern void
11481148
rust_be_error_at (const rich_location &, const ErrorCode,
11491149
const std::string &errmsg);
11501150
extern void
1151-
rust_be_warning_at (const Location, int opt, const std::string &warningmsg);
1151+
rust_be_warning_at (const location_t, int opt, const std::string &warningmsg);
11521152
extern void
1153-
rust_be_fatal_error (const Location, const std::string &errmsg)
1153+
rust_be_fatal_error (const location_t, const std::string &errmsg)
11541154
RUST_ATTRIBUTE_NORETURN;
11551155
extern void
1156-
rust_be_inform (const Location, const std::string &infomsg);
1156+
rust_be_inform (const location_t, const std::string &infomsg);
11571157
extern void
11581158
rust_be_get_quotechars (const char **open_quote, const char **close_quote);
11591159
extern bool

gcc/rust/rust-gcc.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class Gcc_backend : public Backend
186186

187187
tree arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op,
188188
tree left, tree right,
189-
Location, Bvariable *receiver);
189+
location_t,
190+
Bvariable *receiver);
190191

191192
tree comparison_expression (ComparisonOperator op, tree left, tree right,
192193
location_t);
@@ -231,7 +232,7 @@ class Gcc_backend : public Backend
231232

232233
// Blocks.
233234

234-
tree block (tree, tree, const std::vector<Bvariable *> &, Location,
235+
tree block (tree, tree, const std::vector<Bvariable *> &, location_t,
235236
location_t);
236237

237238
void block_add_statements (tree, const std::vector<tree> &);
@@ -255,7 +256,7 @@ class Gcc_backend : public Backend
255256
Bvariable *static_chain_variable (tree, const std::string &, tree,
256257
location_t);
257258

258-
Bvariable *temporary_variable (tree, tree, tree, tree, bool, Location,
259+
Bvariable *temporary_variable (tree, tree, tree, tree, bool, location_t,
259260
tree *);
260261

261262
// Labels.
@@ -783,7 +784,7 @@ Gcc_backend::function_type_varadic (
783784
tree
784785
Gcc_backend::function_ptr_type (tree result_type,
785786
const std::vector<tree> &parameters,
786-
Location /* locus */)
787+
location_t /* locus */)
787788
{
788789
tree args = NULL_TREE;
789790
tree *pp = &args;
@@ -2084,7 +2085,7 @@ Gcc_backend::statement_list (const std::vector<tree> &statements)
20842085
tree
20852086
Gcc_backend::block (tree fndecl, tree enclosing,
20862087
const std::vector<Bvariable *> &vars,
2087-
Location start_location, location_t)
2088+
location_t start_location, location_t)
20882089
{
20892090
tree block_tree = make_node (BLOCK);
20902091
if (enclosing == NULL)

gcc/rust/rust-linemap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Linemap
6363
// Produce a human-readable description of a Location, e.g.
6464
// "foo.rust:10". Returns an empty string for predeclared, builtin or
6565
// unknown locations.
66-
static std::string location_to_string (Location loc);
66+
static std::string location_to_string (location_t loc);
6767

6868
private:
6969
// Whether we are currently reading a file.

gcc/rust/rust-location.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@
2828
// Used to replace Location default constructor
2929
#define UNDEF_LOCATION UNKNOWN_LOCATION
3030

31-
typedef location_t Location;
32-
3331
#endif // !defined(RUST_LOCATION_H)

gcc/rust/util/rust-attributes.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ is_builtin (const AST::Attribute &attribute, BuiltinAttrDefinition &builtin)
122122
* characters.
123123
*/
124124
static void
125-
check_doc_alias (const std::string &alias_input, const Location &locus)
125+
check_doc_alias (const std::string &alias_input, const location_t locus)
126126
{
127127
// FIXME: The locus here is for the whole attribute. Can we get the locus
128128
// of the alias input instead?

gcc/rust/util/rust-hir-map.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ Mappings::insert_location (HirId id, location_t locus)
797797
locations[id] = locus;
798798
}
799799

800-
Location
800+
location_t
801801
Mappings::lookup_location (HirId id)
802802
{
803803
auto it = locations.find (id);

gcc/rust/util/rust-hir-map.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Mappings
172172
bool lookup_hir_to_node (HirId id, NodeId *ref);
173173

174174
void insert_location (HirId id, location_t locus);
175-
Location lookup_location (HirId id);
175+
location_t lookup_location (HirId id);
176176

177177
bool resolve_nodeid_to_stmt (NodeId id, HIR::Stmt **stmt);
178178

@@ -383,7 +383,7 @@ class Mappings
383383
std::map<HirId, HIR::Pattern *> hirPatternMappings;
384384
std::map<RustLangItem::ItemType, DefId> lang_item_mappings;
385385
std::map<NodeId, const Resolver::CanonicalPath> paths;
386-
std::map<NodeId, Location> locations;
386+
std::map<NodeId, location_t> locations;
387387
std::map<NodeId, HirId> nodeIdToHirMappings;
388388
std::map<HirId, NodeId> hirIdToNodeMappings;
389389

gcc/rust/util/rust-token-converter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ convert (location_t location)
5757
return ProcMacro::Span::make_span (location, 0);
5858
}
5959

60-
static Location
60+
static location_t
6161
convert (ProcMacro::Span span)
6262
{
6363
return span.start;

0 commit comments

Comments
 (0)