Browse Source

clang-tidy: fix `readability-else-after-return` lints

Ben Boeckel 2 years ago
parent
commit
b72c45e39f

+ 54 - 36
Source/cmGlobalVisualStudio10Generator.cxx

@@ -1503,19 +1503,23 @@ std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const
 
 
   if (toolset == "v142") {
   if (toolset == "v142") {
     return "v142";
     return "v142";
-  } else if (toolset == "v141") {
+  }
+  if (toolset == "v141") {
     return "v141";
     return "v141";
-  } else if (useToolset == "v140") {
+  }
+  if (useToolset == "v140") {
     return "v140";
     return "v140";
-  } else if (useToolset == "v120") {
+  }
+  if (useToolset == "v120") {
     return "v12";
     return "v12";
-  } else if (useToolset == "v110") {
+  }
+  if (useToolset == "v110") {
     return "v11";
     return "v11";
-  } else if (useToolset == "v100") {
+  }
+  if (useToolset == "v100") {
     return "v10";
     return "v10";
-  } else {
-    return "";
   }
   }
+  return "";
 }
 }
 
 
 std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName() const
 std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName() const
@@ -1525,19 +1529,23 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName() const
 
 
   if (useToolset == "v142") {
   if (useToolset == "v142") {
     return "v142";
     return "v142";
-  } else if (useToolset == "v141") {
+  }
+  if (useToolset == "v141") {
     return "v141";
     return "v141";
-  } else if (useToolset == "v140") {
+  }
+  if (useToolset == "v140") {
     return "v140";
     return "v140";
-  } else if (useToolset == "v120") {
+  }
+  if (useToolset == "v120") {
     return "v12";
     return "v12";
-  } else if (useToolset == "v110") {
+  }
+  if (useToolset == "v110") {
     return "v11";
     return "v11";
-  } else if (useToolset == "v100") {
+  }
+  if (useToolset == "v100") {
     return "v10";
     return "v10";
-  } else {
-    return "";
   }
   }
+  return "";
 }
 }
 
 
 std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName() const
 std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName() const
@@ -1548,15 +1556,17 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName() const
   if ((useToolset == "v140") || (useToolset == "v141") ||
   if ((useToolset == "v140") || (useToolset == "v141") ||
       (useToolset == "v142")) {
       (useToolset == "v142")) {
     return "v14";
     return "v14";
-  } else if (useToolset == "v120") {
+  }
+  if (useToolset == "v120") {
     return "v12";
     return "v12";
-  } else if (useToolset == "v110") {
+  }
+  if (useToolset == "v110") {
     return "v11";
     return "v11";
-  } else if (useToolset == "v100") {
+  }
+  if (useToolset == "v100") {
     return "v10";
     return "v10";
-  } else {
-    return "";
   }
   }
+  return "";
 }
 }
 
 
 std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName() const
 std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName() const
@@ -1567,15 +1577,17 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName() const
   if ((useToolset == "v140") || (useToolset == "v141") ||
   if ((useToolset == "v140") || (useToolset == "v141") ||
       (useToolset == "v142")) {
       (useToolset == "v142")) {
     return "v14";
     return "v14";
-  } else if (useToolset == "v120") {
+  }
+  if (useToolset == "v120") {
     return "v12";
     return "v12";
-  } else if (useToolset == "v110") {
+  }
+  if (useToolset == "v110") {
     return "v11";
     return "v11";
-  } else if (useToolset == "v100") {
+  }
+  if (useToolset == "v100") {
     return "v10";
     return "v10";
-  } else {
-    return "";
   }
   }
+  return "";
 }
 }
 
 
 std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName() const
 std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName() const
@@ -1585,19 +1597,23 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName() const
 
 
   if (useToolset == "v142") {
   if (useToolset == "v142") {
     return "v142";
     return "v142";
-  } else if (useToolset == "v141") {
+  }
+  if (useToolset == "v141") {
     return "v141";
     return "v141";
-  } else if (useToolset == "v140") {
+  }
+  if (useToolset == "v140") {
     return "v140";
     return "v140";
-  } else if (useToolset == "v120") {
+  }
+  if (useToolset == "v120") {
     return "v12";
     return "v12";
-  } else if (useToolset == "v110") {
+  }
+  if (useToolset == "v110") {
     return "v11";
     return "v11";
-  } else if (useToolset == "v100") {
+  }
+  if (useToolset == "v100") {
     return "v10";
     return "v10";
-  } else {
-    return "";
   }
   }
+  return "";
 }
 }
 
 
 std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const
 std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const
