[Lldb-commits] [lldb] 7542e72 - Use llvm::is_contained (NFC)

Kazu Hirata via lldb-commits lldb-commits at lists.llvm.org
Sun Aug 7 00:16:43 PDT 2022


Author: Kazu Hirata
Date: 2022-08-07T00:16:17-07:00
New Revision: 7542e72188cb05b22523cc58ea4223951399520d

URL: https://github.com/llvm/llvm-project/commit/7542e72188cb05b22523cc58ea4223951399520d
DIFF: https://github.com/llvm/llvm-project/commit/7542e72188cb05b22523cc58ea4223951399520d.diff

LOG: Use llvm::is_contained (NFC)

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
    clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
    clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
    clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
    clang/lib/AST/ASTContext.cpp
    clang/lib/Sema/SemaOpenMP.cpp
    lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
    lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
    lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
    lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 399e393a36fdd..f1b78883aece7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -1512,12 +1512,10 @@ static bool isIgnoredParameter(const TheCheck &Check, const ParmVarDecl *Node) {
                           << "' is ignored.\n");
 
   if (!Node->getIdentifier())
-    return llvm::find(Check.IgnoredParameterNames, "\"\"") !=
-           Check.IgnoredParameterNames.end();
+    return llvm::is_contained(Check.IgnoredParameterNames, "\"\"");
 
   StringRef NodeName = Node->getName();
