[llvm] [NFC][TableGen] Code cleanup in Record.h/cpp (PR #138876)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Thu May 8 13:34:25 PDT 2025


================
@@ -569,9 +570,8 @@ const Init *BitsInit::resolveReferences(Resolver &R) const {
   const Init *CachedBitVarRef = nullptr;
   const Init *CachedBitVarResolved = nullptr;
 
-  for (unsigned i = 0, e = getNumBits(); i != e; ++i) {
-    const Init *CurBit = getBit(i);
-    const Init *NewBit = CurBit;
+  for (auto [CurBit, NewBit] : zip_equal(getBits(), NewBits)) {
+    NewBit = CurBit;
----------------
jurahul wrote:

It does :) I had my doubts as well and the STLExtras.h comment doesn't say much, but LLVM Programmers manual explicitly specifies that it does: https://llvm.org/docs/ProgrammersManual.html#the-zip-functions

> Note that the elements are provided through a ‘reference wrapper’ proxy type (tuple of references), which combined with the structured bindings declaration makes Letter and Count references to range elements. Any modification to these references will affect the elements of Letters or Counts


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


More information about the llvm-commits mailing list