@@ -199,7 +199,7 @@ auto _as(lexeme l)
199
199
break ;case lexeme::None: return " (NONE)" ;
200
200
break ;default : return " INTERNAL-ERROR" ;
201
201
}
202
- };
202
+ }
203
203
204
204
205
205
auto is_operator (lexeme l)
@@ -286,13 +286,13 @@ class token
286
286
pos.colno += offset;
287
287
}
288
288
289
- auto position () const -> source_position { return pos; }
289
+ auto position () const -> source_position { return pos; }
290
290
291
- auto length () const -> int { return sv.size (); }
291
+ auto length () const -> int { return unsafe_narrow< int >( sv.size () ); }
292
292
293
- auto type () const -> lexeme { return lex_type; }
293
+ auto type () const -> lexeme { return lex_type; }
294
294
295
- auto set_type (lexeme l) -> void { lex_type = l; }
295
+ auto set_type (lexeme l) -> void { lex_type = l; }
296
296
297
297
auto visit (auto & v, int depth) const
298
298
-> void
@@ -307,7 +307,7 @@ class token
307
307
)
308
308
{
309
309
sv.remove_prefix (prefix.size ());
310
- pos.colno += prefix.size ();
310
+ pos.colno += unsafe_narrow< colno_t >( prefix.size () );
311
311
}
312
312
}
313
313
@@ -816,7 +816,7 @@ auto lex_line(
816
816
source_position (lineno, i + 1 ),
817
817
type
818
818
});
819
- i += num-1 ;
819
+ i += unsafe_narrow< int >( num-1 ) ;
820
820
821
821
merge_cpp1_multi_token_fundamental_type_names ();
822
822
merge_operator_function_names ();
@@ -1066,7 +1066,7 @@ auto lex_line(
1066
1066
auto parts = expand_raw_string_literal (opening_seq, closing_seq, closing_strategy, part, errors, source_position (lineno, pos_to_replace + 1 ));
1067
1067
auto new_part = parts.generate ();
1068
1068
mutable_line.replace ( pos_to_replace, size_to_replace, new_part );
1069
- i += std::ssize (new_part)-1 ;
1069
+ i += unsafe_narrow< colno_t >( std::ssize (new_part)-1 ) ;
1070
1070
1071
1071
if (parts.is_expanded ()) {
1072
1072
// raw string was expanded and we need to repeat the processing of this line
@@ -1147,7 +1147,7 @@ auto lex_line(
1147
1147
auto closing_strategy = end_pos == line.npos ? string_parts::no_ends : string_parts::on_the_end;
1148
1148
auto size_to_replace = end_pos == line.npos ? std::ssize (line) - i : end_pos - i + std::ssize (rsm.closing_seq );
1149
1149
1150
- if (interpolate_raw_string (rsm.opening_seq , rsm.closing_seq , closing_strategy, part, i, size_to_replace ) ) {
1150
+ if (interpolate_raw_string (rsm.opening_seq , rsm.closing_seq , closing_strategy, part, i, unsafe_narrow< int >( size_to_replace) ) ) {
1151
1151
continue ;
1152
1152
}
1153
1153
}
@@ -1164,7 +1164,7 @@ auto lex_line(
1164
1164
raw_string_multiline.value ().text += raw_string_multiline.value ().closing_seq ;
1165
1165
1166
1166
// and position where multiline_raw_string ends (needed for reseting line parsing)
1167
- i = end_pos+std::ssize (raw_string_multiline.value ().closing_seq )-1 ;
1167
+ i = unsafe_narrow< colno_t >( end_pos+std::ssize (raw_string_multiline.value ().closing_seq )-1 ) ;
1168
1168
1169
1169
const auto & text = raw_string_multiline.value ().should_interpolate ? raw_string_multiline.value ().text .substr (1 ) : raw_string_multiline.value ().text ;
1170
1170
multiline_raw_strings.emplace_back (multiline_raw_string{ text, {lineno, i} });
@@ -1379,7 +1379,9 @@ auto lex_line(
1379
1379
opening_seq,
1380
1380
closing_seq,
1381
1381
string_parts::on_both_ends,
1382
- std::string_view (&line[paren_pos+1 ], closing_pos-paren_pos-1 ), i, closing_pos-i+std::ssize (closing_seq))
1382
+ std::string_view (&line[paren_pos+1 ], closing_pos-paren_pos-1 ),
1383
+ i,
1384
+ unsafe_narrow<int >(closing_pos-i+std::ssize (closing_seq)))
1383
1385
) {
1384
1386
continue ;
1385
1387
}
@@ -1397,12 +1399,14 @@ auto lex_line(
1397
1399
opening_seq,
1398
1400
closing_seq,
1399
1401
string_parts::on_the_beginning,
1400
- std::string_view (&line[paren_pos+1 ], std::ssize (line)-(paren_pos+1 )), i, std::ssize (line)-i)
1402
+ std::string_view (&line[paren_pos+1 ], std::ssize (line)-(paren_pos+1 )),
1403
+ i,
1404
+ unsafe_narrow<int >(std::ssize (line)-i))
1401
1405
) {
1402
1406
continue ;
1403
1407
}
1404
1408
// skip entire raw string opening sequence R"
1405
- i = paren_pos;
1409
+ i = unsafe_narrow< int >( paren_pos) ;
1406
1410
1407
1411
// if we are on the end of the line we need to add new line char
1408
1412
if (i+1 == std::ssize (line)) {
@@ -1594,7 +1598,7 @@ auto lex_line(
1594
1598
} else {
1595
1599
raw_string_multiline.emplace (raw_string{source_position{lineno, i}, opening_seq, opening_seq, closing_seq });
1596
1600
// skip entire raw string opening sequence R"
1597
- i = paren_pos;
1601
+ i = unsafe_narrow< int >( paren_pos) ;
1598
1602
1599
1603
// if we are on the end of the line we need to add new line char
1600
1604
if (i+1 == std::ssize (line)) {
@@ -1842,7 +1846,7 @@ class tokens
1842
1846
1843
1847
// Create new map entry for the section starting at this line,
1844
1848
// and populate its tokens with the tokens in this section
1845
- auto lineno = std::distance (std::begin (lines), line);
1849
+ auto lineno = unsafe_narrow< lineno_t >( std::distance (std::begin (lines), line) );
1846
1850
1847
1851
// If this is generated code, use negative line numbers to
1848
1852
// inform and assist the printer
0 commit comments