-  if (llvm::find(Check.IgnoredParameterNames, NodeName) !=
-      Check.IgnoredParameterNames.end()) {
+  if (llvm::is_contained(Check.IgnoredParameterNames, NodeName)) {
     LLVM_DEBUG(llvm::dbgs() << "\tName ignored.\n");
     return true;
   }
@@ -1584,7 +1582,7 @@ bool lazyMapOfSetsIntersectionExists(const MapTy &Map, const ElemTy &E1,
     return false;
 
   for (const auto &E1SetElem : E1Iterator->second)
-    if (llvm::find(E2Iterator->second, E1SetElem) != E2Iterator->second.end())
+    if (llvm::is_contained(E2Iterator->second, E1SetElem))
       return true;
 
   return false;
@@ -1746,8 +1744,8 @@ class Returned {
   }
 
   bool operator()(const ParmVarDecl *Param1, const ParmVarDecl *Param2) const {
-    return llvm::find(ReturnedParams, Param1) != ReturnedParams.end() &&
-           llvm::find(ReturnedParams, Param2) != ReturnedParams.end();
+    return llvm::is_contained(ReturnedParams, Param1) &&
+           llvm::is_contained(ReturnedParams, Param2);
   }
 };
 

diff  --git a/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp b/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
index 1165eb9a38a56..d35ddd021401b 100644
--- a/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
@@ -112,7 +112,7 @@ void ProperlySeededRandomGeneratorCheck::checkSeed(
 
   const std::string SeedType(
       Func->getArg(0)->IgnoreCasts()->getType().getAsString());
-  if (llvm::find(DisallowedSeedTypes, SeedType) != DisallowedSeedTypes.end()) {
+  if (llvm::is_contained(DisallowedSeedTypes, SeedType)) {
     diag(Func->getExprLoc(),
          "random number generator seeded with a disallowed source of seed "
          "value will generate a predictable sequence of values");

diff  --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index e818237954891..3cd019d0c386b 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -60,7 +60,7 @@ template <typename T, unsigned SmallSize> class ImmutableSmallSet {
   size_type count(const T &V) const {
     if (isSmall()) {
       // Since the collection is small, just do a linear search.
-      return llvm::find(Vector, V) == Vector.end() ? 0 : 1;
+      return llvm::is_contained(Vector, V) ? 1 : 0;
     }
 
     return Set.count(V);
@@ -106,7 +106,7 @@ template <typename T, unsigned SmallSize> class SmartSmallSetVector {
   size_type count(const T &V) const {
     if (isSmall()) {
       // Since the collection is small, just do a linear search.
-      return llvm::find(Vector, V) == Vector.end() ? 0 : 1;
+      return llvm::is_contained(Vector, V) ? 1 : 0;
     }
     // Look-up in the Set.
     return Set.count(V);

diff  --git a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
index 9815952f81759..22a4e4eeec6d7 100644
--- a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
@@ -80,7 +80,7 @@ void DuplicateIncludeCallbacks::InclusionDirective(
     bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
     StringRef SearchPath, StringRef RelativePath, const Module *Imported,
     SrcMgr::CharacteristicKind FileType) {
-  if (llvm::find(Files.back(), FileName) != Files.back().end()) {
+  if (llvm::is_contained(Files.back(), FileName)) {
     // We want to delete the entire line, so make sure that [Start,End] covers
     // everything.
     SourceLocation Start =

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 21fd3953eb159..ba63ebcd276e8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11673,7 +11673,7 @@ void ASTContext::forEachMultiversionedFunctionVersion(
        FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) {
     FunctionDecl *CurFD = CurDecl->getAsFunction()->getMostRecentDecl();
     if (CurFD && hasSameType(CurFD->getType(), FD->getType()) &&
-        std::end(SeenDecls) == llvm::find(SeenDecls, CurFD)) {
+        !llvm::is_contained(SeenDecls, CurFD)) {
       SeenDecls.insert(CurFD);
       Pred(CurFD);
     }

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 4279a152db907..6615f75a50cc1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -3767,9 +3767,8 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
         bool IsModifierPresent = Stack->getDefaultmapModifier(ClauseKind) ==
                                  OMPC_DEFAULTMAP_MODIFIER_present;
         if (IsModifierPresent) {
-          if (llvm::find(ImplicitMapModifier[ClauseKind],
-                         OMPC_MAP_MODIFIER_present) ==
-              std::end(ImplicitMapModifier[ClauseKind])) {
+          if (!llvm::is_contained(ImplicitMapModifier[ClauseKind],
+                                  OMPC_MAP_MODIFIER_present)) {
             ImplicitMapModifier[ClauseKind].push_back(
                 OMPC_MAP_MODIFIER_present);
           }

diff  --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index 5dbbd209bd9b6..d2bf2586cd82b 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -168,8 +168,7 @@ bool HexagonDYLDRendezvous::UpdateSOEntriesForAddition() {
     if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0)
       continue;
 
-    pos = std::find(m_soentries.begin(), m_soentries.end(), entry);
-    if (pos == m_soentries.end()) {
+    if (!llvm::is_contained(m_soentries, entry)) {
       m_soentries.push_back(entry);
       m_added_soentries.push_back(entry);
     }
@@ -188,8 +187,7 @@ bool HexagonDYLDRendezvous::UpdateSOEntriesForDeletion() {
     return false;
 
   for (iterator I = begin(); I != end(); ++I) {
-    pos = std::find(entry_list.begin(), entry_list.end(), *I);
-    if (pos == entry_list.end())
+    if (!llvm::is_contained(entry_list, *I))
       m_removed_soentries.push_back(*I);
   }
 

diff  --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index fd9ecc90f272b..9e7baae8a85a6 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -396,8 +396,7 @@ bool DYLDRendezvous::AddSOEntries() {
 
     UpdateFileSpecIfNecessary(entry);
 
-    pos = std::find(m_soentries.begin(), m_soentries.end(), entry);
-    if (pos == m_soentries.end()) {
+    if (!llvm::is_contained(m_soentries, entry)) {
       m_soentries.push_back(entry);
       m_added_soentries.push_back(entry);
     }
@@ -416,8 +415,7 @@ bool DYLDRendezvous::RemoveSOEntries() {
     return false;
 
   for (iterator I = begin(); I != end(); ++I) {
-    pos = std::find(entry_list.begin(), entry_list.end(), *I);
-    if (pos == entry_list.end())
+    if (!llvm::is_contained(entry_list, *I))
       m_removed_soentries.push_back(*I);
   }
 

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 1728d3855b1a2..191ce82d5245e 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -331,7 +331,7 @@ PlatformSP PlatformAppleSimulator::CreateInstance(
       }
 
       if (create) {
-        if (std::count(supported_os.begin(), supported_os.end(), triple.getOS()))
+        if (llvm::is_contained(supported_os, triple.getOS()))
           create = true;
 #if defined(__APPLE__)
         // Only accept "unknown" for the OS if the host is Apple and it

diff  --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index ef9ba39485e64..f6caf8ff46c84 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1618,9 +1618,7 @@ void SymbolFilePDB::GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,
 
   if (can_parse) {
     if (auto *type = ResolveTypeUID(pdb_symbol.getSymIndexId())) {
-      auto result =
-          std::find(type_collection.begin(), type_collection.end(), type);
-      if (result == type_collection.end())
+      if (!llvm::is_contained(type_collection, type))
         type_collection.push_back(type);
     }
   }


        


More information about the lldb-commits mailing list