Pārlūkot izejas kodu

Merge topic 'clang-tidy'

effa6c83 fix more issues reported by clang-tidy
fb461cac silence selected clang-tidy violations
Brad King 9 gadi atpakaļ
vecāks
revīzija
a5f4463eed

+ 1 - 1
Source/CPack/IFW/cmCPackIFWInstaller.cxx

@@ -231,7 +231,7 @@ public:
 protected:
   void StartElement(const std::string& name, const char** /*atts*/) CM_OVERRIDE
   {
-    file = name == "file" ? true : false;
+    file = name == "file";
     if (file) {
       hasFiles = true;
     }

+ 6 - 4
Source/cmExtraCodeLiteGenerator.cxx

@@ -430,17 +430,19 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries(
 
   xml.StartElement("General");
   std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
-  if (!outputPath.empty())
+  if (!outputPath.empty()) {
     xml.Attribute("OutputFile", outputPath + "/$(ProjectName)");
-  else
+  } else {
     xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)");
+  }
   xml.Attribute("IntermediateDirectory", "./");
   xml.Attribute("Command", "./$(ProjectName)");
   xml.Attribute("CommandArguments", "");
-  if (!outputPath.empty())
+  if (!outputPath.empty()) {
     xml.Attribute("WorkingDirectory", outputPath);
-  else
+  } else {
     xml.Attribute("WorkingDirectory", "$(IntermediateDirectory)");
+  }
   xml.Attribute("PauseExecWhenProcTerminates", "yes");
   xml.EndElement(); // General
 

+ 36 - 18
Source/cmFileCommand.cxx

@@ -115,41 +115,59 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args,
   }
   if (subCommand == "STRINGS") {
     return this->HandleStringsCommand(args);
-  } else if (subCommand == "GLOB") {
+  }
+  if (subCommand == "GLOB") {
     return this->HandleGlobCommand(args, false);
-  } else if (subCommand == "GLOB_RECURSE") {
+  }
+  if (subCommand == "GLOB_RECURSE") {
     return this->HandleGlobCommand(args, true);
-  } else if (subCommand == "MAKE_DIRECTORY") {
+  }
+  if (subCommand == "MAKE_DIRECTORY") {
     return this->HandleMakeDirectoryCommand(args);
-  } else if (subCommand == "RENAME") {
+  }
+  if (subCommand == "RENAME") {
     return this->HandleRename(args);
-  } else if (subCommand == "REMOVE") {
+  }
+  if (subCommand == "REMOVE") {
     return this->HandleRemove(args, false);
-  } else if (subCommand == "REMOVE_RECURSE") {
+  }
+  if (subCommand == "REMOVE_RECURSE") {
     return this->HandleRemove(args, true);
-  } else if (subCommand == "COPY") {
+  }
+  if (subCommand == "COPY") {
     return this->HandleCopyCommand(args);
-  } else if (subCommand == "INSTALL") {
+  }
+  if (subCommand == "INSTALL") {
     return this->HandleInstallCommand(args);
-  } else if (subCommand == "DIFFERENT") {
+  }
+  if (subCommand == "DIFFERENT") {
     return this->HandleDifferentCommand(args);
-  } else if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") {
+  }
+  if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") {
     return this->HandleRPathChangeCommand(args);
