Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startswith -> starts_with to match upstream #3519

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion toolchain/lex/lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ auto Lexer::LexCommentOrSlash(llvm::StringRef source_text, ssize_t& position)
}

auto Lexer::LexComment(llvm::StringRef source_text, ssize_t& position) -> void {
CARBON_DCHECK(source_text.substr(position).startswith("//"));
CARBON_DCHECK(source_text.substr(position).starts_with("//"));

// Any comment must be the only non-whitespace on the line.
const auto* line_info = current_line_info();
Expand Down
2 changes: 1 addition & 1 deletion toolchain/lex/numeric_literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ auto NumericLiteral::Parser::CheckDigitSeparatorPlacement(

// Check that we don't have a '0' prefix on a non-zero decimal integer.
auto NumericLiteral::Parser::CheckLeadingZero() -> bool {
if (radix_ == Radix::Decimal && int_part_.startswith("0") &&
if (radix_ == Radix::Decimal && int_part_.starts_with("0") &&
int_part_ != "0") {
CARBON_DIAGNOSTIC(UnknownBaseSpecifier, Error,
"Unknown base specifier in numeric literal.");
Expand Down
10 changes: 5 additions & 5 deletions toolchain/lex/string_literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ auto StringLiteral::Introducer::Lex(llvm::StringRef source_text)
-> std::optional<Introducer> {
MultiLineKind kind = NotMultiLine;
llvm::StringRef indicator;
if (source_text.startswith(MultiLineIndicator)) {
if (source_text.starts_with(MultiLineIndicator)) {
kind = MultiLine;
indicator = llvm::StringRef(MultiLineIndicator);
} else if (source_text.startswith(DoubleQuotedMultiLineIndicator)) {
} else if (source_text.starts_with(DoubleQuotedMultiLineIndicator)) {
kind = MultiLineWithDoubleQuotes;
indicator = llvm::StringRef(DoubleQuotedMultiLineIndicator);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ auto StringLiteral::Lex(llvm::StringRef source_text)
break;
case '\\':
if (escape.size() == 1 ||
source_text.substr(cursor + 1).startswith(escape.substr(1))) {
source_text.substr(cursor + 1).starts_with(escape.substr(1))) {
content_needs_validation = true;
cursor += escape.size();
// If there's either not a character following the escape, or it's a
Expand All @@ -162,7 +162,7 @@ auto StringLiteral::Lex(llvm::StringRef source_text)
break;
case '"':
case '\'':
if (source_text.substr(cursor).startswith(terminator)) {
if (source_text.substr(cursor).starts_with(terminator)) {
llvm::StringRef text =
source_text.substr(0, cursor + terminator.size());
llvm::StringRef content =
Expand Down Expand Up @@ -379,7 +379,7 @@ static auto ExpandEscapeSequencesAndRemoveIndent(
if (!contents.consume_front(indent)) {
const char* line_start = contents.begin();
contents = contents.drop_while(IsHorizontalWhitespace);
if (!contents.startswith("\n")) {
if (!contents.starts_with("\n")) {
CARBON_DIAGNOSTIC(
MismatchedIndentInString, Error,
"Indentation does not match that of the closing `'''` in "
Expand Down
Loading