Skip to content

Commit aca2de9

Browse files
committed
llvm::StringRef compare_lower -> compare_insensitive
The `compare_lower` API was replaced with `compare_insensitive` in llvm commit 2e4a2b8. git clang-format ran.
1 parent 49e48a4 commit aca2de9

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ void ASTContext::getVisibleTopLevelModuleNames(
20282028

20292029
// Sort and unique.
20302030
std::sort(names.begin(), names.end(), [](Identifier LHS, Identifier RHS) {
2031-
return LHS.str().compare_lower(RHS.str()) < 0;
2031+
return LHS.str().compare_insensitive(RHS.str()) < 0;
20322032
});
20332033
names.erase(std::unique(names.begin(), names.end()), names.end());
20342034
}

lib/IDE/CodeCompletion.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,13 +1502,13 @@ void CodeCompletionContext::sortCompletionResults(
15021502
// Sort nameCache, and then transform Results to return the pointers in order.
15031503
std::sort(nameCache.begin(), nameCache.end(),
15041504
[](const ResultAndName &LHS, const ResultAndName &RHS) {
1505-
int Result = StringRef(LHS.name).compare_lower(RHS.name);
1506-
// If the case insensitive comparison is equal, then secondary sort order
1507-
// should be case sensitive.
1508-
if (Result == 0)
1509-
Result = LHS.name.compare(RHS.name);
1510-
return Result < 0;
1511-
});
1505+
int Result = StringRef(LHS.name).compare_insensitive(RHS.name);
1506+
// If the case insensitive comparison is equal, then secondary
1507+
// sort order should be case sensitive.
1508+
if (Result == 0)
1509+
Result = LHS.name.compare(RHS.name);
1510+
return Result < 0;
1511+
});
15121512

15131513
llvm::transform(nameCache, Results.begin(),
15141514
[](const ResultAndName &entry) { return entry.result; });

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ void swift::ide::collectModuleGroups(ModuleDecl *M,
207207
for (auto File : M->getFiles()) {
208208
File->collectAllGroups(Into);
209209
}
210-
std::sort(Into.begin(), Into.end(),
211-
[](StringRef L, StringRef R) { return L.compare_lower(R) < 0; });
210+
std::sort(Into.begin(), Into.end(), [](StringRef L, StringRef R) {
211+
return L.compare_insensitive(R) < 0;
212+
});
212213
}
213214

214215
/// Determine whether the given extension has a Clang node that

lib/Markup/AST.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ swift::markup::MarkupASTNode *swift::markup::createSimpleField(
341341
if (false) {
342342

343343
}
344-
#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \
345-
else if (Tag.compare_lower(#Keyword) == 0) { \
346-
return Id::create(MC, Children); \
344+
#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \
345+
else if (Tag.compare_insensitive(#Keyword) == 0) { \
346+
return Id::create(MC, Children); \
347347
}
348348
#include "swift/Markup/SimpleFields.def"
349349
llvm_unreachable("Given tag not for any simple markup field");
@@ -353,9 +353,9 @@ bool swift::markup::isAFieldTag(StringRef Tag) {
353353
if (false) {
354354

355355
}
356-
#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \
357-
else if (Tag.compare_lower(#Keyword) == 0) { \
358-
return true; \
356+
#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \
357+
else if (Tag.compare_insensitive(#Keyword) == 0) { \
358+
return true; \
359359
}
360360
#include "swift/Markup/SimpleFields.def"
361361
return false;

tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static double combinedScore(const Options &options, double matchScore,
624624

625625
static int compareResultName(Item &a, Item &b) {
626626
// Sort first by filter name (case-insensitive).
627-
if (int primary = StringRef(a.name).compare_lower(b.name))
627+
if (int primary = StringRef(a.name).compare_insensitive(b.name))
628628
return primary;
629629

630630
// Next, sort by full description text.

tools/driver/swift_api_digester_main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ class RemovedAddedNodeMatcher : public NodeMatcher, public MatchedNodeListener {
196196
bool detectFuncToProperty(SDKNode *R, SDKNode *A) {
197197
if (R->getKind() == SDKNodeKind::DeclFunction) {
198198
if (A->getKind() == SDKNodeKind::DeclVar) {
199-
if (A->getName().compare_lower(R->getName()) == 0) {
199+
if (A->getName().compare_insensitive(R->getName()) == 0) {
200200
R->annotate(NodeAnnotation::GetterToProperty);
201201
} else if (R->getName().startswith("get") &&
202-
R->getName().substr(3).compare_lower(A->getName()) == 0) {
202+
R->getName().substr(3).compare_insensitive(A->getName()) ==
203+
0) {
203204
R->annotate(NodeAnnotation::GetterToProperty);
204205
} else if (R->getName().startswith("set") &&
205-
R->getName().substr(3).compare_lower(A->getName()) == 0) {
206+
R->getName().substr(3).compare_insensitive(A->getName()) ==
207+
0) {
206208
R->annotate(NodeAnnotation::SetterToProperty);
207209
} else {
208210
return false;

0 commit comments

Comments
 (0)