@@ -1608,15 +1624,17 @@ std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const
   if ((useToolset == "v140") || (useToolset == "v141") ||
   if ((useToolset == "v140") || (useToolset == "v141") ||
       (useToolset == "v142")) {
       (useToolset == "v142")) {
     return "v14";
     return "v14";
-  } else if (useToolset == "v120") {
+  }
+  if (useToolset == "v120") {
     return "v12";
     return "v12";
-  } else if (useToolset == "v110") {
+  }
+  if (useToolset == "v110") {
     return "v11";
     return "v11";
-  } else if (useToolset == "v100") {
+  }
+  if (useToolset == "v100") {
     return "v10";
     return "v10";
-  } else {
-    return "";
   }
   }
+  return "";
 }
 }
 
 
 std::string cmGlobalVisualStudio10Generator::CanonicalToolsetName(
 std::string cmGlobalVisualStudio10Generator::CanonicalToolsetName(

+ 2 - 4
Source/cmGlobalVisualStudio11Generator.cxx

@@ -216,9 +216,8 @@ bool cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
         this->IsWindowsDesktopToolsetInstalled()) {
         this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v110_wp80";
       toolset = "v110_wp80";
       return true;
       return true;
-    } else {
-      return false;
     }
     }
+    return false;
   }
   }
   return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
   return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
     toolset);
     toolset);
@@ -232,9 +231,8 @@ bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
         this->IsWindowsDesktopToolsetInstalled()) {
         this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v110";
       toolset = "v110";
       return true;
       return true;
-    } else {
-      return false;
     }
     }
+    return false;
   }
   }
   return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
   return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
     toolset);
     toolset);

+ 2 - 4
Source/cmGlobalVisualStudio12Generator.cxx

@@ -194,9 +194,8 @@ bool cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset(
         this->IsWindowsDesktopToolsetInstalled()) {
         this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v120_wp81";
       toolset = "v120_wp81";
       return true;
       return true;
-    } else {
-      return false;
     }
     }
+    return false;
   }
   }
   return this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
   return this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
     toolset);
     toolset);
@@ -210,9 +209,8 @@ bool cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
         this->IsWindowsDesktopToolsetInstalled()) {
         this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v120";
       toolset = "v120";
       return true;
       return true;
-    } else {
-      return false;
     }
     }
+    return false;
   }
   }
   return this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
   return this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
     toolset);
     toolset);

+ 2 - 3
Source/cmGlobalVisualStudio14Generator.cxx

@@ -213,9 +213,8 @@ bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
         this->IsWindowsDesktopToolsetInstalled()) {
         this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v140";
       toolset = "v140";
       return true;
       return true;
-    } else {
-      return false;
     }
     }
+    return false;
   }
   }
   return this->cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
   return this->cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
     toolset);
     toolset);
@@ -255,7 +254,7 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion(
       return std::string();
       return std::string();
     }
     }
     // If the value is something else, trust that it is a valid SDK value.
     // If the value is something else, trust that it is a valid SDK value.
-    else if (value) {
+    if (value) {
       return *value;
       return *value;
     }
     }
     // If value is an invalid pointer, leave result unchanged.
     // If value is an invalid pointer, leave result unchanged.

+ 12 - 6
Source/cmGlobalVisualStudio7Generator.cxx

@@ -190,17 +190,23 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
   std::string extension = cmSystemTools::GetFilenameLastExtension(location);
   std::string extension = cmSystemTools::GetFilenameLastExtension(location);
   if (extension == ".vbproj") {
   if (extension == ".vbproj") {
     return "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
     return "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
-  } else if (extension == ".csproj") {
+  }
+  if (extension == ".csproj") {
     return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
     return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
-  } else if (extension == ".fsproj") {
+  }
+  if (extension == ".fsproj") {
     return "F2A71F9B-5D33-465A-A702-920D77279786";
     return "F2A71F9B-5D33-465A-A702-920D77279786";
-  } else if (extension == ".vdproj") {
+  }
+  if (extension == ".vdproj") {
     return "54435603-DBB4-11D2-8724-00A0C9A8B90C";
     return "54435603-DBB4-11D2-8724-00A0C9A8B90C";
-  } else if (extension == ".dbproj") {
+  }
+  if (extension == ".dbproj") {
     return "C8D11400-126E-41CD-887F-60BD40844F9E";
     return "C8D11400-126E-41CD-887F-60BD40844F9E";
-  } else if (extension == ".wixproj") {
+  }
+  if (extension == ".wixproj") {
     return "930C7802-8A8C-48F9-8165-68863BCCD9DD";
     return "930C7802-8A8C-48F9-8165-68863BCCD9DD";
-  } else if (extension == ".pyproj") {
+  }
+  if (extension == ".pyproj") {
     return "888888A0-9F3D-457C-B088-3A5042F75D52";
     return "888888A0-9F3D-457C-B088-3A5042F75D52";
   }
   }
   return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
   return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";

