[llvm] 47755e1 - [AppleAccelTable][NFC] Improve code readability

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 13:36:36 PDT 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-06-08T16:36:08-04:00
New Revision: 47755e1ff8f255d4f369269be078063dc53944ea

URL: https://github.com/llvm/llvm-project/commit/47755e1ff8f255d4f369269be078063dc53944ea
DIFF: https://github.com/llvm/llvm-project/commit/47755e1ff8f255d4f369269be078063dc53944ea.diff

LOG: [AppleAccelTable][NFC] Improve code readability

This commit does a few minor NFC cleanups:

* A variable was called "Atom", probably trying to claim it was an AtomType.
This was incorrect, it is actually a FormValue.

* LLVM provides a `zip_equal` to express the intent of asserting ranges with the
same size. We change the lookup method to use that.

* The use of tuples made the code slightly difficult to follow, as such we
unpack the tuple with structure binding to improve readability.

Depends on D152157

Differential Revision: https://reviews.llvm.org/D152158

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index a4aa50db11f88..8cfd9e42edb24 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -277,18 +277,18 @@ AppleAcceleratorTable::Entry::Entry(
 
 void AppleAcceleratorTable::Entry::extract(
     const AppleAcceleratorTable &AccelTable, uint64_t *Offset) {
-  for (auto &Atom : Values)
-    Atom.extractValue(AccelTable.AccelSection, Offset, AccelTable.FormParams);
+  for (auto &FormValue : Values)
+    FormValue.extractValue(AccelTable.AccelSection, Offset,
+                           AccelTable.FormParams);
 }
 
 std::optional<DWARFFormValue>
-AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType Atom) const {
+AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType AtomToFind) const {
   assert(HdrData && "Dereferencing end iterator?");
   assert(HdrData->Atoms.size() == Values.size());
-  for (auto Tuple : zip_first(HdrData->Atoms, Values)) {
-    if (std::get<0>(Tuple).first == Atom)
-      return std::get<1>(Tuple);
-  }
+  for (auto [Atom, FormValue] : zip_equal(HdrData->Atoms, Values))
+    if (Atom.first == AtomToFind)
+      return FormValue;
   return std::nullopt;
 }
 


        


More information about the llvm-commits mailing list