Browse Source

clang-tidy: fix `modernize-loop-convert` lints

Ben Boeckel 2 years ago
parent
commit
1f893e5873

+ 2 - 2
Source/cmGlobalVisualStudio8Generator.cxx

@@ -278,8 +278,8 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
 {
   cmGlobalVisualStudio7Generator::AddExtraIDETargets();
   if (this->AddCheckTarget()) {
-    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
-      const auto& tgts = this->LocalGenerators[i]->GetGeneratorTargets();
+    for (auto& LocalGenerator : this->LocalGenerators) {
+      const auto& tgts = LocalGenerator->GetGeneratorTargets();
       // All targets depend on the build-system check target.
       for (const auto& ti : tgts) {
         if (ti->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {

+ 2 - 2
Source/cmIDEOptions.cxx

@@ -21,8 +21,8 @@ cmIDEOptions::cmIDEOptions()
   this->DoingInclude = false;
   this->AllowSlash = false;
   this->DoingFollowing = nullptr;
-  for (int i = 0; i < FlagTableCount; ++i) {
-    this->FlagTable[i] = nullptr;
+  for (auto& flag : this->FlagTable) {
+    flag = nullptr;
   }
 }
 

+ 6 - 8
Source/cmLocalVisualStudio7Generator.cxx

@@ -1435,8 +1435,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
   fout << "\t<Files>\n";
 
   // Loop through every source group.
-  for (unsigned int i = 0; i < sourceGroups.size(); ++i) {
-    cmSourceGroup sg = sourceGroups[i];
+  for (auto const& sg : sourceGroups) {
     this->WriteGroup(&sg, target, fout, libName, configs, sources);
   }
 
@@ -1630,9 +1629,9 @@ std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory(
 
   // Compute the maximum length configuration name.
   std::string config_max;
-  for (auto i = configs.begin(); i != configs.end(); ++i) {
-    if (i->size() > config_max.size()) {
-      config_max = *i;
+  for (auto& config : configs) {
+    if (config.size() > config_max.size()) {
+      config_max = config;
     }
   }
 
@@ -1658,9 +1657,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
   // Write the children to temporary output.
   bool hasChildrenWithSources = false;
   std::ostringstream tmpOut;
-  for (unsigned int i = 0; i < children.size(); ++i) {
-    if (this->WriteGroup(&children[i], target, tmpOut, libName, configs,
-                         sources)) {
+  for (const auto& child : children) {
+    if (this->WriteGroup(&child, target, tmpOut, libName, configs, sources)) {
       hasChildrenWithSources = true;
     }
   }

+ 6 - 9
Source/cmVisualStudio10TargetGenerator.cxx

@@ -275,8 +275,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
     this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
   this->NsightTegra = gg->IsNsightTegra();
   this->Android = gg->TargetsAndroid();
-  for (int i = 0; i < 4; ++i) {
-    this->NsightTegraVersion[i] = 0;
+  for (unsigned int& version : this->NsightTegraVersion) {
+    version = 0;
   }
   sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
          &this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
@@ -2338,19 +2338,16 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
       if (!deployLocation.empty()) {
         e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
       }
-      for (size_t i = 0; i != this->Configurations.size(); ++i) {
-        if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) ==
-            "1") {
+      for (auto& config : this->Configurations) {
+        if (cge->Evaluate(this->LocalGenerator, config) == "1") {
           e2.WritePlatformConfigTag("DeploymentContent",
                                     "'$(Configuration)|$(Platform)'=='" +
-                                      this->Configurations[i] + "|" +
-                                      this->Platform + "'",
+                                      config + "|" + this->Platform + "'",
                                     "true");
         } else {
           e2.WritePlatformConfigTag("ExcludedFromBuild",
                                     "'$(Configuration)|$(Platform)'=='" +
-                                      this->Configurations[i] + "|" +
-                                      this->Platform + "'",
+                                      config + "|" + this->Platform + "'",
                                     "true");
         }
       }

+ 5 - 5
Source/cmVisualStudioGeneratorOptions.cxx

@@ -51,9 +51,9 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
 void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table)
 {
   if (table) {
-    for (int i = 0; i < FlagTableCount; ++i) {
-      if (!this->FlagTable[i]) {
-        this->FlagTable[i] = table;
+    for (auto& flag : this->FlagTable) {
+      if (!flag) {
+        flag = table;
         break;
       }
     }
@@ -62,8 +62,8 @@ void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table)
 
 void cmVisualStudioGeneratorOptions::ClearTables()
 {
-  for (int i = 0; i < FlagTableCount; ++i) {
-    this->FlagTable[i] = nullptr;
+  for (auto& flag : this->FlagTable) {
+    flag = nullptr;
   }
 }