+ 5 - 6
Source/cmGlobalVisualStudioGenerator.cxx

@@ -518,13 +518,12 @@ std::string cmGlobalVisualStudioGenerator::GetStartupProjectName(
     std::string startup = *n;
     std::string startup = *n;
     if (this->FindTarget(startup)) {
     if (this->FindTarget(startup)) {
       return startup;
       return startup;
-    } else {
-      root->GetMakefile()->IssueMessage(
-        MessageType::AUTHOR_WARNING,
-        "Directory property VS_STARTUP_PROJECT specifies target "
-        "'" +
-          startup + "' that does not exist.  Ignoring.");
     }
     }
+    root->GetMakefile()->IssueMessage(
+      MessageType::AUTHOR_WARNING,
+      "Directory property VS_STARTUP_PROJECT specifies target "
+      "'" +
+        startup + "' that does not exist.  Ignoring.");
   }
   }
 
 
   // default, if not specified
   // default, if not specified

+ 15 - 16
Source/cmGlobalVisualStudioVersionedGenerator.cxx

@@ -85,19 +85,19 @@ static std::string VSHostPlatformName()
 {
 {
   if (VSIsArm64Host()) {
   if (VSIsArm64Host()) {
     return "ARM64";
     return "ARM64";
-  } else if (VSIsWow64()) {
+  }
+  if (VSIsWow64()) {
     return "x64";
     return "x64";
-  } else {
+  }
 #if defined(_M_ARM)
 #if defined(_M_ARM)
-    return "ARM";
+  return "ARM";
 #elif defined(_M_IA64)
 #elif defined(_M_IA64)
-    return "Itanium";
+  return "Itanium";
 #elif defined(_WIN64)
 #elif defined(_WIN64)
-    return "x64";
+  return "x64";
 #else
 #else
-    return "Win32";
+  return "Win32";
 #endif
 #endif
-  }
 }
 }
 
 
 static std::string VSHostArchitecture(
 static std::string VSHostArchitecture(
@@ -105,19 +105,19 @@ static std::string VSHostArchitecture(
 {
 {
   if (VSIsArm64Host()) {
   if (VSIsArm64Host()) {
     return v >= cmGlobalVisualStudioGenerator::VSVersion::VS17 ? "ARM64" : "";
     return v >= cmGlobalVisualStudioGenerator::VSVersion::VS17 ? "ARM64" : "";
-  } else if (VSIsWow64()) {
+  }
+  if (VSIsWow64()) {
     return "x64";
     return "x64";
-  } else {
+  }
 #if defined(_M_ARM)
 #if defined(_M_ARM)
-    return "";
+  return "";
 #elif defined(_M_IA64)
 #elif defined(_M_IA64)
-    return "";
+  return "";
 #elif defined(_WIN64)
 #elif defined(_WIN64)
-    return "x64";
+  return "x64";
 #else
 #else
-    return "x86";
+  return "x86";
 #endif
 #endif
-  }
 }
 }
 
 
 static unsigned int VSVersionToMajor(
 static unsigned int VSVersionToMajor(
@@ -900,9 +900,8 @@ bool cmGlobalVisualStudioVersionedGenerator::SelectWindowsStoreToolset(
         this->IsWindowsDesktopToolsetInstalled()) {
         this->IsWindowsDesktopToolsetInstalled()) {
       toolset = VSVersionToToolset(this->Version);
       toolset = VSVersionToToolset(this->Version);
       return true;
       return true;
-    } else {
-      return false;
     }
     }
+    return false;
   }
   }
   return this->cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
   return this->cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
     toolset);
     toolset);

+ 2 - 3
Source/cmLocalVisualStudio7Generator.cxx

@@ -278,10 +278,9 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
     // the generator validated all project-named sources.
     // the generator validated all project-named sources.
     file->ResolveFullPath();
     file->ResolveFullPath();
     return file;
     return file;
-  } else {
-    cmSystemTools::Error("Error adding rule for " + makefileIn);
-    return nullptr;
   }
   }
