[clang-tools-extra] Add checks to convert std library iterator algorithms into c++20 or boost ranges (PR #97764)

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 5 20:07:07 PDT 2024


================
@@ -0,0 +1,68 @@
+//===--- UseRangesCheck.h - clang-tidy --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_USERANGESCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_USERANGESCHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "IncludeInserter.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringMap.h"
+
+namespace clang::tidy::utils {
+
+/// Base class for handling converting std iterator algorithms to a range
+/// equivalent.
+class UseRangesCheck : public ClangTidyCheck {
+public:
+  struct Indexes {
+    enum Replace { First, Second };
+    unsigned BeginArg;
+    unsigned EndArg = BeginArg + 1;
+    Replace ReplaceArg = First;
+  };
----------------
njames93 wrote:

It was added to support downstream users who want to extend the check to work for their own custom libraries who's methods are a little different to those found in the standard library.

https://github.com/llvm/llvm-project/pull/97764


More information about the cfe-commits mailing list