[clang-tools-extra] Use llvm::find (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 30 Oct 2022 16:41:55 +0000 (09:41 -0700)
committerKazu Hirata <kazu@google.com>
Sun, 30 Oct 2022 16:41:55 +0000 (09:41 -0700)
clang-tools-extra/clang-doc/Generators.cpp
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clangd/InlayHints.cpp

index 591d433..da19c05 100644 (file)
@@ -65,7 +65,7 @@ void Generator::addInfoToIndex(Index &Idx, const doc::Info *Info) {
   for (const auto &R : llvm::reverse(Info->Namespace)) {
     // Look for the current namespace in the children of the index I is
     // pointing.
-    auto It = std::find(I->Children.begin(), I->Children.end(), R.USR);
+    auto It = llvm::find(I->Children, R.USR);
     if (It != I->Children.end()) {
       // If it is found, just change I to point the namespace reference found.
       I = &*It;
@@ -79,7 +79,7 @@ void Generator::addInfoToIndex(Index &Idx, const doc::Info *Info) {
   // Look for Info in the vector where it is supposed to be; it could already
   // exist if it is a parent namespace of an Info already passed to this
   // function.
-  auto It = std::find(I->Children.begin(), I->Children.end(), Info->USR);
+  auto It = llvm::find(I->Children, Info->USR);
   if (It == I->Children.end()) {
     // If it is not in the vector it is inserted
     I->Children.emplace_back(Info->USR, Info->extractName(), Info->IT,
index aa8300c..73e28fb 100644 (file)
@@ -78,8 +78,7 @@ std::string ConfusableIdentifierCheck::skeleton(StringRef Name) {
       UTF8 *BufferStart = std::begin(Buffer);
       UTF8 *IBuffer = BufferStart;
       const UTF32 *ValuesStart = std::begin(Where->values);
-      const UTF32 *ValuesEnd =
-          std::find(std::begin(Where->values), std::end(Where->values), '\0');
+      const UTF32 *ValuesEnd = llvm::find(Where->values, '\0');
       if (ConvertUTF32toUTF8(&ValuesStart, ValuesEnd, &IBuffer,
                              std::end(Buffer),
                              strictConversion) != conversionOK) {
index 7cd6fc3..c294845 100644 (file)
@@ -75,7 +75,7 @@ static bool containsMisleadingBidi(StringRef Buffer,
       BidiContexts.push_back(PDI);
     // Close a PDI Context.
     else if (CodePoint == PDI) {
-      auto R = std::find(BidiContexts.rbegin(), BidiContexts.rend(), PDI);
+      auto R = llvm::find(llvm::reverse(BidiContexts), PDI);
       if (R != BidiContexts.rend())
         BidiContexts.resize(BidiContexts.rend() - R - 1);
     }
index 00f4b00..a8ca761 100644 (file)
@@ -120,8 +120,7 @@ void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult &Result) {
     }
   }
 
-  const size_t Index = std::find(Function->parameters().begin(),
-                                 Function->parameters().end(), Param) -
+  const size_t Index = llvm::find(Function->parameters(), Param) -
                        Function->parameters().begin();
 
   auto Diag =
index 16c6b1c..1d13a13 100644 (file)
@@ -581,9 +581,8 @@ private:
   static const ParmVarDecl *getParamDefinition(const ParmVarDecl *P) {
     if (auto *Callee = dyn_cast<FunctionDecl>(P->getDeclContext())) {
       if (auto *Def = Callee->getDefinition()) {
-        auto I = std::distance(
-            Callee->param_begin(),
-            std::find(Callee->param_begin(), Callee->param_end(), P));
+        auto I = std::distance(Callee->param_begin(),
+                               llvm::find(Callee->parameters(), P));
         if (I < Callee->getNumParams()) {
           return Def->getParamDecl(I);
         }