aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-session-manager.cc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-03 11:54:19 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:49:34 +0100
commit1678cdd3aac83c3e255e4395c12a9d7dff350a70 (patch)
tree11264b9115ca4a301098a48b403a0a6fa8a9e122 /gcc/rust/rust-session-manager.cc
parent030786a9680b0206480ebda372c1fb5d2aa19a59 (diff)
downloadgcc-1678cdd3aac83c3e255e4395c12a9d7dff350a70.zip
gcc-1678cdd3aac83c3e255e4395c12a9d7dff350a70.tar.gz
gcc-1678cdd3aac83c3e255e4395c12a9d7dff350a70.tar.bz2
gccrs: Replace value initialization of Location with UNDEF_LOCATION
gcc/rust/ChangeLog: * rust-location.h (UNDEF_LOCATION): New. * ast/rust-ast-collector.cc: Replace Location () with UNDEF_LOCATION. * ast/rust-ast-fragment.cc: Likewise. * ast/rust-ast.h: Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.h: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.h: Likewise. * backend/rust-compile.cc: Likewise. * backend/rust-constexpr.cc: Likewise. * expand/rust-expand-visitor.cc: Likewise. * expand/rust-macro-expand.cc: Likewise. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro.cc: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-lex.cc: Likewise. * metadata/rust-export-metadata.cc: Likewise. * parse/rust-parse-impl.h: Likewise. * resolve/rust-ast-resolve-item.cc: Likewise. * resolve/rust-ast-resolve.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-session-manager.cc: Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-coercion.cc: Likewise. * typecheck/rust-hir-dot-operator.cc: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-trait-reference.cc: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-hir-type-check-expr.cc: Likewise. * typecheck/rust-hir-type-check-implitem.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. * util/rust-hir-map.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r--gcc/rust/rust-session-manager.cc40
1 files changed, 21 insertions, 19 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index aaf19f3..e524bc3 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -115,12 +115,12 @@ validate_crate_name (const std::string &crate_name, Error &error)
{
if (crate_name.empty ())
{
- error = Error (Location (), "crate name cannot be empty");
+ error = Error (UNDEF_LOCATION, "crate name cannot be empty");
return false;
}
if (crate_name.length () > kMaxNameLength)
{
- error = Error (Location (), "crate name cannot exceed %lu characters",
+ error = Error (UNDEF_LOCATION, "crate name cannot exceed %lu characters",
(unsigned long) kMaxNameLength);
return false;
}
@@ -128,7 +128,7 @@ validate_crate_name (const std::string &crate_name, Error &error)
{
if (!(ISALNUM (c) || c == '_'))
{
- error = Error (Location (),
+ error = Error (UNDEF_LOCATION,
"invalid character %<%c%> in crate name: %<%s%>", c,
crate_name.c_str ());
return false;
@@ -197,7 +197,7 @@ Session::handle_option (
// set the crate name
if (arg != nullptr)
{
- auto error = Error (Location (), std::string ());
+ auto error = Error (UNDEF_LOCATION, std::string ());
if ((ret = validate_crate_name (arg, error)))
{
options.set_crate_name (arg);
@@ -276,7 +276,7 @@ Session::handle_cfg_option (std::string &input)
if (!parse_cfg_option (input, key, value))
{
rust_error_at (
- Location (),
+ UNDEF_LOCATION,
"invalid argument to %<-frust-cfg%>: Accepted formats are "
"%<-frust-cfg=key%> or %<-frust-cfg=key=\"value\"%> (quoted)");
return false;
@@ -299,7 +299,7 @@ Session::enable_dump (std::string arg)
if (arg.empty ())
{
rust_error_at (
- Location (),
+ UNDEF_LOCATION,
"dump option was not given a name. choose %<lex%>, %<ast-pretty%>, "
"%<register_plugins%>, %<injection%>, "
"%<expansion%>, %<resolution%>, %<target_options%>, %<hir%>, "
@@ -350,7 +350,7 @@ Session::enable_dump (std::string arg)
else
{
rust_error_at (
- Location (),
+ UNDEF_LOCATION,
"dump option %qs was unrecognised. choose %<lex%>, %<ast-pretty%>, "
"%<register_plugins%>, %<injection%>, "
"%<expansion%>, %<resolution%>, %<target_options%>, %<hir%>, "
@@ -367,7 +367,7 @@ void
Session::handle_input_files (int num_files, const char **files)
{
if (num_files != 1)
- rust_fatal_error (Location (),
+ rust_fatal_error (UNDEF_LOCATION,
"only one file may be specified on the command line");
const auto &file = files[0];
@@ -397,7 +397,7 @@ Session::handle_crate_name (const AST::Crate &parsed_crate)
{
auto mappings = Analysis::Mappings::get ();
auto crate_name_changed = false;
- auto error = Error (Location (), std::string ());
+ auto error = Error (UNDEF_LOCATION, std::string ());
for (const auto &attr : parsed_crate.inner_attrs)
{
@@ -450,7 +450,7 @@ Session::compile_crate (const char *filename)
if (!flag_rust_experimental
&& !std::getenv ("GCCRS_INCOMPLETE_AND_EXPERIMENTAL_COMPILER_DO_NOT_USE"))
rust_fatal_error (
- Location (), "%s",
+ UNDEF_LOCATION, "%s",
"gccrs is not yet able to compile Rust code "
"properly. Most of the errors produced will be gccrs' fault and not the "
"crate you are trying to compile. Because of this, please reports issues "
@@ -472,7 +472,7 @@ Session::compile_crate (const char *filename)
RAIIFile file_wrap (filename);
if (!file_wrap.ok ())
{
- rust_error_at (Location (), "cannot open filename %s: %m", filename);
+ rust_error_at (UNDEF_LOCATION, "cannot open filename %s: %m", filename);
return;
}
@@ -795,7 +795,8 @@ Session::injection (AST::Crate &crate)
{
// create "macro use" attribute for use on extern crate item to enable
// loading macros from it
- AST::Attribute attr (AST::SimplePath::from_str ("macro_use", Location ()),
+ AST::Attribute attr (AST::SimplePath::from_str ("macro_use",
+ UNDEF_LOCATION),
nullptr);
// create "extern crate" item with the name
@@ -813,20 +814,21 @@ Session::injection (AST::Crate &crate)
// FIXME: Once we do want to include the standard library, add the prelude
// use item
// std::vector<AST::SimplePathSegment> segments
- // = {AST::SimplePathSegment (injected_crate_name, Location ()),
- // AST::SimplePathSegment ("prelude", Location ()),
- // AST::SimplePathSegment ("v1", Location ())};
+ // = {AST::SimplePathSegment (injected_crate_name, UNDEF_LOCATION),
+ // AST::SimplePathSegment ("prelude", UNDEF_LOCATION),
+ // AST::SimplePathSegment ("v1", UNDEF_LOCATION)};
// // create use tree and decl
// std::unique_ptr<AST::UseTreeGlob> use_tree (
// new AST::UseTreeGlob (AST::UseTreeGlob::PATH_PREFIXED,
- // AST::SimplePath (std::move (segments)), Location ()));
+ // AST::SimplePath (std::move (segments)),
+ // UNDEF_LOCATION));
// AST::Attribute prelude_attr (AST::SimplePath::from_str ("prelude_import",
- // Location ()),
+ // UNDEF_LOCATION),
// nullptr);
// std::unique_ptr<AST::UseDeclaration> use_decl (
// new AST::UseDeclaration (std::move (use_tree),
// AST::Visibility::create_error (),
- // {std::move (prelude_attr)}, Location ()));
+ // {std::move (prelude_attr)}, UNDEF_LOCATION));
// crate.items.insert (crate.items.begin (), std::move (use_decl));
@@ -1227,7 +1229,7 @@ namespace selftest {
void
rust_crate_name_validation_test (void)
{
- auto error = Rust::Error (Location (), std::string ());
+ auto error = Rust::Error (UNDEF_LOCATION, std::string ());
ASSERT_TRUE (Rust::validate_crate_name ("example", error));
ASSERT_TRUE (Rust::validate_crate_name ("abcdefg_1234", error));
ASSERT_TRUE (Rust::validate_crate_name ("1", error));