+  cmSystemTools::Error("Error adding rule for " + makefileIn);
+  return nullptr;
 }
 }
 
 
 void cmLocalVisualStudio7Generator::WriteConfigurations(
 void cmLocalVisualStudio7Generator::WriteConfigurations(

+ 5 - 7
Source/cmVSSetupHelper.cxx

@@ -187,21 +187,19 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
   SmartBSTR bstrVersion;
   SmartBSTR bstrVersion;
   if (FAILED(pInstance->GetInstallationVersion(&bstrVersion))) {
   if (FAILED(pInstance->GetInstallationVersion(&bstrVersion))) {
     return false;
     return false;
-  } else {
-    vsInstanceInfo.Version =
-      cmsys::Encoding::ToNarrow(std::wstring(bstrVersion));
   }
   }
+  vsInstanceInfo.Version =
+    cmsys::Encoding::ToNarrow(std::wstring(bstrVersion));
 
 
   // Reboot may have been required before the installation path was created.
   // Reboot may have been required before the installation path was created.
   SmartBSTR bstrInstallationPath;
   SmartBSTR bstrInstallationPath;
   if ((eLocal & state) == eLocal) {
   if ((eLocal & state) == eLocal) {
     if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) {
     if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) {
       return false;
       return false;
-    } else {
-      vsInstanceInfo.VSInstallLocation =
-        cmsys::Encoding::ToNarrow(std::wstring(bstrInstallationPath));
-      cmSystemTools::ConvertToUnixSlashes(vsInstanceInfo.VSInstallLocation);
     }
     }
+    vsInstanceInfo.VSInstallLocation =
+      cmsys::Encoding::ToNarrow(std::wstring(bstrInstallationPath));
+    cmSystemTools::ConvertToUnixSlashes(vsInstanceInfo.VSInstallLocation);
   }
   }
 
 
   // Check if a compiler is installed with this instance.
   // Check if a compiler is installed with this instance.

+ 1 - 2
Source/cmVSSetupHelper.h

@@ -47,9 +47,8 @@ public:
   {
   {
     if (pp != nullptr) {
     if (pp != nullptr) {
       return ptr->QueryInterface(rclsid, (void**)pp);
       return ptr->QueryInterface(rclsid, (void**)pp);
-    } else {
-      return E_FAIL;
     }
     }
+    return E_FAIL;
   }
   }
   HRESULT CoCreateInstance(REFCLSID clsid, IUnknown* pUnknown,
   HRESULT CoCreateInstance(REFCLSID clsid, IUnknown* pUnknown,
                            REFIID interfaceId, DWORD dwClsContext = CLSCTX_ALL)
                            REFIID interfaceId, DWORD dwClsContext = CLSCTX_ALL)

+ 2 - 4
Source/cmVisualStudioSlnData.cxx

@@ -26,8 +26,7 @@ const cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByGUID(
   auto it(ProjectsByGUID.find(projectGUID));
   auto it(ProjectsByGUID.find(projectGUID));
   if (it != ProjectsByGUID.end())
   if (it != ProjectsByGUID.end())
     return it->second;
     return it->second;
-  else
-    return cm::nullopt;
+  return cm::nullopt;
 }
 }
 
 
 const cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByName(
 const cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByName(
@@ -36,8 +35,7 @@ const cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByName(
   auto it(ProjectNameIndex.find(projectName));
   auto it(ProjectNameIndex.find(projectName));
   if (it != ProjectNameIndex.end())
   if (it != ProjectNameIndex.end())
     return it->second->second;
     return it->second->second;
-  else
-    return cm::nullopt;
+  return cm::nullopt;
 }
 }
 
 
 std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const
 std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const

+ 5 - 8
Source/cmVisualStudioSlnParser.cxx

@@ -82,8 +82,7 @@ std::string cmVisualStudioSlnParser::ParsedLine::GetArgVerbatim() const
 {
 {
   if (this->Arg.second)
   if (this->Arg.second)
     return Quote + this->Arg.first + Quote;
     return Quote + this->Arg.first + Quote;
-  else
-    return this->Arg.first;
+  return this->Arg.first;
 }
 }
 
 
 const std::string& cmVisualStudioSlnParser::ParsedLine::GetValue(
 const std::string& cmVisualStudioSlnParser::ParsedLine::GetValue(
@@ -91,8 +90,7 @@ const std::string& cmVisualStudioSlnParser::ParsedLine::GetValue(
 {
 {
   if (idxValue < this->Values.size())
   if (idxValue < this->Values.size())
     return this->Values[idxValue].first;
     return this->Values[idxValue].first;
-  else
-    return BadString;
+  return BadString;
 }
 }
 
 
 std::string cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim(
 std::string cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim(
@@ -102,10 +100,9 @@ std::string cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim(
     const StringData& data = this->Values[idxValue];
     const StringData& data = this->Values[idxValue];
     if (data.second)
     if (data.second)
       return Quote + data.first + Quote;
       return Quote + data.first + Quote;
-    else
-      return data.first;
-  } else
-    return BadString;
+    return data.first;
+  }
+  return BadString;
 }
 }
 
 
 class cmVisualStudioSlnParser::State
 class cmVisualStudioSlnParser::State