Skip to content

Commit 8bdf387

Browse files
Use *{Map,Set}::contains (NFC)
Differential Revision: https://reviews.llvm.org/D146104
1 parent 9f40e86 commit 8bdf387

File tree

15 files changed

+17
-19
lines changed

15 files changed

+17
-19
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ class BinaryFunction {
17541754

17551755
/// Returns if this function is a child of \p Other function.
17561756
bool isChildOf(const BinaryFunction &Other) const {
1757-
return llvm::is_contained(ParentFragments, &Other);
1757+
return ParentFragments.contains(&Other);
17581758
}
17591759

17601760
/// Set the profile data for the number of times the function was called.

clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ bool lazyMapOfSetsIntersectionExists(const MapTy &Map, const ElemTy &E1,
15811581
return false;
15821582

15831583
for (const auto &E1SetElem : E1Iterator->second)
1584-
if (llvm::is_contained(E2Iterator->second, E1SetElem))
1584+
if (E2Iterator->second.contains(E1SetElem))
15851585
return true;
15861586

15871587
return false;

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11961,7 +11961,7 @@ void ASTContext::forEachMultiversionedFunctionVersion(
1196111961
FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) {
1196211962
FunctionDecl *CurFD = CurDecl->getAsFunction()->getMostRecentDecl();
1196311963
if (CurFD && hasSameType(CurFD->getType(), FD->getType()) &&
11964-
!llvm::is_contained(SeenDecls, CurFD)) {
11964+
!SeenDecls.contains(CurFD)) {
1196511965
SeenDecls.insert(CurFD);
1196611966
Pred(CurFD);
1196711967
}

clang/lib/Lex/Lexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ void Lexer::codeCompleteIncludedFile(const char *PathStart,
22792279
++CompletionPoint;
22802280
if (Next == (IsAngled ? '>' : '"'))
22812281
break;
2282-
if (llvm::is_contained(SlashChars, Next))
2282+
if (SlashChars.contains(Next))
22832283
break;
22842284
}
22852285

clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void CheckerRegistry::initializeRegistry(const CheckerManager &Mgr) {
233233
// done recursively, its arguably cheaper, but for sure less error prone to
234234
// recalculate from scratch.
235235
auto IsEnabled = [&](const CheckerInfo *Checker) {
236-
return llvm::is_contained(Tmp, Checker);
236+
return Tmp.contains(Checker);
237237
};
238238
for (const CheckerInfo &Checker : Data.Checkers) {
239239
if (!Checker.isEnabled(Mgr))
@@ -525,4 +525,3 @@ void CheckerRegistry::validateCheckerOptions() const {
525525
<< SuppliedCheckerOrPackage;
526526
}
527527
}
528-

llvm/include/llvm/Support/CommandLine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class Option {
315315
}
316316

317317
bool isInAllSubCommands() const {
318-
return llvm::is_contained(Subs, &SubCommand::getAll());
318+
return Subs.contains(&SubCommand::getAll());
319319
}
320320

321321
//-------------------------------------------------------------------------===

llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class StatepointState {
388388
Register Reg = MO.getReg();
389389
assert(Reg.isPhysical() && "Only physical regs are expected");
390390

391-
if (isCalleeSaved(Reg) && (AllowGCPtrInCSR || !is_contained(GCRegs, Reg)))
391+
if (isCalleeSaved(Reg) && (AllowGCPtrInCSR || !GCRegs.contains(Reg)))
392392
continue;
393393

394394
LLVM_DEBUG(dbgs() << "Will spill " << printReg(Reg, &TRI) << " at index "

llvm/lib/IR/DebugInfoMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ bool DIExpression::hasAllLocationOps(unsigned N) const {
16671667
if (ExprOp.getOp() == dwarf::DW_OP_LLVM_arg)
16681668
SeenOps.insert(ExprOp.getArg(0));
16691669
for (uint64_t Idx = 0; Idx < N; ++Idx)
1670-
if (!is_contained(SeenOps, Idx))
1670+
if (!SeenOps.contains(Idx))
16711671
return false;
16721672
return true;
16731673
}

llvm/lib/Support/CommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,7 +2757,7 @@ StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) {
27572757
initCommonOptions();
27582758
auto &Subs = GlobalParser->RegisteredSubCommands;
27592759
(void)Subs;
2760-
assert(is_contained(Subs, &Sub));
2760+
assert(Subs.contains(&Sub));
27612761
return Sub.OptionsMap;
27622762
}
27632763

llvm/lib/Transforms/Scalar/GVNSink.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class LockstepReverseIterator {
154154

155155
void restrictToBlocks(SmallSetVector<BasicBlock *, 4> &Blocks) {
156156
for (auto II = Insts.begin(); II != Insts.end();) {
157-
if (!llvm::is_contained(Blocks, (*II)->getParent())) {
157+
if (!Blocks.contains((*II)->getParent())) {
158158
ActiveBlocks.remove((*II)->getParent());
159159
II = Insts.erase(II);
160160
} else {
@@ -272,7 +272,7 @@ class ModelledPHI {
272272
auto VI = Values.begin();
273273
while (BI != Blocks.end()) {
274274
assert(VI != Values.end());
275-
if (!llvm::is_contained(NewBlocks, *BI)) {
275+
if (!NewBlocks.contains(*BI)) {
276276
BI = Blocks.erase(BI);
277277
VI = Values.erase(VI);
278278
} else {

llvm/tools/llvm-exegesis/lib/Analysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum EscapeTag { kEscapeCsv, kEscapeHtml, kEscapeHtmlString };
2828
template <EscapeTag Tag> void writeEscaped(raw_ostream &OS, const StringRef S);
2929

3030
template <> void writeEscaped<kEscapeCsv>(raw_ostream &OS, const StringRef S) {
31-
if (!llvm::is_contained(S, kCsvSep)) {
31+
if (!S.contains(kCsvSep)) {
3232
OS << S;
3333
} else {
3434
// Needs escaping.

llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,8 @@ int main(int argc, char **argv) {
361361
char32_t Codepoint = Entry.first;
362362
const std::string &Name = Entry.second;
363363
// Ignore names which are not valid.
364-
if (Name.empty() || !llvm::all_of(Name, [](char C) {
365-
return llvm::is_contained(Letters, C);
366-
})) {
364+
if (Name.empty() ||
365+
!llvm::all_of(Name, [](char C) { return Letters.contains(C); })) {
367366
continue;
368367
}
369368
printf("%06x: %s\n", static_cast<unsigned int>(Codepoint), Name.c_str());

mlir/lib/AsmParser/Parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ ParseResult Parser::codeCompleteDialectOrElidedOpName(SMLoc loc) {
389389
const char *bufBegin = state.lex.getBufferBegin();
390390
const char *it = loc.getPointer() - 1;
391391
for (; it > bufBegin && *it != '\n'; --it)
392-
if (!llvm::is_contained(StringRef(" \t\r"), *it))
392+
if (!StringRef(" \t\r").contains(*it))
393393
return true;
394394
return false;
395395
};

mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ checkMappingAttributeTypes(std::optional<TransformOpInterface> transformOp,
124124

125125
DenseSet<Attribute> seen;
126126
for (Attribute map : forallOp.getMapping()->getValue()) {
127-
if (llvm::is_contained(seen, map)) {
127+
if (seen.contains(map)) {
128128
return failureHelper(transformOp, forallOp,
129129
"duplicated attribute, cannot map different loops "
130130
"to the same processor");

mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ LogicalResult scf::canonicalizeMinMaxOpInLoop(RewriterBase &rewriter,
152152
// Find all iteration variables among `minOp`'s operands add constrain them.
153153
for (Value operand : op->getOperands()) {
154154
// Skip duplicate ivs.
155-
if (llvm::is_contained(allIvs, operand))
155+
if (allIvs.contains(operand))
156156
continue;
157157

158158
// If `operand` is an iteration variable: Find corresponding loop

0 commit comments

Comments
 (0)