diff --git a/include/cpp2util.h b/include/cpp2util.h index f49c5ad137..c86487f54b 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -762,20 +762,20 @@ constexpr auto process_type_name(std::string_view name) -> std::string_view { constexpr auto types_close_parenthesis = '>'; #endif auto pos = name.find(type_prefix); - if (pos != std::string_view::npos) { + if (pos != name.npos) { name = name.substr(pos); name.remove_prefix(type_prefix.size()); } pos = name.find_last_of(types_close_parenthesis); - if (pos != std::string_view::npos) { + if (pos != name.npos) { name = name.substr(0, pos); } #if defined(__GNUC__) constexpr auto type_separator = ';'; pos = name.find(type_separator); - if (pos != std::string_view::npos) { + if (pos != name.npos) { name = name.substr(0, pos); } #endif diff --git a/regression-tests/test-results/version b/regression-tests/test-results/version index 3762666fd7..4de8ceb0bd 100644 --- a/regression-tests/test-results/version +++ b/regression-tests/test-results/version @@ -1,5 +1,5 @@ -cppfront compiler v0.7.1 Build 9713:1156 +cppfront compiler v0.7.1 Build 9714:0930 Copyright(c) Herb Sutter All rights reserved SPDX-License-Identifier: CC-BY-NC-ND-4.0 diff --git a/source/build.info b/source/build.info index ffaf154fa4..6840219ea7 100644 --- a/source/build.info +++ b/source/build.info @@ -1 +1 @@ -"9713:1156" \ No newline at end of file +"9714:0930" \ No newline at end of file diff --git a/source/io.h b/source/io.h index e15316057b..35933d9172 100644 --- a/source/io.h +++ b/source/io.h @@ -175,7 +175,7 @@ auto starts_with_whitespace_slash_star_and_no_star_slash(std::string const& line && line[i + 1] == '*' ) { - return line.find("*/", i) == std::string::npos; + return line.find("*/", i) == line.npos; } else { return false; @@ -604,7 +604,7 @@ auto process_cpp_line( } else if (in_raw_string_literal) { auto end_pos = line.find(raw_string_closing_seq, i); - if (end_pos == std::string::npos) { + if (end_pos == line.npos) { return r; } in_raw_string_literal = false; @@ -626,7 +626,7 @@ auto process_cpp_line( if (i < ssize(line) - 1) { if (auto paren_pos = line.find("(", i); - paren_pos != std::string::npos + paren_pos != line.npos ) { raw_string_closing_seq = ")"+line.substr(i, paren_pos-i)+"\""; diff --git a/source/lex.h b/source/lex.h index 401789b0f5..4e9c3fcded 100644 --- a/source/lex.h +++ b/source/lex.h @@ -1267,7 +1267,7 @@ auto lex_line( // raw string was not expanded raw_string_multiline.value().text += part; - if (end_pos == std::string::npos) { + if (end_pos == line.npos) { raw_string_multiline.value().text += '\n'; break; } @@ -1328,7 +1328,7 @@ auto lex_line( comment::comment_kind::line_comment, {lineno, i}, {lineno, _as(std::ssize(line))}, - std::string(&line[i], std::ssize(line) - i) + line.substr(i) }); in_comment = false; goto END; @@ -1484,7 +1484,7 @@ auto lex_line( auto R_pos = i + 1; auto seq_pos = i + 3; - if (auto paren_pos = line.find("(", seq_pos); paren_pos != std::string::npos) { + if (auto paren_pos = line.find("(", seq_pos); paren_pos != line.npos) { auto opening_seq = line.substr(i, paren_pos - i + 1); auto closing_seq = ")"+line.substr(seq_pos, paren_pos-seq_pos)+"\""; @@ -1532,7 +1532,7 @@ auto lex_line( else { errors.emplace_back( source_position(lineno, i + 1), - "invalid new-line in raw string delimiter \"" + std::string(&line[i],3) + "invalid new-line in raw string delimiter \"" + line.substr(i, 3) + "\" - stray 'R' in program \"" ); } @@ -1579,7 +1579,6 @@ auto lex_line( source_position(lineno, i), "binary literal cannot be empty (0B must be followed by binary digits)" ); - ++i; } } else if (peek1 == 'x' || peek1 == 'X') { @@ -1593,7 +1592,6 @@ auto lex_line( source_position(lineno, i), "hexadecimal literal cannot be empty (0X must be followed by hexadecimal digits)" ); - ++i; } } } @@ -1703,7 +1701,7 @@ auto lex_line( if (peek(j-2) == 'R') { auto seq_pos = i + j; - if (auto paren_pos = line.find("(", seq_pos); paren_pos != std::string::npos) { + if (auto paren_pos = line.find("(", seq_pos); paren_pos != line.npos) { auto opening_seq = line.substr(i, paren_pos - i + 1); auto closing_seq = ")"+line.substr(seq_pos, paren_pos-seq_pos)+"\""; @@ -1724,7 +1722,7 @@ auto lex_line( else { errors.emplace_back( source_position(lineno, i + j - 2), - "invalid new-line in raw string delimiter \"" + std::string(&line[i],j) + "invalid new-line in raw string delimiter \"" + line.substr(i, j) + "\" - stray 'R' in program \"" ); } @@ -1734,7 +1732,7 @@ auto lex_line( if (peek(j) != '\"') { errors.emplace_back( source_position(lineno, i), - "string literal \"" + std::string(&line[i+1],j) + "string literal \"" + line.substr(i+1, j) + "\" is missing its closing \"" ); } @@ -1781,7 +1779,7 @@ auto lex_line( assert (j > 1); errors.emplace_back( source_position(lineno, i), - "character literal '" + std::string(&line[i+1],j-1) + "character literal '" + line.substr(i+1, j-1) + "' is missing its closing '" ); } diff --git a/source/reflect.h b/source/reflect.h index 475ccc3fbc..c1fa92b1d4 100644 --- a/source/reflect.h +++ b/source/reflect.h @@ -881,7 +881,7 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; if ( cpp2::impl::cmp_greater(CPP2_UFCS(ssize)(source),1) && newline_pos != source.npos) { - while( newline_pos != std::string_view::npos ) + while( newline_pos != source.npos ) { add_line(CPP2_UFCS(substr)(source, 0, newline_pos)); CPP2_UFCS(remove_prefix)(source, newline_pos + 1); diff --git a/source/reflect.h2 b/source/reflect.h2 index f5161f3f83..cff4721504 100644 --- a/source/reflect.h2 +++ b/source/reflect.h2 @@ -102,7 +102,7 @@ compiler_services: @polymorphic_base @copyable type = if source.ssize() > 1 && newline_pos != source.npos { - while newline_pos != std::string_view::npos + while newline_pos != source.npos { add_line( source.substr(0, newline_pos) ); source.remove_prefix( newline_pos+1 ); diff --git a/source/to_cpp1.h b/source/to_cpp1.h index eea5cb5958..f882d0c821 100644 --- a/source/to_cpp1.h +++ b/source/to_cpp1.h @@ -343,9 +343,9 @@ class positional_printer // and where the last one was which determines our current colno if (track_curr_pos) { - auto last_newline = std::string::npos; // the last newline we found in the string + auto last_newline = s.npos; // the last newline we found in the string auto newline_pos = std::size_t(0); // the current newline we found in the string - while ((newline_pos = s.find('\n', newline_pos)) != std::string::npos) + while ((newline_pos = s.find('\n', newline_pos)) != s.npos) { // For each line break we find, reset pad and inc current lineno pad_for_this_line = 0; @@ -355,7 +355,7 @@ class positional_printer } // Now also adjust the colno - if (last_newline != std::string::npos) { + if (last_newline != s.npos) { // If we found a newline, it's the distance from the last newline to EOL curr_pos.colno = unsafe_narrow(s.length() - last_newline); } @@ -415,7 +415,7 @@ class positional_printer if (c.kind == comment::comment_kind::line_comment) { print( pad( c.start.colno - curr_pos.colno + 1 ) ); print( c.text ); - assert( c.text.find("\n") == std::string::npos ); // we shouldn't have newlines + assert( c.text.find("\n") == c.text.npos ); // we shouldn't have newlines print("\n"); } @@ -792,7 +792,7 @@ class positional_printer && newline_pos != s.npos ) { - while (newline_pos != std::string_view::npos) + while (newline_pos != s.npos) { // Print the text before the next newline if (newline_pos > 0) { @@ -4424,8 +4424,8 @@ class cppfront tparam->declaration->is_type() && ( name == tparam_name - || name.find("<"+tparam_name) != std::string_view::npos - || name.find(","+tparam_name) != std::string_view::npos + || name.find("<"+tparam_name) != name.npos + || name.find(","+tparam_name) != name.npos ) ) {