Use *{Map,Set}::contains (NFC)
authorKazu Hirata <kazu@google.com>
Wed, 15 Mar 2023 15:46:32 +0000 (08:46 -0700)
committerKazu Hirata <kazu@google.com>
Wed, 15 Mar 2023 15:46:32 +0000 (08:46 -0700)
Differential Revision: https://reviews.llvm.org/D146104

15 files changed:
bolt/include/bolt/Core/BinaryFunction.h
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
llvm/include/llvm/Support/CommandLine.h
llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/Support/CommandLine.cpp
llvm/lib/Transforms/Scalar/GVNSink.cpp
llvm/tools/llvm-exegesis/lib/Analysis.cpp
llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
mlir/lib/AsmParser/Parser.cpp
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp

index 036a4c5b0987ac415a579d56213bf3796d28d6d9..7a99ce2481a1a6f9bd52674e9998b1ad94c988bf 100644 (file)
@@ -1754,7 +1754,7 @@ public:
 
   /// Returns if this function is a child of \p Other function.
   bool isChildOf(const BinaryFunction &Other) const {
-    return llvm::is_contained(ParentFragments, &Other);
+    return ParentFragments.contains(&Other);
   }
 
   /// Set the profile data for the number of times the function was called.
index 0e21453234f2fb2e01ea3087ed42df64cad608b2..fa7285744be8902fd2e7baa30917427ce009aa91 100644 (file)
@@ -1581,7 +1581,7 @@ bool lazyMapOfSetsIntersectionExists(const MapTy &Map, const ElemTy &E1,
     return false;
 
   for (const auto &E1SetElem : E1Iterator->second)
-    if (llvm::is_contained(E2Iterator->second, E1SetElem))
+    if (E2Iterator->second.contains(E1SetElem))
       return true;
 
   return false;
index 14c9ab9c31a886b656b30af0dcd15409ac5b2a77..5196f1e3555ac9befd85eecfbaefe3d70339ccd1 100644 (file)
@@ -11961,7 +11961,7 @@ void ASTContext::forEachMultiversionedFunctionVersion(
        FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) {
     FunctionDecl *CurFD = CurDecl->getAsFunction()->getMostRecentDecl();
     if (CurFD && hasSameType(CurFD->getType(), FD->getType()) &&
-        !llvm::is_contained(SeenDecls, CurFD)) {
+        !SeenDecls.contains(CurFD)) {
       SeenDecls.insert(CurFD);
       Pred(CurFD);
     }
index b9b13725edbc55ffe2df7ff8e5ff88f8f0a71313..bc97ca18a2ebd92b1cf2d8ee0acf1c4481d547ec 100644 (file)
@@ -2279,7 +2279,7 @@ void Lexer::codeCompleteIncludedFile(const char *PathStart,
     ++CompletionPoint;
     if (Next == (IsAngled ? '>' : '"'))
       break;
-    if (llvm::is_contained(SlashChars, Next))
+    if (SlashChars.contains(Next))
       break;
   }
 
index 4618d17577dd8708bd78ff258d2ca0d1c2cc197d..f0d3f43c414c6e715b47045dcf7261adc235a8bf 100644 (file)
@@ -233,7 +233,7 @@ void CheckerRegistry::initializeRegistry(const CheckerManager &Mgr) {
   // done recursively, its arguably cheaper, but for sure less error prone to
   // recalculate from scratch.
   auto IsEnabled = [&](const CheckerInfo *Checker) {
-    return llvm::is_contained(Tmp, Checker);
+    return Tmp.contains(Checker);
   };
   for (const CheckerInfo &Checker : Data.Checkers) {
     if (!Checker.isEnabled(Mgr))
@@ -525,4 +525,3 @@ void CheckerRegistry::validateCheckerOptions() const {
         << SuppliedCheckerOrPackage;
   }
 }
-
index 43c769c1fd0ad4a04438bd81813409125268f3c1..408853a60876b18c46ad6a184ffcdca8182ddf1e 100644 (file)
@@ -315,7 +315,7 @@ public:
   }
 
   bool isInAllSubCommands() const {
-    return llvm::is_contained(Subs, &SubCommand::getAll());
+    return Subs.contains(&SubCommand::getAll());
   }
 
   //-------------------------------------------------------------------------===
index 55d939de426e38ceef8f216d528d807890cafbc2..0b32d69afeb286f0f085e4b58dbe74c359608b19 100644 (file)
@@ -388,7 +388,7 @@ public:
       Register Reg = MO.getReg();
       assert(Reg.isPhysical() && "Only physical regs are expected");
 
-      if (isCalleeSaved(Reg) && (AllowGCPtrInCSR || !is_contained(GCRegs, Reg)))
+      if (isCalleeSaved(Reg) && (AllowGCPtrInCSR || !GCRegs.contains(Reg)))
         continue;
 
       LLVM_DEBUG(dbgs() << "Will spill " << printReg(Reg, &TRI) << " at index "
index a5d931769573dbef8a6fa337113d23198659dbae..479a51e1e00428df4cc19d6ee7d865c73734d476 100644 (file)
@@ -1667,7 +1667,7 @@ bool DIExpression::hasAllLocationOps(unsigned N) const {
     if (ExprOp.getOp() == dwarf::DW_OP_LLVM_arg)
       SeenOps.insert(ExprOp.getArg(0));
   for (uint64_t Idx = 0; Idx < N; ++Idx)
-    if (!is_contained(SeenOps, Idx))
+    if (!SeenOps.contains(Idx))
       return false;
   return true;
 }
index 92e69db0c5b972c4c9ccd29580266376b2af37ae..d3efb8b67be5c67d47a09ff8690b7351bc0d936b 100644 (file)
@@ -2757,7 +2757,7 @@ StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) {
   initCommonOptions();
   auto &Subs = GlobalParser->RegisteredSubCommands;
   (void)Subs;
-  assert(is_contained(Subs, &Sub));
+  assert(Subs.contains(&Sub));
   return Sub.OptionsMap;
 }
 
index 34a9aaf4066e25be6ca3bfe8e1222d397832d778..d0933ec418acf06e73f6c631ef447e73bbe2dd62 100644 (file)
@@ -154,7 +154,7 @@ public:
 
   void restrictToBlocks(SmallSetVector<BasicBlock *, 4> &Blocks) {
     for (auto II = Insts.begin(); II != Insts.end();) {
-      if (!llvm::is_contained(Blocks, (*II)->getParent())) {
+      if (!Blocks.contains((*II)->getParent())) {
         ActiveBlocks.remove((*II)->getParent());
         II = Insts.erase(II);
       } else {
@@ -272,7 +272,7 @@ public:
     auto VI = Values.begin();
     while (BI != Blocks.end()) {
       assert(VI != Values.end());
-      if (!llvm::is_contained(NewBlocks, *BI)) {
+      if (!NewBlocks.contains(*BI)) {
         BI = Blocks.erase(BI);
         VI = Values.erase(VI);
       } else {
index d1ec125f82ae7cb36a0994d360dd113ce9760dcb..2d7e17fc7399f4220e2ad7ec2114d78e0ed1ea91 100644 (file)
@@ -28,7 +28,7 @@ enum EscapeTag { kEscapeCsv, kEscapeHtml, kEscapeHtmlString };
 template <EscapeTag Tag> void writeEscaped(raw_ostream &OS, const StringRef S);
 
 template <> void writeEscaped<kEscapeCsv>(raw_ostream &OS, const StringRef S) {
-  if (!llvm::is_contained(S, kCsvSep)) {
+  if (!S.contains(kCsvSep)) {
     OS << S;
   } else {
     // Needs escaping.
index 83770e845d408834dc04fc1f63b3e5d993dbbb0f..7bf9c8b03b41855da110aac366d46bd6c59a4c00 100644 (file)
@@ -361,9 +361,8 @@ int main(int argc, char **argv) {
     char32_t Codepoint = Entry.first;
     const std::string &Name = Entry.second;
     // Ignore names which are not valid.
-    if (Name.empty() || !llvm::all_of(Name, [](char C) {
-          return llvm::is_contained(Letters, C);
-        })) {
+    if (Name.empty() ||
+        !llvm::all_of(Name, [](char C) { return Letters.contains(C); })) {
       continue;
     }
     printf("%06x: %s\n", static_cast<unsigned int>(Codepoint), Name.c_str());
index c44190b7b4a6129556b73332d72a9d0c94a02de0..46c1ae976d9d46dc164db43f7520033bbfbb8505 100644 (file)
@@ -389,7 +389,7 @@ ParseResult Parser::codeCompleteDialectOrElidedOpName(SMLoc loc) {
     const char *bufBegin = state.lex.getBufferBegin();
     const char *it = loc.getPointer() - 1;
     for (; it > bufBegin && *it != '\n'; --it)
-      if (!llvm::is_contained(StringRef(" \t\r"), *it))
+      if (!StringRef(" \t\r").contains(*it))
         return true;
     return false;
   };
index 6d87604aee0ba3a97419e286cb18caad1e70eb7f..748d9e46ac153f688c88310fbf4c6cba67c7189a 100644 (file)
@@ -124,7 +124,7 @@ checkMappingAttributeTypes(std::optional<TransformOpInterface> transformOp,
 
   DenseSet<Attribute> seen;
   for (Attribute map : forallOp.getMapping()->getValue()) {
-    if (llvm::is_contained(seen, map)) {
+    if (seen.contains(map)) {
       return failureHelper(transformOp, forallOp,
                            "duplicated attribute, cannot map different loops "
                            "to the same processor");
index 7799fa9231c622d34caaf90520446ff5cb27ef5c..6964747cdebb664a689a2ff986ff1c5621ad4670 100644 (file)
@@ -152,7 +152,7 @@ LogicalResult scf::canonicalizeMinMaxOpInLoop(RewriterBase &rewriter,
   // Find all iteration variables among `minOp`'s operands add constrain them.
   for (Value operand : op->getOperands()) {
     // Skip duplicate ivs.
-    if (llvm::is_contained(allIvs, operand))
+    if (allIvs.contains(operand))
       continue;
 
     // If `operand` is an iteration variable: Find corresponding loop