r217956 - Basic: use range-based for loops for ARM target

Saleem Abdulrasool compnerd at compnerd.org
Wed Sep 17 07:50:23 PDT 2014


Author: compnerd
Date: Wed Sep 17 09:50:23 2014
New Revision: 217956

URL: http://llvm.org/viewvc/llvm-project?rev=217956&view=rev
Log:
Basic: use range-based for loops for ARM target

Tweak handleTargetFeature for the ARM(32) target to use range based for loops.
NFC.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=217956&r1=217955&r2=217956&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Sep 17 09:50:23 2014
@@ -3841,28 +3841,29 @@ public:
     Crypto = 0;
     SoftFloat = SoftFloatABI = false;
     HWDiv = 0;
-    for (unsigned i = 0, e = Features.size(); i != e; ++i) {
-      if (Features[i] == "+soft-float")
+
+    for (const auto &Feature : Features) {
+      if (Feature == "+soft-float")
         SoftFloat = true;
-      else if (Features[i] == "+soft-float-abi")
+      else if (Feature == "+soft-float-abi")
         SoftFloatABI = true;
-      else if (Features[i] == "+vfp2")
+      else if (Feature == "+vfp2")
         FPU |= VFP2FPU;
-      else if (Features[i] == "+vfp3")
+      else if (Feature == "+vfp3")
         FPU |= VFP3FPU;
-      else if (Features[i] == "+vfp4")
+      else if (Feature == "+vfp4")
         FPU |= VFP4FPU;
-      else if (Features[i] == "+fp-armv8")
+      else if (Feature == "+fp-armv8")
         FPU |= FPARMV8;
-      else if (Features[i] == "+neon")
+      else if (Feature == "+neon")
         FPU |= NeonFPU;
-      else if (Features[i] == "+hwdiv")
+      else if (Feature == "+hwdiv")
         HWDiv |= HWDivThumb;
-      else if (Features[i] == "+hwdiv-arm")
+      else if (Feature == "+hwdiv-arm")
         HWDiv |= HWDivARM;
-      else if (Features[i] == "+crc")
+      else if (Feature == "+crc")
         CRC = 1;
-      else if (Features[i] == "+crypto")
+      else if (Feature == "+crypto")
         Crypto = 1;
     }
 
@@ -3877,13 +3878,13 @@ public:
       Features.push_back("-neonfp");
 
     // Remove front-end specific options which the backend handles differently.
-    std::vector<std::string>::iterator it;
-    it = std::find(Features.begin(), Features.end(), "+soft-float");
-    if (it != Features.end())
-      Features.erase(it);
-    it = std::find(Features.begin(), Features.end(), "+soft-float-abi");
-    if (it != Features.end())
-      Features.erase(it);
+    const StringRef FrontEndFeatures[] = { "+soft-float", "+soft-float-abi" };
+    for (const auto &FEFeature : FrontEndFeatures) {
+      auto Feature = std::find(Features.begin(), Features.end(), FEFeature);
+      if (Feature != Features.end())
+        Features.erase(Feature);
+    }
+
     return true;
   }
 





More information about the cfe-commits mailing list