public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Allow linemap to be optional nullptr
@ 2022-07-07 11:35 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-07-07 11:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:143219798492864c8eff7fecbdb9257fa10bf4ec
commit 143219798492864c8eff7fecbdb9257fa10bf4ec
Author: Philip Herron <philip.herron@embecosm.com>
Date: Wed Jul 6 16:57:26 2022 +0100
Allow linemap to be optional nullptr
Diff:
---
gcc/rust/lex/rust-lex.cc | 20 ++++++++++++++------
gcc/rust/lex/rust-lex.h | 2 ++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 13921e70b6c..5447c72a8b1 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 429b9e129c1..b501a69a795 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-07 11:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 11:35 [gcc/devel/rust/master] Allow linemap to be optional nullptr Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).