aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-07-06 16:57:26 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-07-06 17:35:55 +0100
commit143219798492864c8eff7fecbdb9257fa10bf4ec (patch)
tree6508b9ec7c6becf40f397c4f03514f6ba31c3bbb
parent29d594e263f0ccbcbd2babf43ff453c5188f4f2c (diff)
downloadgcc-143219798492864c8eff7fecbdb9257fa10bf4ec.zip
gcc-143219798492864c8eff7fecbdb9257fa10bf4ec.tar.gz
gcc-143219798492864c8eff7fecbdb9257fa10bf4ec.tar.bz2
Allow linemap to be optional nullptr
-rw-r--r--gcc/rust/lex/rust-lex.cc20
-rw-r--r--gcc/rust/lex/rust-lex.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 13921e7..5447c72 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -347,7 +347,7 @@ Lexer::build_token ()
current_line++;
current_column = 1;
// tell line_table that new line starts
- line_map->start_line (current_line, max_column_hint);
+ start_line (current_line, max_column_hint);
break;
}
else
@@ -368,7 +368,7 @@ Lexer::build_token ()
current_line++;
current_column = 1;
// tell line_table that new line starts
- line_map->start_line (current_line, max_column_hint);
+ start_line (current_line, max_column_hint);
continue;
case '\r': // cr
// Ignore, we expect a newline (lf) soon.
@@ -540,7 +540,7 @@ Lexer::build_token ()
current_line++;
current_column = 1;
// tell line_table that new line starts
- line_map->start_line (current_line, max_column_hint);
+ start_line (current_line, max_column_hint);
str.shrink_to_fit ();
if (is_inner)
@@ -617,7 +617,7 @@ Lexer::build_token ()
current_line++;
current_column = 1;
// tell line_table that new line starts
- line_map->start_line (current_line, max_column_hint);
+ start_line (current_line, max_column_hint);
continue;
}
@@ -686,7 +686,7 @@ Lexer::build_token ()
current_line++;
current_column = 1;
// tell line_table that new line starts
- line_map->start_line (current_line, max_column_hint);
+ start_line (current_line, max_column_hint);
str += '\n';
continue;
}
@@ -1400,7 +1400,7 @@ Lexer::parse_partial_string_continue ()
current_line++;
current_column = 1;
// tell line_table that new line starts
- line_map->start_line (current_line, max_column_hint);
+ start_line (current_line, max_column_hint);
// reset "length"
additional_length_offset = 1;
@@ -2688,4 +2688,12 @@ Lexer::split_current_token (TokenId new_left, TokenId new_right)
token_queue.replace_current_value (std::move (new_left_tok));
token_queue.insert (1, std::move (new_right_tok));
}
+
+void
+Lexer::start_line (int current_line, int current_column)
+{
+ if (line_map)
+ line_map->start_line (current_line, current_column);
+}
+
} // namespace Rust
diff --git a/gcc/rust/lex/rust-lex.h b/gcc/rust/lex/rust-lex.h
index 429b9e1..b501a69 100644
--- a/gcc/rust/lex/rust-lex.h
+++ b/gcc/rust/lex/rust-lex.h
@@ -205,6 +205,8 @@ public:
std::string get_filename () { return std::string (input.get_filename ()); }
private:
+ void start_line (int current_line, int current_column);
+
// File for use as input.
RAIIFile input;
// TODO is this actually required? could just have file storage in InputSource