Skip to content

Commit 53d1fc4

Browse files
committed
Replace usages of .find(Key) != .end() to .contains(Key) in llvm sets
1 parent e924cf6 commit 53d1fc4

File tree

11 files changed

+21
-20
lines changed

11 files changed

+21
-20
lines changed

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ class swift::MemberLookupTable {
10591059
/// Returns \c true if the lookup table has a complete accounting of the
10601060
/// given name.
10611061
bool isLazilyComplete(DeclBaseName name) const {
1062-
return LazilyCompleteNames.find(name) != LazilyCompleteNames.end();
1062+
return LazilyCompleteNames.contains(name);
10631063
}
10641064

10651065
/// Mark a given lazily-loaded name as being complete.

lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ static SmallVector<StringRef, 8> findRemovedInputs(
660660
SmallVector<StringRef, 8> missingInputs;
661661
for (auto &previousInput : previousInputs) {
662662
auto previousInputArg = previousInput.getKey();
663-
if (inputArgs.find(previousInputArg) == inputArgs.end()) {
663+
if (!inputArgs.contains(previousInputArg)) {
664664
missingInputs.push_back(previousInputArg);
665665
}
666666
}

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ findDiagnostic(std::vector<CapturedDiagnosticInfo> &CapturedDiagnostics,
128128

129129
// Verify the classification and string.
130130
if (I->Classification != Expected.Classification ||
131-
!I->Message.contains(Expected.MessageStr))
131+
I->Message.find(Expected.MessageStr) == StringRef::npos)
132132
continue;
133133

134134
// Okay, we found a match, hurray!

lib/FrontendTool/TBD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static bool validateSymbols(DiagnosticEngine &diags,
9393
irNotTBD.push_back(unmangledName);
9494
}
9595
} else {
96-
assert(symbolSet.find(name) == symbolSet.end() &&
96+
assert(!symbolSet.contains(name) &&
9797
"non-global value in value symbol table");
9898
}
9999
}

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ getDeclsFromCrossImportOverlay(ModuleDecl *Overlay, ModuleDecl *Declaring,
424424
return false;
425425

426426
// Ignore an imports of modules also imported by the underlying module.
427-
if (PrevImported.find(Imported) != PrevImported.end())
427+
if (PrevImported.contains(Imported))
428428
return false;
429429
}
430430
if (auto *VD = dyn_cast<ValueDecl>(D)) {

lib/LLVMPasses/LLVMARCOpts.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ static bool canonicalizeInputFunction(Function &F, ARCEntryPointBuilder &B,
142142
// Have not encountered a strong retain/release. keep it in the
143143
// unknown retain/release list for now. It might get replaced
144144
// later.
145-
if (NativeRefs.find(ArgVal) == NativeRefs.end()) {
146-
UnknownObjectRetains[ArgVal].push_back(&CI);
145+
if (!NativeRefs.contains(ArgVal)) {
146+
UnknownObjectRetains[ArgVal].push_back(&CI);
147147
} else {
148148
B.setInsertPoint(&CI);
149149
B.createRetain(ArgVal, &CI);
@@ -189,7 +189,7 @@ static bool canonicalizeInputFunction(Function &F, ARCEntryPointBuilder &B,
189189
// Have not encountered a strong retain/release. keep it in the
190190
// unknown retain/release list for now. It might get replaced
191191
// later.
192-
if (NativeRefs.find(ArgVal) == NativeRefs.end()) {
192+
if (!NativeRefs.contains(ArgVal)) {
193193
UnknownObjectReleases[ArgVal].push_back(&CI);
194194
} else {
195195
B.setInsertPoint(&CI);

lib/Migrator/APIDiffMigratorPass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,7 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
13581358
llvm::raw_svector_ostream OS(Buffer);
13591359
if (swift::ide::printValueDeclUSR(OD, OS))
13601360
return SourceLoc();
1361-
return OverridingRemoveNames.find(OS.str()) == OverridingRemoveNames.end() ?
1362-
SourceLoc() : OverrideLoc;
1361+
return OverridingRemoveNames.contains(OS.str()) ? OverrideLoc : SourceLoc();
13631362
}
13641363

13651364
struct SuperRemoval: public ASTWalker {
@@ -1380,7 +1379,7 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
13801379
auto *RD = DSC->getFn()->getReferencedDecl().getDecl();
13811380
if (swift::ide::printValueDeclUSR(RD, OS))
13821381
return false;
1383-
return USRs.find(OS.str()) != USRs.end();
1382+
return USRs.contains(OS.str());
13841383
}
13851384
}
13861385
// We should handle try super.foo() too.

lib/PrintAsObjC/DeclAndTypePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static bool isClangKeyword(Identifier name) {
7171

7272
if (name.empty())
7373
return false;
74-
return keywords.find(name.str()) != keywords.end();
74+
return keywords.contains(name.str());
7575
}
7676

7777

lib/SILOptimizer/Analysis/ARCAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ findMatchingRetains(SILBasicBlock *BB) {
697697
SA = nullptr;
698698

699699
for (auto X : R.first->getPredecessorBlocks()) {
700-
if (HandledBBs.find(X) != HandledBBs.end())
700+
if (HandledBBs.contains(X))
701701
continue;
702702
// Try to use the predecessor edge-value.
703703
if (SA && SA->getIncomingPhiValue(X)) {

lib/SILOptimizer/Analysis/EpilogueARCAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void EpilogueARCContext::initializeDataflow() {
4040
SILValue CArg = ToProcess.pop_back_val();
4141
if (!CArg)
4242
continue;
43-
if (Processed.find(CArg) != Processed.end())
44-
continue;
43+
if (Processed.contains(CArg))
44+
continue;
4545
Processed.insert(CArg);
4646
if (auto *A = dyn_cast<SILPhiArgument>(CArg)) {
4747
// Find predecessor and break the SILArgument to predecessors.

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,11 +2508,13 @@ static int generateMigrationScript(StringRef LeftPath, StringRef RightPath,
25082508
TypeAliasDiffFinder(RightModule, LeftModule, RevertAliasMap).search();
25092509
populateAliasChanges(RevertAliasMap, AllItems, /*IsRevert*/true);
25102510

2511-
AllItems.erase(std::remove_if(AllItems.begin(), AllItems.end(),
2512-
[&](CommonDiffItem &Item) {
2513-
return Item.DiffKind == NodeAnnotation::RemovedDecl &&
2514-
IgnoredRemoveUsrs.find(Item.LeftUsr) != IgnoredRemoveUsrs.end();
2515-
}), AllItems.end());
2511+
AllItems.erase(
2512+
std::remove_if(AllItems.begin(), AllItems.end(),
2513+
[&](CommonDiffItem &Item) {
2514+
return Item.DiffKind == NodeAnnotation::RemovedDecl &&
2515+
IgnoredRemoveUsrs.contains(Item.LeftUsr);
2516+
}),
2517+
AllItems.end());
25162518

25172519
NoEscapeFuncParamVector AllNoEscapingFuncs;
25182520
NoEscapingFuncEmitter::collectDiffItems(RightModule, AllNoEscapingFuncs);

0 commit comments

Comments
 (0)