aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-07-05 21:27:51 +0200
committerMark Wielaard <mark@klomp.org>2021-07-05 21:27:51 +0200
commit94ada647bf35c727c17ade60d06af6803a7e5668 (patch)
tree6e3a1c42920a2dd59c1509c92dba376e51a1ffa4
parent29192293fdce8b3cf4888bbe0d5f504655e26cd5 (diff)
downloadgcc-94ada647bf35c727c17ade60d06af6803a7e5668.zip
gcc-94ada647bf35c727c17ade60d06af6803a7e5668.tar.gz
gcc-94ada647bf35c727c17ade60d06af6803a7e5668.tar.bz2
Remove has_utf8bom flag from AST and HIR Crate classes
The lexer deals with the UTF-8 BOM and the parser cannot detect whether there is or isn't a BOM at the start of a file. The flag isn't relevant or useful in the AST and HIR Crate classes.
-rw-r--r--gcc/rust/ast/rust-ast-full-test.cc3
-rw-r--r--gcc/rust/ast/rust-ast.h11
-rw-r--r--gcc/rust/hir/rust-ast-lower.cc4
-rw-r--r--gcc/rust/hir/tree/rust-hir-full-test.cc5
-rw-r--r--gcc/rust/hir/tree/rust-hir.h12
-rw-r--r--gcc/rust/parse/rust-parse-impl.h8
6 files changed, 9 insertions, 34 deletions
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc
index 12ef255..dd55e1d 100644
--- a/gcc/rust/ast/rust-ast-full-test.cc
+++ b/gcc/rust/ast/rust-ast-full-test.cc
@@ -172,9 +172,6 @@ Crate::as_string () const
rust_debug ("beginning crate recursive as-string");
std::string str ("Crate: ");
- // add utf8bom
- if (has_utf8bom)
- str += "\n has utf8bom";
// inner attributes
str += append_attributes (inner_attrs, INNER);
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index ce55e1b..75b08f8 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1550,8 +1550,6 @@ protected:
// A crate AST object - holds all the data for a single compilation unit
struct Crate
{
- bool has_utf8bom;
-
std::vector<Attribute> inner_attrs;
// dodgy spacing required here
/* TODO: is it better to have a vector of items here or a module (implicit
@@ -1563,16 +1561,14 @@ struct Crate
public:
// Constructor
Crate (std::vector<std::unique_ptr<Item> > items,
- std::vector<Attribute> inner_attrs, bool has_utf8bom = false)
- : has_utf8bom (has_utf8bom), inner_attrs (std::move (inner_attrs)),
- items (std::move (items)),
+ std::vector<Attribute> inner_attrs)
+ : inner_attrs (std::move (inner_attrs)), items (std::move (items)),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
// Copy constructor with vector clone
Crate (Crate const &other)
- : has_utf8bom (other.has_utf8bom), inner_attrs (other.inner_attrs),
- node_id (other.node_id)
+ : inner_attrs (other.inner_attrs), node_id (other.node_id)
{
items.reserve (other.items.size ());
for (const auto &e : other.items)
@@ -1585,7 +1581,6 @@ public:
Crate &operator= (Crate const &other)
{
inner_attrs = other.inner_attrs;
- has_utf8bom = other.has_utf8bom;
node_id = other.node_id;
items.reserve (other.items.size ());
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index 0f3c86d..01abd84 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -40,7 +40,6 @@ HIR::Crate
ASTLowering::go ()
{
std::vector<std::unique_ptr<HIR::Item> > items;
- bool has_utf8bom = false;
for (auto it = astCrate.items.begin (); it != astCrate.items.end (); it++)
{
@@ -55,8 +54,7 @@ ASTLowering::go ()
mappings->get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- return HIR::Crate (std::move (items), astCrate.get_inner_attrs (), mapping,
- has_utf8bom);
+ return HIR::Crate (std::move (items), astCrate.get_inner_attrs (), mapping);
}
// rust-ast-lower-block.h
diff --git a/gcc/rust/hir/tree/rust-hir-full-test.cc b/gcc/rust/hir/tree/rust-hir-full-test.cc
index 051ba87..05c75e0 100644
--- a/gcc/rust/hir/tree/rust-hir-full-test.cc
+++ b/gcc/rust/hir/tree/rust-hir-full-test.cc
@@ -73,11 +73,6 @@ std::string
Crate::as_string () const
{
std::string str ("HIR::Crate: ");
- // add utf8bom
- if (has_utf8bom)
- {
- str += "\n has utf8bom";
- }
// inner attributes
str += "\n inner attributes: ";
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index f918f2d..1819d17 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -678,8 +678,6 @@ public:
// A crate HIR object - holds all the data for a single compilation unit
struct Crate
{
- bool has_utf8bom;
-
AST::AttrVec inner_attrs;
// dodgy spacing required here
/* TODO: is it better to have a vector of items here or a module (implicit
@@ -691,15 +689,14 @@ struct Crate
public:
// Constructor
Crate (std::vector<std::unique_ptr<Item> > items, AST::AttrVec inner_attrs,
- Analysis::NodeMapping mappings, bool has_utf8bom = false)
- : has_utf8bom (has_utf8bom), inner_attrs (std::move (inner_attrs)),
- items (std::move (items)), mappings (mappings)
+ Analysis::NodeMapping mappings)
+ : inner_attrs (std::move (inner_attrs)), items (std::move (items)),
+ mappings (mappings)
{}
// Copy constructor with vector clone
Crate (Crate const &other)
- : has_utf8bom (other.has_utf8bom), inner_attrs (other.inner_attrs),
- mappings (other.mappings)
+ : inner_attrs (other.inner_attrs), mappings (other.mappings)
{
items.reserve (other.items.size ());
for (const auto &e : other.items)
@@ -712,7 +709,6 @@ public:
Crate &operator= (Crate const &other)
{
inner_attrs = other.inner_attrs;
- has_utf8bom = other.has_utf8bom;
mappings = other.mappings;
items.reserve (other.items.size ());
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 136b343..a8597fa 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -393,12 +393,6 @@ template <typename ManagedTokenSource>
AST::Crate
Parser<ManagedTokenSource>::parse_crate ()
{
- /* TODO: determine if has utf8bom. Currently, is eliminated
- * by the lexing phase. Not useful for the compiler anyway, so maybe a
- * better idea would be to eliminate
- * the has_utf8bom variable from the crate data structure. */
- bool has_utf8bom = false;
-
// parse inner attributes
AST::AttrVec inner_attrs = parse_inner_attributes ();
@@ -429,7 +423,7 @@ Parser<ManagedTokenSource>::parse_crate ()
for (const auto &error : error_table)
error.emit_error ();
- return AST::Crate (std::move (items), std::move (inner_attrs), has_utf8bom);
+ return AST::Crate (std::move (items), std::move (inner_attrs));
}
// Parse a contiguous block of inner attributes.