Skip to content

Commit 293a434

Browse files
authored
Merge pull request swiftlang#72744 from bnbarham/rename-endswith
Rename `StringRef::endswith` references to `StringRef::ends_with`
2 parents e6a2021 + 1fdda02 commit 293a434

Some content is hidden

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

47 files changed

+99
-99
lines changed

include/swift/AST/FineGrainedDependencies.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ template <typename GraphT> class DotFileEmitter {
989989
includeExternals || n->getKey().getKind() != NodeKind::externalDepend;
990990
bool apiPredicate =
991991
includeAPINotes ||
992-
!StringRef(n->getKey().humanReadableName()).endswith(".apinotes");
992+
!StringRef(n->getKey().humanReadableName()).ends_with(".apinotes");
993993
return externalPredicate && apiPredicate;
994994
}
995995
bool includeGraphArc(const NodeT *def, const NodeT *use) const {

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11765,7 +11765,7 @@ bool MacroDecl::isUniqueMacroName(StringRef name) {
1176511765
name = name.drop_back();
1176611766

1176711767
// Check for fMu.
11768-
return name.endswith("fMu");
11768+
return name.ends_with("fMu");
1176911769
}
1177011770

1177111771
bool MacroDecl::isUniqueMacroName(DeclBaseName name) {

lib/AST/FineGrainedDependencies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ std::optional<SourceFileDepGraph>
4646
SourceFileDepGraph::loadFromPath(StringRef path, const bool allowSwiftModule) {
4747
const bool treatAsModule =
4848
allowSwiftModule &&
49-
path.endswith(file_types::getExtension(file_types::TY_SwiftModuleFile));
49+
path.ends_with(file_types::getExtension(file_types::TY_SwiftModuleFile));
5050
auto bufferOrError = llvm::MemoryBuffer::getFile(path);
5151
if (!bufferOrError)
5252
return std::nullopt;

lib/AST/ModuleDependencies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService(
535535
std::error_code EC;
536536
for (auto F = FS.dir_begin(RuntimeLibPath, EC);
537537
!EC && F != llvm::vfs::directory_iterator(); F.increment(EC)) {
538-
if (F->path().endswith(".yaml"))
538+
if (F->path().ends_with(".yaml"))
539539
CommonDependencyFiles.emplace_back(F->path().str());
540540
}
541541
}

lib/Basic/EditorPlaceholder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using namespace swift;
3939
std::optional<EditorPlaceholderData>
4040
swift::parseEditorPlaceholder(llvm::StringRef PlaceholderText) {
4141
if (!PlaceholderText.starts_with("<#") ||
42-
!PlaceholderText.endswith("#>"))
42+
!PlaceholderText.ends_with("#>"))
4343
return std::nullopt;
4444

4545
PlaceholderText = PlaceholderText.drop_front(2).drop_back(2);

lib/Basic/Platform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ std::string swift::getSDKBuildVersion(StringRef Path) {
580580
std::string swift::getSDKName(StringRef Path) {
581581
std::string Name = getPlistEntry(llvm::Twine(Path)+"/SDKSettings.plist",
582582
"CanonicalName");
583-
if (Name.empty() && Path.endswith(".sdk")) {
583+
if (Name.empty() && Path.ends_with(".sdk")) {
584584
Name = llvm::sys::path::filename(Path).drop_back(strlen(".sdk")).str();
585585
}
586586
return Name;

lib/Basic/PrettyStackTrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void PrettyStackTraceStringAction::print(llvm::raw_ostream &out) const {
3030
void PrettyStackTraceFileContents::print(llvm::raw_ostream &out) const {
3131
out << "Contents of " << Buffer.getBufferIdentifier() << ":\n---\n"
3232
<< Buffer.getBuffer();
33-
if (!Buffer.getBuffer().endswith("\n"))
33+
if (!Buffer.getBuffer().ends_with("\n"))
3434
out << '\n';
3535
out << "---\n";
3636
}

lib/Basic/StringExtras.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PartOfSpeech swift::getPartOfSpeech(StringRef word) {
6969
#include "PartsOfSpeech.def"
7070

7171
// Identify gerunds, which always end in "ing".
72-
if (word.endswith("ing") && word.size() > 4) {
72+
if (word.ends_with("ing") && word.size() > 4) {
7373
StringRef possibleVerb = word.drop_back(3);
7474

7575
// If what remains is a verb, we have a gerund.
@@ -417,7 +417,7 @@ static std::optional<StringRef> skipTypeSuffix(StringRef typeName) {
417417
}
418418

419419
// _t.
420-
if (typeName.size() > 2 && typeName.endswith("_t")) {
420+
if (typeName.size() > 2 && typeName.ends_with("_t")) {
421421
return typeName.drop_back(2);
422422
}
423423
return std::nullopt;
@@ -555,7 +555,7 @@ static StringRef omitNeedlessWordsFromPrefix(StringRef name,
555555
if (firstWord == "By") {
556556
StringRef nextWord = camel_case::getFirstWord(
557557
newName.substr(firstWord.size()));
558-
if (nextWord.endswith("ing")) {
558+
if (nextWord.ends_with("ing")) {
559559
return newName.substr(firstWord.size());
560560
}
561561
}
@@ -1404,27 +1404,27 @@ bool swift::omitNeedlessWords(
14041404

14051405
std::optional<StringRef>
14061406
swift::stripWithCompletionHandlerSuffix(StringRef name) {
1407-
if (name.endswith("WithCompletionHandler")) {
1407+
if (name.ends_with("WithCompletionHandler")) {
14081408
return name.drop_back(strlen("WithCompletionHandler"));
14091409
}
14101410

1411-
if (name.endswith("WithCompletion")) {
1411+
if (name.ends_with("WithCompletion")) {
14121412
return name.drop_back(strlen("WithCompletion"));
14131413
}
14141414

1415-
if (name.endswith("WithCompletionBlock")) {
1415+
if (name.ends_with("WithCompletionBlock")) {
14161416
return name.drop_back(strlen("WithCompletionBlock"));
14171417
}
14181418

1419-
if (name.endswith("WithBlock")) {
1419+
if (name.ends_with("WithBlock")) {
14201420
return name.drop_back(strlen("WithBlock"));
14211421
}
14221422

1423-
if (name.endswith("WithReplyTo")) {
1423+
if (name.ends_with("WithReplyTo")) {
14241424
return name.drop_back(strlen("WithReplyTo"));
14251425
}
14261426

1427-
if (name.endswith("WithReply")) {
1427+
if (name.ends_with("WithReply")) {
14281428
return name.drop_back(strlen("WithReply"));
14291429
}
14301430

lib/ClangImporter/CFTypeInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ StringRef importer::getCFTypeName(
102102
if (auto pointee = CFPointeeInfo::classifyTypedef(decl)) {
103103
auto name = decl->getName();
104104
if (pointee.isRecord() || pointee.isTypedef())
105-
if (name.endswith(SWIFT_CFTYPE_SUFFIX))
105+
if (name.ends_with(SWIFT_CFTYPE_SUFFIX))
106106
return name.drop_back(strlen(SWIFT_CFTYPE_SUFFIX));
107107

108108
return name;

lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static bool clangSupportsPragmaAttributeWithSwiftAttr() {
458458

459459
static inline bool isPCHFilenameExtension(StringRef path) {
460460
return llvm::sys::path::extension(path)
461-
.endswith(file_types::getExtension(file_types::TY_PCH));
461+
.ends_with(file_types::getExtension(file_types::TY_PCH));
462462
}
463463

464464
void importer::getNormalInvocationArguments(
@@ -7034,7 +7034,7 @@ bool ClangImporter::isUnsafeCXXMethod(const FuncDecl *func) {
70347034
if (!func->hasName())
70357035
return false;
70367036
auto id = func->getBaseName().userFacingName();
7037-
return id.starts_with("__") && id.endswith("Unsafe");
7037+
return id.starts_with("__") && id.ends_with("Unsafe");
70387038
}
70397039

70407040
bool ClangImporter::isAnnotatedWith(const clang::CXXMethodDecl *method,

0 commit comments

Comments
 (0)