-  } else if (subCommand == "RPATH_CHECK") {
+  }
+  if (subCommand == "RPATH_CHECK") {
     return this->HandleRPathCheckCommand(args);
-  } else if (subCommand == "RPATH_REMOVE") {
+  }
+  if (subCommand == "RPATH_REMOVE") {
     return this->HandleRPathRemoveCommand(args);
-  } else if (subCommand == "RELATIVE_PATH") {
+  }
+  if (subCommand == "RELATIVE_PATH") {
     return this->HandleRelativePathCommand(args);
-  } else if (subCommand == "TO_CMAKE_PATH") {
+  }
+  if (subCommand == "TO_CMAKE_PATH") {
     return this->HandleCMakePathCommand(args, false);
-  } else if (subCommand == "TO_NATIVE_PATH") {
+  }
+  if (subCommand == "TO_NATIVE_PATH") {
     return this->HandleCMakePathCommand(args, true);
-  } else if (subCommand == "TIMESTAMP") {
+  }
+  if (subCommand == "TIMESTAMP") {
     return this->HandleTimestampCommand(args);
-  } else if (subCommand == "GENERATE") {
+  }
+  if (subCommand == "GENERATE") {
     return this->HandleGenerateCommand(args);
-  } else if (subCommand == "LOCK") {
+  }
+  if (subCommand == "LOCK") {
     return this->HandleLockCommand(args);
   }
 

+ 2 - 2
Source/cmFileMonitor.cxx

