[llvm] [ADT] Adding bidirectional iterator functionality + unit tests (PR #160726)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 09:13:15 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/ADT/BitVector.h llvm/unittests/ADT/BitVectorTest.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index ef619aef2..48c20e364 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -51,9 +51,9 @@ template <typename BitVectorT> class const_set_bits_iterator_impl {
 public:
   using iterator_category = std::bidirectional_iterator_tag;
   using difference_type   = std::ptrdiff_t;
-  using value_type        = unsigned;
-  using pointer           = const value_type*;
-  using reference         = value_type;
+  using value_type = unsigned;
+  using pointer = const value_type *;
+  using reference = value_type;
 
   const_set_bits_iterator_impl(const BitVectorT &Parent, int Current)
       : Parent(Parent), Current(Current) {}
diff --git a/llvm/unittests/ADT/BitVectorTest.cpp b/llvm/unittests/ADT/BitVectorTest.cpp
index 216e9a0c5..4b4642148 100644
--- a/llvm/unittests/ADT/BitVectorTest.cpp
+++ b/llvm/unittests/ADT/BitVectorTest.cpp
@@ -8,8 +8,8 @@
 
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallBitVector.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -1204,7 +1204,7 @@ TYPED_TEST(BitVectorTest, BidirectionalIterator) {
 
   // Test full backward iteration
   std::vector<unsigned> BackwardBits;
-  for (auto RIt = Vec.set_bits_end(); RIt != Vec.set_bits_begin(); ) {
+  for (auto RIt = Vec.set_bits_end(); RIt != Vec.set_bits_begin();) {
     --RIt;
     BackwardBits.push_back(*RIt);
   }

``````````

</details>


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


More information about the llvm-commits mailing list