aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-12 13:36:15 -0400
committerPhilip Herron <philip.herron@embecosm.com>2023-07-17 09:39:11 +0000
commit95e8c2d54f4b865206766db74c178ba134a1ab9d (patch)
tree936c690806344b37fac7a884b16785d585abbdf9
parentea69361b3468e8ecb4bd1a329cc482a41dd5ac1a (diff)
downloadgcc-95e8c2d54f4b865206766db74c178ba134a1ab9d.zip
gcc-95e8c2d54f4b865206766db74c178ba134a1ab9d.tar.gz
gcc-95e8c2d54f4b865206766db74c178ba134a1ab9d.tar.bz2
Remove Linemap::predeclared_location
gcc/rust/ChangeLog: * rust-linemap.h (Linemap::predeclared_location): Remove. * backend/rust-compile-type.cc: Replace Linemap::predeclared_location with BUILTINS_LOCATION. * resolve/rust-name-resolver.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
-rw-r--r--gcc/rust/backend/rust-compile-type.cc47
-rw-r--r--gcc/rust/resolve/rust-name-resolver.cc15
-rw-r--r--gcc/rust/rust-linemap.h3
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc3
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc80
5 files changed, 54 insertions, 94 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc
index 02df5fb..6b4cbed 100644
--- a/gcc/rust/backend/rust-compile-type.cc
+++ b/gcc/rust/backend/rust-compile-type.cc
@@ -81,7 +81,7 @@ TyTyResolveCompile::get_implicit_enumeral_node_type (Context *ctx)
{
enum_node = ctx->get_backend ()->named_type (
"enumeral", ctx->get_backend ()->integer_type (false, 64),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
}
return enum_node;
}
@@ -93,9 +93,8 @@ TyTyResolveCompile::get_unit_type (Context *ctx)
if (unit_type == nullptr)
{
auto unit_type_node = ctx->get_backend ()->struct_type ({});
- unit_type
- = ctx->get_backend ()->named_type ("()", unit_type_node,
- Linemap::predeclared_location ());
+ unit_type = ctx->get_backend ()->named_type ("()", unit_type_node,
+ BUILTINS_LOCATION);
}
return unit_type;
}
@@ -444,7 +443,7 @@ TyTyResolveCompile::visit (const TyTy::BoolType &)
translated
= ctx->get_backend ()->named_type ("bool",
ctx->get_backend ()->bool_type (),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
}
void
@@ -454,32 +453,31 @@ TyTyResolveCompile::visit (const TyTy::IntType &type)
{
case TyTy::IntType::I8:
translated = ctx->get_backend ()->named_type (
- "i8", ctx->get_backend ()->integer_type (false, 8),
- Linemap::predeclared_location ());
+ "i8", ctx->get_backend ()->integer_type (false, 8), BUILTINS_LOCATION);
return;
case TyTy::IntType::I16:
translated = ctx->get_backend ()->named_type (
"i16", ctx->get_backend ()->integer_type (false, 16),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
case TyTy::IntType::I32:
translated = ctx->get_backend ()->named_type (
"i32", ctx->get_backend ()->integer_type (false, 32),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
case TyTy::IntType::I64:
translated = ctx->get_backend ()->named_type (
"i64", ctx->get_backend ()->integer_type (false, 64),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
case TyTy::IntType::I128:
translated = ctx->get_backend ()->named_type (
"i128", ctx->get_backend ()->integer_type (false, 128),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
}
}
@@ -491,32 +489,28 @@ TyTyResolveCompile::visit (const TyTy::UintType &type)
{
case TyTy::UintType::U8:
translated = ctx->get_backend ()->named_type (
- "u8", ctx->get_backend ()->integer_type (true, 8),
- Linemap::predeclared_location ());
+ "u8", ctx->get_backend ()->integer_type (true, 8), BUILTINS_LOCATION);
return;
case TyTy::UintType::U16:
translated = ctx->get_backend ()->named_type (
- "u16", ctx->get_backend ()->integer_type (true, 16),
- Linemap::predeclared_location ());
+ "u16", ctx->get_backend ()->integer_type (true, 16), BUILTINS_LOCATION);
return;
case TyTy::UintType::U32:
translated = ctx->get_backend ()->named_type (
- "u32", ctx->get_backend ()->integer_type (true, 32),
- Linemap::predeclared_location ());
+ "u32", ctx->get_backend ()->integer_type (true, 32), BUILTINS_LOCATION);
return;
case TyTy::UintType::U64:
translated = ctx->get_backend ()->named_type (
- "u64", ctx->get_backend ()->integer_type (true, 64),
- Linemap::predeclared_location ());
+ "u64", ctx->get_backend ()->integer_type (true, 64), BUILTINS_LOCATION);
return;
case TyTy::UintType::U128:
translated = ctx->get_backend ()->named_type (
"u128", ctx->get_backend ()->integer_type (true, 128),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
}
}
@@ -530,14 +524,14 @@ TyTyResolveCompile::visit (const TyTy::FloatType &type)
translated
= ctx->get_backend ()->named_type ("f32",
ctx->get_backend ()->float_type (32),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
case TyTy::FloatType::F64:
translated
= ctx->get_backend ()->named_type ("f64",
ctx->get_backend ()->float_type (64),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
return;
}
}
@@ -549,7 +543,7 @@ TyTyResolveCompile::visit (const TyTy::USizeType &)
"usize",
ctx->get_backend ()->integer_type (
true, ctx->get_backend ()->get_pointer_size ()),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
}
void
@@ -559,7 +553,7 @@ TyTyResolveCompile::visit (const TyTy::ISizeType &)
"isize",
ctx->get_backend ()->integer_type (
false, ctx->get_backend ()->get_pointer_size ()),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
}
void
@@ -568,7 +562,7 @@ TyTyResolveCompile::visit (const TyTy::CharType &)
translated
= ctx->get_backend ()->named_type ("char",
ctx->get_backend ()->wchar_type (),
- Linemap::predeclared_location ());
+ BUILTINS_LOCATION);
}
void
@@ -691,8 +685,7 @@ TyTyResolveCompile::visit (const TyTy::StrType &type)
{
tree raw_str = create_str_type_record (type);
translated
- = ctx->get_backend ()->named_type ("str", raw_str,
- Linemap::predeclared_location ());
+ = ctx->get_backend ()->named_type ("str", raw_str, BUILTINS_LOCATION);
}
void
diff --git a/gcc/rust/resolve/rust-name-resolver.cc b/gcc/rust/resolve/rust-name-resolver.cc
index b8ed353..7bb123b 100644
--- a/gcc/rust/resolve/rust-name-resolver.cc
+++ b/gcc/rust/resolve/rust-name-resolver.cc
@@ -366,9 +366,8 @@ Resolver::insert_builtin_types (Rib *r)
CanonicalPath builtin_path
= CanonicalPath::new_seg (builtin->get_node_id (),
builtin->as_string ());
- r->insert_name (builtin_path, builtin->get_node_id (),
- Linemap::predeclared_location (), false,
- Rib::ItemType::Type,
+ r->insert_name (builtin_path, builtin->get_node_id (), BUILTINS_LOCATION,
+ false, Rib::ItemType::Type,
[] (const CanonicalPath &, NodeId, Location) -> void {});
}
}
@@ -436,7 +435,7 @@ Resolver::generate_builtins ()
= TyTy::TupleType::get_unit_type (mappings->get_next_hir_id ());
std::vector<std::unique_ptr<AST::Type> > elems;
AST::TupleType *unit_type
- = new AST::TupleType (std::move (elems), Linemap::predeclared_location ());
+ = new AST::TupleType (std::move (elems), BUILTINS_LOCATION);
builtins.push_back (unit_type);
tyctx->insert_builtin (unit_tyty->get_ref (), unit_type->get_node_id (),
unit_tyty);
@@ -446,15 +445,13 @@ Resolver::generate_builtins ()
void
Resolver::setup_builtin (const std::string &name, TyTy::BaseType *tyty)
{
- AST::PathIdentSegment seg (name, Linemap::predeclared_location ());
+ AST::PathIdentSegment seg (name, BUILTINS_LOCATION);
auto typePath = ::std::unique_ptr<AST::TypePathSegment> (
- new AST::TypePathSegment (::std::move (seg), false,
- Linemap::predeclared_location ()));
+ new AST::TypePathSegment (::std::move (seg), false, BUILTINS_LOCATION));
::std::vector< ::std::unique_ptr<AST::TypePathSegment> > segs;
segs.push_back (::std::move (typePath));
auto builtin_type
- = new AST::TypePath (::std::move (segs), Linemap::predeclared_location (),
- false);
+ = new AST::TypePath (::std::move (segs), BUILTINS_LOCATION, false);
builtins.push_back (builtin_type);
tyctx->insert_builtin (tyty->get_ref (), builtin_type->get_node_id (), tyty);
mappings->insert_node_to_hir (builtin_type->get_node_id (), tyty->get_ref ());
diff --git a/gcc/rust/rust-linemap.h b/gcc/rust/rust-linemap.h
index 141dfdc..6515bec 100644
--- a/gcc/rust/rust-linemap.h
+++ b/gcc/rust/rust-linemap.h
@@ -60,9 +60,6 @@ public:
// access some virtual functions without explicitly passing around
// an instance of Linemap.
- // Return the special Location used for predeclared identifiers.
- static Location predeclared_location () { return BUILTINS_LOCATION; }
-
// Produce a human-readable description of a Location, e.g.
// "foo.rust:10". Returns an empty string for predeclared, builtin or
// unknown locations.
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index c9865a5..b231fb1 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -730,8 +730,7 @@ TypeResolveGenericParam::visit (HIR::TypeParam &param)
implicit_id,
param.get_mappings ().get_local_defid ());
implicit_self_bound
- = new HIR::TypePath (mappings, {}, Linemap::predeclared_location (),
- false);
+ = new HIR::TypePath (mappings, {}, BUILTINS_LOCATION, false);
}
// resolve the bounds
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 6663cdd..1955cf2 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -1822,7 +1822,7 @@ TupleType::TupleType (HirId ref, HirId ty_ref, Location locus,
TupleType *
TupleType::get_unit_type (HirId ref)
{
- return new TupleType (ref, Linemap::predeclared_location ());
+ return new TupleType (ref, BUILTINS_LOCATION);
}
size_t
@@ -2481,15 +2481,13 @@ SliceType::handle_substitions (SubstitutionArgumentMappings &mappings)
BoolType::BoolType (HirId ref, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::BOOL,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
BoolType::BoolType (HirId ref, HirId ty_ref, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::BOOL,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
@@ -2534,16 +2532,14 @@ BoolType::clone () const
IntType::IntType (HirId ref, IntKind kind, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::INT,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
int_kind (kind)
{}
IntType::IntType (HirId ref, HirId ty_ref, IntKind kind, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::INT,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
int_kind (kind)
{}
@@ -2620,8 +2616,7 @@ IntType::is_equal (const BaseType &other) const
UintType::UintType (HirId ref, UintKind kind, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::UINT,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
uint_kind (kind)
{}
@@ -2629,8 +2624,7 @@ UintType::UintType (HirId ref, UintKind kind, std::set<HirId> refs)
UintType::UintType (HirId ref, HirId ty_ref, UintKind kind,
std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::UINT,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
uint_kind (kind)
{}
@@ -2707,8 +2701,7 @@ UintType::is_equal (const BaseType &other) const
FloatType::FloatType (HirId ref, FloatKind kind, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::FLOAT,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
float_kind (kind)
{}
@@ -2716,8 +2709,7 @@ FloatType::FloatType (HirId ref, FloatKind kind, std::set<HirId> refs)
FloatType::FloatType (HirId ref, HirId ty_ref, FloatKind kind,
std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::FLOAT,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
float_kind (kind)
{}
@@ -2788,15 +2780,13 @@ FloatType::is_equal (const BaseType &other) const
USizeType::USizeType (HirId ref, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::USIZE,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
USizeType::USizeType (HirId ref, HirId ty_ref, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::USIZE,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
@@ -2841,15 +2831,13 @@ USizeType::clone () const
ISizeType::ISizeType (HirId ref, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::ISIZE,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
ISizeType::ISizeType (HirId ref, HirId ty_ref, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::ISIZE,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
@@ -2894,15 +2882,13 @@ ISizeType::clone () const
CharType::CharType (HirId ref, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::CHAR,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
CharType::CharType (HirId ref, HirId ty_ref, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::CHAR,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
@@ -2948,8 +2934,7 @@ CharType::clone () const
ReferenceType::ReferenceType (HirId ref, TyVar base, Mutability mut,
std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::REF,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
base (base), mut (mut)
{}
@@ -2957,8 +2942,7 @@ ReferenceType::ReferenceType (HirId ref, TyVar base, Mutability mut,
ReferenceType::ReferenceType (HirId ref, HirId ty_ref, TyVar base,
Mutability mut, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::REF,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
base (base), mut (mut)
{}
@@ -3106,8 +3090,7 @@ ReferenceType::handle_substitions (SubstitutionArgumentMappings &mappings)
PointerType::PointerType (HirId ref, TyVar base, Mutability mut,
std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::POINTER,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
base (base), mut (mut)
{}
@@ -3115,8 +3098,7 @@ PointerType::PointerType (HirId ref, TyVar base, Mutability mut,
PointerType::PointerType (HirId ref, HirId ty_ref, TyVar base, Mutability mut,
std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::POINTER,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
base (base), mut (mut)
{}
@@ -3446,15 +3428,13 @@ ParamType::is_implicit_self_trait () const
StrType::StrType (HirId ref, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::STR,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
StrType::StrType (HirId ref, HirId ty_ref, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::STR,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
@@ -3505,15 +3485,13 @@ StrType::is_equal (const BaseType &other) const
NeverType::NeverType (HirId ref, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::NEVER,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
NeverType::NeverType (HirId ref, HirId ty_ref, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::NEVER,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs)
{}
@@ -3559,8 +3537,7 @@ NeverType::clone () const
PlaceholderType::PlaceholderType (std::string symbol, HirId ref,
std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::PLACEHOLDER,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
symbol (symbol)
{}
@@ -3568,8 +3545,7 @@ PlaceholderType::PlaceholderType (std::string symbol, HirId ref,
PlaceholderType::PlaceholderType (std::string symbol, HirId ref, HirId ty_ref,
std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::PLACEHOLDER,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
symbol (symbol)
{}
@@ -3674,8 +3650,7 @@ ProjectionType::ProjectionType (
std::vector<SubstitutionParamMapping> subst_refs,
SubstitutionArgumentMappings generic_arguments, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::PROJECTION,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
SubstitutionRef (std::move (subst_refs), std::move (generic_arguments)),
base (base), trait (trait), item (item)
@@ -3687,8 +3662,7 @@ ProjectionType::ProjectionType (
std::vector<SubstitutionParamMapping> subst_refs,
SubstitutionArgumentMappings generic_arguments, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::PROJECTION,
- {Resolver::CanonicalPath::create_empty (),
- Linemap::predeclared_location ()},
+ {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
refs),
SubstitutionRef (std::move (subst_refs), std::move (generic_arguments)),
base (base), trait (trait), item (item)