@@ -36,7 +36,7 @@ public:
 class cmVirtualDirectoryWatcher : public cmIBaseWatcher
 {
 public:
-  ~cmVirtualDirectoryWatcher()
+  ~cmVirtualDirectoryWatcher() override
   {
     for (auto i : this->Children) {
       delete i.second;
@@ -156,7 +156,7 @@ public:
     p->AddChildWatcher(ps, this);
   }
 
-  ~cmRealDirectoryWatcher()
+  ~cmRealDirectoryWatcher() override
   {
     // Handle is freed via uv_handle_close callback!
   }

+ 3 - 2
Source/cmGeneratorExpressionDAGChecker.cxx

@@ -53,8 +53,9 @@ void cmGeneratorExpressionDAGChecker::Initialize()
 
 #define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() ||
 
-  if (CheckResult == DAG && (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
-                              TEST_TRANSITIVE_PROPERTY_METHOD) false))
+  if (CheckResult == DAG &&
+      (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
+        TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(clang-tidy)
 #undef TEST_TRANSITIVE_PROPERTY_METHOD
   {
     std::map<std::string, std::set<std::string> >::const_iterator it =

+ 2 - 2
Source/cmGeneratorExpressionNode.cxx

@@ -1035,7 +1035,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 #define TRANSITIVE_PROPERTY_COMPARE(PROPERTY)                                 \
   (#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) ||
         if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(
-              TRANSITIVE_PROPERTY_COMPARE) false) {
+              TRANSITIVE_PROPERTY_COMPARE) false) { // NOLINT(clang-tidy)
           reportError(
             context, content->GetOriginalExpression(),
             "$<TARGET_PROPERTY:...> expression in link libraries "
@@ -1052,7 +1052,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 #define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() ||
 
         assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
-          ASSERT_TRANSITIVE_PROPERTY_METHOD) false);
+          ASSERT_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(clang-tidy)
 #undef ASSERT_TRANSITIVE_PROPERTY_METHOD
       }
     }

+ 1 - 1
Source/cmGeneratorTarget.cxx

@@ -401,7 +401,7 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
   if (!cmTargetPropertyComputer::PassesWhitelist(
         this->GetType(), prop, this->Makefile->GetMessenger(),
         this->GetBacktrace())) {
-    return 0;
+    return CM_NULLPTR;
   }
   if (const char* result = cmTargetPropertyComputer::GetProperty(
         this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {

+ 1 - 1
Source/cmGetPropertyCommand.cxx

@@ -248,7 +248,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
       }
       return this->StoreResult(CM_NULLPTR);
     }
-    const char* prop_cstr = 0;
+    const char* prop_cstr = CM_NULLPTR;
     cmListFileBacktrace bt = this->Makefile->GetBacktrace();
     cmMessenger* messenger = this->Makefile->GetMessenger();
     if (cmTargetPropertyComputer::PassesWhitelist(

+ 1 - 1
Source/cmGetTargetPropertyCommand.cxx

@@ -24,7 +24,7 @@ bool cmGetTargetPropertyCommand::InitialPass(
         prop_exists = true;
       }
     } else if (!args[2].empty()) {
-      const char* prop_cstr = 0;
+      const char* prop_cstr = CM_NULLPTR;
       cmListFileBacktrace bt = this->Makefile->GetBacktrace();
       cmMessenger* messenger = this->Makefile->GetMessenger();
       if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2],

+ 4 - 2
Source/cmNinjaTargetGenerator.cxx

@@ -275,8 +275,9 @@ std::string cmNinjaTargetGenerator::GetPreprocessedFilePath(
     objName.substr(0, objName.size() - objExt.size()) + "-pp." + ppExt;
 
   std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
-  if (!path.empty())
+  if (!path.empty()) {
     path += "/";
+  }
   path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   path += "/";
   path += ppName;
@@ -287,8 +288,9 @@ std::string cmNinjaTargetGenerator::GetDyndepFilePath(
   std::string const& lang) const
 {
   std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
-  if (!path.empty())
+  if (!path.empty()) {
     path += "/";
+  }
   path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   path += "/";
   path += lang;

+ 14 - 8
Source/cmServerProtocol.cxx

@@ -41,8 +41,9 @@ static std::vector<std::string> getConfigurations(const cmake* cm)
   }
 
   makefiles[0]->GetConfigurations(configurations);
-  if (configurations.empty())
+  if (configurations.empty()) {
     configurations.push_back("");
+  }
   return configurations;
 }
 
@@ -95,20 +96,24 @@ static void getCMakeInputs(const cmGlobalGenerator* gg,
       if (!sourceDir.empty()) {
         const std::string& relative =
           cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str());
-        if (toAdd.size() > relative.size())
+        if (toAdd.size() > relative.size()) {
           toAdd = relative;
+        }
       }
 
       if (isInternal) {
-        if (internalFiles)
+        if (internalFiles) {
           internalFiles->push_back(toAdd);
+        }
       } else {
         if (isTemporary) {
-          if (tmpFiles)
+          if (tmpFiles) {
             tmpFiles->push_back(toAdd);
+          }
         } else {
-          if (explicitFiles)
+          if (explicitFiles) {
             explicitFiles->push_back(toAdd);
+          }
         }
       }
     }
@@ -671,8 +676,9 @@ static Json::Value DumpSourceFilesList(
   Json::Value result = Json::arrayValue;
   for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) {
     Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir);
-    if (!group.isNull())
+    if (!group.isNull()) {
       result.append(group);
+    }
   }
 
   return result;
@@ -820,8 +826,8 @@ static Json::Value DumpProjectList(const cmake* cm, const std::string config)
     Json::Value pObj = Json::objectValue;
     pObj[kNAME_KEY] = projectIt.first;
 
-    assert(projectIt.second.size() >
-           0); // All Projects must have at least one local generator
+    // All Projects must have at least one local generator
+    assert(!projectIt.second.empty());
     const cmLocalGenerator* lg = projectIt.second.at(0);
 
     // Project structure information:

+ 8 - 4
Source/cmTarget.cxx

@@ -855,13 +855,15 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
     e << "NAME property is read-only\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-  } else if (prop == "EXPORT_NAME" && this->IsImported()) {
+  }
+  if (prop == "EXPORT_NAME" && this->IsImported()) {
     std::ostringstream e;
     e << "EXPORT_NAME property can't be set on imported targets (\""
       << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-  } else if (prop == "SOURCES" && this->IsImported()) {
+  }
+  if (prop == "SOURCES" && this->IsImported()) {
     std::ostringstream e;
     e << "SOURCES property can't be set on imported targets (\"" << this->Name
       << "\")\n";
@@ -935,13 +937,15 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
     e << "NAME property is read-only\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-  } else if (prop == "EXPORT_NAME" && this->IsImported()) {
+  }
+  if (prop == "EXPORT_NAME" && this->IsImported()) {
     std::ostringstream e;
     e << "EXPORT_NAME property can't be set on imported targets (\""
       << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-  } else if (prop == "SOURCES" && this->IsImported()) {
+  }
+  if (prop == "SOURCES" && this->IsImported()) {
     std::ostringstream e;
     e << "SOURCES property can't be set on imported targets (\"" << this->Name
       << "\")\n";

+ 3 - 3
Source/cmTargetPropertyComputer.h

@@ -76,7 +76,7 @@ private:
       }
 
       // Support "LOCATION_<CONFIG>".
