Skip to content

Commit 9779c18

Browse files
committed
Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` - `StringRef::startswith` is deprecated on tip. `SmallString::startswith` was just renamed there (maybe with some small deprecation inbetween, but if so, we've missed it). The `SmallString::startswith` references were moved to `.str().starts_with()`, rather than adding the `starts_with` on `stable/20230725` as we only had a few of them. Open to switching that over if anyone feels strongly though.
1 parent 495a177 commit 9779c18

File tree

113 files changed

+276
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+276
-276
lines changed

include/swift/ABI/ObjectFile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
6060
}
6161

6262
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
63-
return sectionName.startswith("__swift5_") || sectionName == "__const";
63+
return sectionName.starts_with("__swift5_") || sectionName == "__const";
6464
}
6565
};
6666

@@ -79,7 +79,7 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
7979
}
8080

8181
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
82-
return sectionName.startswith("swift5_");
82+
return sectionName.starts_with("swift5_");
8383
}
8484
};
8585

@@ -98,7 +98,7 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
9898
}
9999

100100
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
101-
return sectionName.startswith(".sw5");
101+
return sectionName.starts_with(".sw5");
102102
}
103103
};
104104
} // namespace swift

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class SDKNodeDecl: public SDKNode {
382382
swift::ReferenceOwnership getReferenceOwnership() const {
383383
return swift::ReferenceOwnership(ReferenceOwnership);
384384
}
385-
bool isObjc() const { return Usr.startswith("c:"); }
385+
bool isObjc() const { return Usr.starts_with("c:"); }
386386
static bool classof(const SDKNode *N);
387387
DeclKind getDeclKind() const { return DKind; }
388388
void printFullyQualifiedName(llvm::raw_ostream &OS) const;

include/swift/AST/ASTPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class ASTPrinter {
232232
void printKeyword(StringRef name,
233233
const PrintOptions &Opts,
234234
StringRef Suffix = "") {
235-
if (Opts.SkipUnderscoredKeywords && name.startswith("_"))
235+
if (Opts.SkipUnderscoredKeywords && name.starts_with("_"))
236236
return;
237237
assert(!name.empty() && "Tried to print empty keyword");
238238
callPrintNamePre(PrintNameContext::Keyword);

include/swift/AST/Identifier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ class Identifier {
174174
}
175175

176176
bool hasDollarPrefix() const {
177-
return str().startswith("$") && !(getLength() == 1);
177+
return str().starts_with("$") && !(getLength() == 1);
178178
}
179179

180180
bool hasUnderscoredNaming() const {
181-
return str().startswith("_");
181+
return str().starts_with("_");
182182
}
183183

184184
const void *getAsOpaquePointer() const {

include/swift/AST/RawComment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct SingleRawComment {
5757
}
5858

5959
bool isGyb() const {
60-
return RawText.startswith("// ###");
60+
return RawText.starts_with("// ###");
6161
}
6262
};
6363

include/swift/Basic/PathRemapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PathRemapper {
5353
// compatibility with Clang (especially because we propagate the flag to
5454
// ClangImporter as well).
5555
for (const auto &Mapping : PathMappings)
56-
if (Path.startswith(Mapping.first))
56+
if (Path.starts_with(Mapping.first))
5757
return (Twine(Mapping.second) +
5858
Path.substr(Mapping.first.size())).str();
5959
return Path.str();

include/swift/Basic/PrimitiveParsing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static inline unsigned measureNewline(StringRef S) {
3030
}
3131

3232
static inline bool startsWithNewline(StringRef S) {
33-
return S.startswith("\n") || S.startswith("\r\n");
33+
return S.starts_with("\n") || S.starts_with("\r\n");
3434
}
3535

3636
/// Breaks a given string to lines and trims leading whitespace from them.

include/swift/Demangling/Demangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class Demangler : public NodeFactory {
415415
std::function<SymbolicReferenceResolver_t> SymbolicReferenceResolver;
416416

417417
bool nextIf(StringRef str) {
418-
if (!Text.substr(Pos).startswith(str)) return false;
418+
if (!Text.substr(Pos).starts_with(str)) return false;
419419
Pos += str.size();
420420
return true;
421421
}

include/swift/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ class Parser {
766766

767767
/// Check whether the current token starts with a multi-line string delimiter.
768768
bool startsWithMultilineStringDelimiter(Token Tok) {
769-
return Tok.getText().ltrim('#').startswith("\"\"\"");
769+
return Tok.getText().ltrim('#').starts_with("\"\"\"");
770770
}
771771

772772
/// Returns true if token is an identifier with the given value.

include/swift/Remote/MetadataReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ class MetadataReader {
866866
StringRef NameStr(Name);
867867

868868
// If this is a Swift-defined protocol, demangle it.
869-
if (NameStr.startswith("_TtP")) {
869+
if (NameStr.starts_with("_TtP")) {
870870
auto Demangled = dem.demangleSymbol(NameStr);
871871
if (!Demangled)
872872
return resolver.failure();

0 commit comments

Comments
 (0)