From 7542e72188cb05b22523cc58ea4223951399520d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 7 Aug 2022 00:16:17 -0700 Subject: [PATCH] Use llvm::is_contained (NFC) --- .../clang-tidy/bugprone/EasilySwappableParametersCheck.cpp | 12 +++++------- .../clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp | 2 +- clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp | 4 ++-- .../clang-tidy/readability/DuplicateIncludeCheck.cpp | 2 +- clang/lib/AST/ASTContext.cpp | 2 +- clang/lib/Sema/SemaOpenMP.cpp | 5 ++--- .../DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp | 6 ++---- .../Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp | 6 ++---- .../Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp | 2 +- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 4 +--- 10 files changed, 18 insertions(+), 27 deletions(-) diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp index 399e393..f1b7888 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 @@ public: } 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 1165eb9..d35ddd0 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 e818237..3cd019d 100644 --- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp @@ -60,7 +60,7 @@ public: 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 @@ private: 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 9815952..22a4e4e 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 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 21fd395..ba63ebc 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 4279a15..6615f75 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -3767,9 +3767,8 @@ public: 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 5dbbd20..d2bf258 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 fd9ecc9..9e7baae8 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 1728d38..191ce82 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 ef9ba39..f6caf8f 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); } } -- 2.7.4