[llvm] b96c012 - [MC] Use range-based for loops (NFC) (#98604)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 11:37:30 PDT 2024


Author: Kazu Hirata
Date: 2024-07-12T11:37:27-07:00
New Revision: b96c0123fd09cd8e68a6bc500eb30417f8e96228

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

LOG: [MC] Use range-based for loops (NFC) (#98604)

Added: 
    

Modified: 
    llvm/lib/MC/MCELFStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index a30a64ba3df5e..38ebaccf3b6ff 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -699,17 +699,16 @@ void MCELFStreamer::setAttributeItems(unsigned Attribute, unsigned IntValue,
 
 MCELFStreamer::AttributeItem *
 MCELFStreamer::getAttributeItem(unsigned Attribute) {
-  for (size_t I = 0; I < Contents.size(); ++I)
-    if (Contents[I].Tag == Attribute)
-      return &Contents[I];
+  for (AttributeItem &Item : Contents)
+    if (Item.Tag == Attribute)
+      return &Item;
   return nullptr;
 }
 
 size_t
 MCELFStreamer::calculateContentSize(SmallVector<AttributeItem, 64> &AttrsVec) {
   size_t Result = 0;
-  for (size_t I = 0; I < AttrsVec.size(); ++I) {
-    AttributeItem Item = AttrsVec[I];
+  for (const AttributeItem &Item : AttrsVec) {
     switch (Item.Type) {
     case AttributeItem::HiddenAttribute:
       break;
@@ -770,8 +769,7 @@ void MCELFStreamer::createAttributesSection(
 
   // Size should have been accounted for already, now
   // emit each field as its type (ULEB or String)
-  for (size_t I = 0; I < AttrsVec.size(); ++I) {
-    AttributeItem Item = AttrsVec[I];
+  for (const AttributeItem &Item : AttrsVec) {
     emitULEB128IntValue(Item.Tag);
     switch (Item.Type) {
     default:


        


More information about the llvm-commits mailing list