-      else if (cmHasLiteralPrefix(prop, "LOCATION_")) {
+      if (cmHasLiteralPrefix(prop, "LOCATION_")) {
         if (!tgt->IsImported() &&
             !HandleLocationPropertyPolicy(tgt->GetName(), messenger,
                                           context)) {
@@ -87,8 +87,8 @@ private:
       }
 
       // Support "<CONFIG>_LOCATION".
-      else if (cmHasLiteralSuffix(prop, "_LOCATION") &&
-               !cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) {
+      if (cmHasLiteralSuffix(prop, "_LOCATION") &&
+          !cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) {
         std::string configName(prop.c_str(), prop.size() - 9);
         if (configName != "IMPORTED") {
           if (!tgt->IsImported() &&

+ 54 - 38
Source/cmcmd.cxx

@@ -414,7 +414,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       return 0;
     }
 
-    else if (args[1] == "env") {
+    if (args[1] == "env") {
       std::vector<std::string>::const_iterator ai = args.begin() + 2;
       std::vector<std::string>::const_iterator ae = args.end();
       for (; ai != ae; ++ai) {
@@ -454,7 +454,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-    else if (args[1] == "environment") {
+    if (args[1] == "environment") {
       std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables();
       std::vector<std::string>::iterator it;
       for (it = env.begin(); it != env.end(); ++it) {
@@ -464,7 +464,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 #endif
 
-    else if (args[1] == "make_directory" && args.size() > 2) {
+    if (args[1] == "make_directory" && args.size() > 2) {
       // If error occurs we want to continue copying next files.
       bool return_value = 0;
       for (std::string::size_type cc = 2; cc < args.size(); cc++) {
@@ -476,7 +476,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       return return_value;
     }
 
-    else if (args[1] == "remove_directory" && args.size() == 3) {
+    if (args[1] == "remove_directory" && args.size() == 3) {
       if (cmSystemTools::FileIsDirectory(args[2]) &&
           !cmSystemTools::RemoveADirectory(args[2])) {
         std::cerr << "Error removing directory \"" << args[2] << "\".\n";
@@ -486,7 +486,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Remove file
-    else if (args[1] == "remove" && args.size() > 2) {
+    if (args[1] == "remove" && args.size() > 2) {
       bool force = false;
       for (std::string::size_type cc = 2; cc < args.size(); cc++) {
         if (args[cc] == "\\-f" || args[cc] == "-f") {
@@ -502,8 +502,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       }
       return 0;
     }
+
     // Touch file
-    else if (args[1] == "touch" && args.size() > 2) {
+    if (args[1] == "touch" && args.size() > 2) {
       for (std::string::size_type cc = 2; cc < args.size(); cc++) {
         if (!cmSystemTools::Touch(args[cc], true)) {
           return 1;
@@ -511,8 +512,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       }
       return 0;
     }
+
     // Touch file
-    else if (args[1] == "touch_nocreate" && args.size() > 2) {
+    if (args[1] == "touch_nocreate" && args.size() > 2) {
       for (std::string::size_type cc = 2; cc < args.size(); cc++) {
         // Complain if the file could not be removed, still exists,
         // and the -f option was not given.
@@ -522,8 +524,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       }
       return 0;
     }
+
     // capabilities
-    else if (args[1] == "capabilities") {
+    if (args[1] == "capabilities") {
       if (args.size() > 2) {
         std::cerr << "-E capabilities accepts no additional arguments\n";
         return 1;
@@ -538,7 +541,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Sleep command
-    else if (args[1] == "sleep" && args.size() > 2) {
+    if (args[1] == "sleep" && args.size() > 2) {
       double total = 0;
       for (size_t i = 2; i < args.size(); ++i) {
         double num = 0.0;
@@ -559,7 +562,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Clock command
-    else if (args[1] == "time" && args.size() > 2) {
+    if (args[1] == "time" && args.size() > 2) {
       std::vector<std::string> command(args.begin() + 2, args.end());
 
       clock_t clock_start, clock_finish;
@@ -583,8 +586,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
                 << "\n";
       return ret;
     }
+
     // Command to calculate the md5sum of a file
-    else if (args[1] == "md5sum" && args.size() >= 3) {
+    if (args[1] == "md5sum" && args.size() >= 3) {
       char md5out[32];
       int retval = 0;
       for (std::string::size_type cc = 2; cc < args.size(); cc++) {
@@ -606,7 +610,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Command to change directory and run a program.
-    else if (args[1] == "chdir" && args.size() >= 4) {
+    if (args[1] == "chdir" && args.size() >= 4) {
       std::string directory = args[2];
       if (!cmSystemTools::FileExists(directory.c_str())) {
         cmSystemTools::Error("Directory does not exist for chdir command: ",
@@ -628,7 +632,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Command to start progress for a build
-    else if (args[1] == "cmake_progress_start" && args.size() == 4) {
+    if (args[1] == "cmake_progress_start" && args.size() == 4) {
       // basically remove the directory
       std::string dirName = args[2];
       dirName += "/Progress";
@@ -660,7 +664,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Command to report progress for a build
-    else if (args[1] == "cmake_progress_report" && args.size() >= 3) {
+    if (args[1] == "cmake_progress_report" && args.size() >= 3) {
       // This has been superseded by cmake_echo_color --progress-*
       // options.  We leave it here to avoid errors if somehow this
       // is invoked by an existing makefile without regenerating.
@@ -669,7 +673,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
 
     // Command to create a symbolic link.  Fails on platforms not
     // supporting them.
-    else if (args[1] == "create_symlink" && args.size() == 4) {
+    if (args[1] == "create_symlink" && args.size() == 4) {
       const char* destinationFileName = args[3].c_str();
       if ((cmSystemTools::FileExists(destinationFileName) ||
            cmSystemTools::FileIsSymlink(destinationFileName)) &&
@@ -690,16 +694,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Internal CMake shared library support.
-    else if (args[1] == "cmake_symlink_library" && args.size() == 5) {
+    if (args[1] == "cmake_symlink_library" && args.size() == 5) {
       return cmcmd::SymlinkLibrary(args);
     }
+
     // Internal CMake versioned executable support.
-    else if (args[1] == "cmake_symlink_executable" && args.size() == 4) {
+    if (args[1] == "cmake_symlink_executable" && args.size() == 4) {
       return cmcmd::SymlinkExecutable(args);
     }
 
     // Internal CMake dependency scanning support.
-    else if (args[1] == "cmake_depends" && args.size() >= 6) {
+    if (args[1] == "cmake_depends" && args.size() >= 6) {
       const bool verbose = isCMakeVerbose();
 
       // Create a cmake object instance to process dependencies.
@@ -774,41 +779,47 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Internal CMake link script support.
-    else if (args[1] == "cmake_link_script" && args.size() >= 3) {
+    if (args[1] == "cmake_link_script" && args.size() >= 3) {
       return cmcmd::ExecuteLinkScript(args);
     }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
     // Internal CMake ninja dependency scanning support.
-    else if (args[1] == "cmake_ninja_depends") {
+    if (args[1] == "cmake_ninja_depends") {
       return cmcmd_cmake_ninja_depends(args.begin() + 2, args.end());
     }
 
     // Internal CMake ninja dyndep support.
-    else if (args[1] == "cmake_ninja_dyndep") {
+    if (args[1] == "cmake_ninja_dyndep") {
       return cmcmd_cmake_ninja_dyndep(args.begin() + 2, args.end());
     }
 #endif
 
     // Internal CMake unimplemented feature notification.
-    else if (args[1] == "cmake_unimplemented_variable") {
+    if (args[1] == "cmake_unimplemented_variable") {
       std::cerr << "Feature not implemented for this platform.";
       if (args.size() == 3) {
         std::cerr << "  Variable " << args[2] << " is not set.";
       }
       std::cerr << std::endl;
       return 1;
-    } else if (args[1] == "vs_link_exe") {
+    }
+
+    if (args[1] == "vs_link_exe") {
       return cmcmd::VisualStudioLink(args, 1);
-    } else if (args[1] == "vs_link_dll") {
+    }
+
+    if (args[1] == "vs_link_dll") {
       return cmcmd::VisualStudioLink(args, 2);
     }
+
     // Internal CMake color makefile support.
-    else if (args[1] == "cmake_echo_color") {
+    if (args[1] == "cmake_echo_color") {
       return cmcmd::ExecuteEchoColor(args);
     }
+
 #ifdef CMAKE_BUILD_WITH_CMAKE
-    else if (args[1] == "cmake_autogen" && args.size() >= 4) {
+    if (args[1] == "cmake_autogen" && args.size() >= 4) {
       cmQtAutoGenerators autogen;
       std::string const& config = args[3];
       bool autogenSuccess = autogen.Run(args[2], config);
@@ -817,7 +828,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
 #endif
 
     // Tar files
-    else if (args[1] == "tar" && args.size() > 3) {
+    if (args[1] == "tar" && args.size() > 3) {
       const char* knownFormats[] = { "7zip", "gnutar", "pax", "paxr", "zip" };
 
       std::string flags = args[2];
@@ -921,7 +932,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
 #endif
       }
       return 0;
-    } else if (args[1] == "server") {
+    }
+
+    if (args[1] == "server") {
       const std::string pipePrefix = "--pipe=";
       bool supportExperimental = false;
       bool isDebug = false;
@@ -958,28 +971,26 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       std::string errorMessage;
       if (server.Serve(&errorMessage)) {
         return 0;
-      } else {
-        cmSystemTools::Error(errorMessage.c_str());
-        return 1;
       }
+      cmSystemTools::Error(errorMessage.c_str());
 #else
       static_cast<void>(supportExperimental);
       static_cast<void>(isDebug);
       cmSystemTools::Error("CMake was not built with server mode enabled");
-      return 1;
 #endif
+      return 1;
     }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
     // Internal CMake Fortran module support.
-    else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) {
+    if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) {
       return cmDependsFortran::CopyModule(args) ? 0 : 1;
     }
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
     // Write registry value
-    else if (args[1] == "write_regv" && args.size() > 3) {
+    if (args[1] == "write_regv" && args.size() > 3) {
       return cmSystemTools::WriteRegistryValue(args[2].c_str(),
                                                args[3].c_str())
         ? 0
@@ -987,16 +998,21 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     }
 
     // Delete registry value
-    else if (args[1] == "delete_regv" && args.size() > 2) {
+    if (args[1] == "delete_regv" && args.size() > 2) {
       return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1;
     }
+
     // Remove file
-    else if (args[1] == "comspec" && args.size() > 2) {
+    if (args[1] == "comspec" && args.size() > 2) {
       std::cerr << "Win9x helper \"cmake -E comspec\" no longer supported\n";
       return 1;
-    } else if (args[1] == "env_vs8_wince" && args.size() == 3) {
+    }
+
+    if (args[1] == "env_vs8_wince" && args.size() == 3) {
       return cmcmd::WindowsCEEnvironment("8.0", args[2]);
-    } else if (args[1] == "env_vs9_wince" && args.size() == 3) {
+    }
+
+    if (args[1] == "env_vs9_wince" && args.size() == 3) {
       return cmcmd::WindowsCEEnvironment("9.0", args[2]);
     }
 #endif