Skip to content

Commit 0d678b2

Browse files
powerboat9philberty
authored andcommitted
Move Backend::error_variable to Bvariable::error_variable
gcc/rust/ChangeLog: * rust-backend.h (Backend::error_variable): Remove. (Gcc_backend::error_variable): Move to ... * rust-gcc.cc (Bvariable::error_variable): ... here ... * rust-gcc.h (Bvariable::error_variable): ... and declare here. (Gcc_backend::global_variable): Update error_variable call. (Gcc_backend::local_variable): Likewise. (Gcc_backend::parameter_variable): Likewise. (Gcc_backend::static_chain_variable): Likewise. (Gcc_backend::temporary_variable): Likewise. * backend/rust-compile-extern.h (CompileExternItem::visit): Likewise. * backend/rust-compile-fnparam.cc (CompileFnParam::CompileFnParam): Likewise. Signed-off-by: Owen Avery <[email protected]>
1 parent 09e2333 commit 0d678b2

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

gcc/rust/backend/rust-compile-extern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CompileExternItem : public HIRCompileBase,
4848
void visit (HIR::ExternalStaticItem &item) override
4949
{
5050
// check if its already been compiled
51-
Bvariable *lookup = ctx->get_backend ()->error_variable ();
51+
Bvariable *lookup = Bvariable::error_variable ();
5252
if (ctx->lookup_var_decl (item.get_mappings ().get_hirid (), &lookup))
5353
{
5454
reference = ctx->get_backend ()->var_expression (lookup, ref_locus);

gcc/rust/backend/rust-compile-fnparam.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Compile {
2727
CompileFnParam::CompileFnParam (Context *ctx, tree fndecl, tree decl_type,
2828
location_t locus)
2929
: HIRCompileBase (ctx), fndecl (fndecl), decl_type (decl_type), locus (locus),
30-
compiled_param (ctx->get_backend ()->error_variable ())
30+
compiled_param (Bvariable::error_variable ())
3131
{}
3232

3333
Bvariable *

gcc/rust/rust-backend.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ class Backend
346346

347347
// Variables.
348348

349-
// Create an error variable. This is used for cases which should
350-
// not occur in a correct program, in order to keep the compilation
351-
// going without crashing.
352-
virtual Bvariable *error_variable () = 0;
353-
354349
// Create a global variable. NAME is the package-qualified name of
355350
// the variable. ASM_NAME is the encoded identifier for the
356351
// variable, incorporating the package, and made safe for the
@@ -655,8 +650,6 @@ class Gcc_backend : public Backend
655650

656651
// Variables.
657652

658-
Bvariable *error_variable () { return new Bvariable (error_mark_node); }
659-
660653
Bvariable *global_variable (const std::string &var_name,
661654
const std::string &asm_name, tree type,
662655
bool is_external, bool is_hidden,

gcc/rust/rust-gcc.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ Bvariable::get_tree (location_t location) const
7777
return build_fold_indirect_ref_loc (location, t);
7878
}
7979

80+
Bvariable *
81+
Bvariable::error_variable ()
82+
{
83+
return new Bvariable (error_mark_node);
84+
}
85+
8086
// This file implements the interface between the Rust frontend proper
8187
// and the gcc IR. This implements specific instantiations of
8288
// abstract classes defined by the Rust frontend proper. The Rust
@@ -2048,7 +2054,7 @@ Gcc_backend::global_variable (const std::string &var_name,
20482054
bool in_unique_section, location_t location)
20492055
{
20502056
if (type_tree == error_mark_node)
2051-
return this->error_variable ();
2057+
return Bvariable::error_variable ();
20522058

20532059
// The GNU linker does not like dynamic variables with zero size.
20542060
tree orig_type_tree = type_tree;
@@ -2113,7 +2119,7 @@ Gcc_backend::local_variable (tree function, const std::string &name,
21132119
location_t location)
21142120
{
21152121
if (type_tree == error_mark_node)
2116-
return this->error_variable ();
2122+
return Bvariable::error_variable ();
21172123
tree decl = build_decl (location, VAR_DECL, get_identifier_from_string (name),
21182124
type_tree);
21192125
DECL_CONTEXT (decl) = function;
@@ -2134,7 +2140,7 @@ Gcc_backend::parameter_variable (tree function, const std::string &name,
21342140
tree type_tree, location_t location)
21352141
{
21362142
if (type_tree == error_mark_node)
2137-
return this->error_variable ();
2143+
return Bvariable::error_variable ();
21382144
tree decl = build_decl (location, PARM_DECL,
21392145
get_identifier_from_string (name), type_tree);
21402146
DECL_CONTEXT (decl) = function;
@@ -2151,7 +2157,7 @@ Gcc_backend::static_chain_variable (tree fndecl, const std::string &name,
21512157
tree type_tree, location_t location)
21522158
{
21532159
if (type_tree == error_mark_node)
2154-
return this->error_variable ();
2160+
return Bvariable::error_variable ();
21552161
tree decl = build_decl (location, PARM_DECL,
21562162
get_identifier_from_string (name), type_tree);
21572163
DECL_CONTEXT (decl) = fndecl;
@@ -2188,7 +2194,7 @@ Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree,
21882194
|| fndecl == error_mark_node)
21892195
{
21902196
*pstatement = error_mark_node;
2191-
return this->error_variable ();
2197+
return Bvariable::error_variable ();
21922198
}
21932199

21942200
tree var;

gcc/rust/rust-gcc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class Bvariable
4949
// Get the actual decl;
5050
tree get_decl () const { return this->t_; }
5151

52+
// Create an error variable. This is used for cases which should
53+
// not occur in a correct program, in order to keep the compilation
54+
// going without crashing.
55+
static Bvariable *error_variable ();
56+
5257
private:
5358
tree t_;
5459
tree orig_type_;

0 commit comments

Comments
 (0)