Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/regular_expre…
Browse files Browse the repository at this point in the history
…ssion_metafunction
  • Loading branch information
MaxSagebaum committed Jul 15, 2024
2 parents b99d10e + 8168a2d commit 788cf3d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
6 changes: 3 additions & 3 deletions include/cpp2util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion regression-tests/test-results/version
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/build.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"9713:1156"
"9714:0930"
6 changes: 3 additions & 3 deletions source/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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)+"\"";
Expand Down
18 changes: 8 additions & 10 deletions source/lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1328,7 +1328,7 @@ auto lex_line(
comment::comment_kind::line_comment,
{lineno, i},
{lineno, _as<colno_t>(std::ssize(line))},
std::string(&line[i], std::ssize(line) - i)
line.substr(i)
});
in_comment = false;
goto END;
Expand Down Expand Up @@ -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)+"\"";

Expand Down Expand Up @@ -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 \""
);
}
Expand Down Expand Up @@ -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') {
Expand All @@ -1593,7 +1592,6 @@ auto lex_line(
source_position(lineno, i),
"hexadecimal literal cannot be empty (0X must be followed by hexadecimal digits)"
);
++i;
}
}
}
Expand Down Expand Up @@ -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)+"\"";

Expand All @@ -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 \""
);
}
Expand All @@ -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 \""
);
}
Expand Down Expand Up @@ -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 '"
);
}
Expand Down
2 changes: 1 addition & 1 deletion source/reflect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/reflect.h2
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
14 changes: 7 additions & 7 deletions source/to_cpp1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<colno_t>(s.length() - last_newline);
}
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
)
)
{
Expand Down

0 comments on commit 788cf3d

Please sign in to comment.