瀏覽代碼

clang-tidy: fix `readability-string-compare` lints

Ben Boeckel 2 年之前
父節點
當前提交
d64adb9267
共有 3 個文件被更改,包括 26 次插入27 次删除
  1. 1 1
      Source/cmGlobalVisualStudio10Generator.cxx
  2. 3 3
      Source/cmVSSetupHelper.cxx
  3. 22 23
      Source/cmVisualStudioSlnParser.cxx

+ 1 - 1
Source/cmGlobalVisualStudio10Generator.cxx

@@ -1140,7 +1140,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
       std::string extension =
         cmSystemTools::GetFilenameLastExtension(proj->GetRelativePath());
       extension = cmSystemTools::LowerCase(extension);
-      if (extension.compare(".csproj") == 0) {
+      if (extension == ".csproj") {
         // Use correct platform name
         platform =
           slnData.GetConfigurationTarget(tname, plainConfig, platform);

+ 3 - 3
Source/cmVSSetupHelper.cxx

@@ -159,12 +159,12 @@ bool cmVSSetupAPIHelper::CheckInstalledComponent(
   // the
   // component name ex: Microsoft.VisualStudio.Component.Windows10SDK.10240
   if (id.find(Win10SDKComponent) != std::wstring::npos &&
-      type.compare(ComponentType) == 0) {
+      type == ComponentType) {
     bWin10SDK = true;
     ret = true;
   }
 
-  if (id.compare(Win81SDKComponent) == 0 && type.compare(ComponentType) == 0) {
+  if (id == Win81SDKComponent && type == ComponentType) {
     bWin81SDK = true;
     ret = true;
   }
@@ -405,7 +405,7 @@ bool cmVSSetupAPIHelper::EnumerateVSInstancesWithCOM(
 bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
 {
   bool isVSInstanceExists = false;
-  if (chosenInstanceInfo.VSInstallLocation.compare("") != 0) {
+  if (!chosenInstanceInfo.VSInstallLocation.empty()) {
     return true;
   }
 

+ 22 - 23
Source/cmVisualStudioSlnParser.cxx

@@ -206,7 +206,7 @@ bool cmVisualStudioSlnParser::State::Process(
       this->Stack.push(FileStateTopLevel);
       break;
     case FileStateTopLevel:
-      if (line.GetTag().compare("Project") == 0) {
+      if (line.GetTag() == "Project") {
         if (line.GetValueCount() != 3) {
           result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
           return false;
@@ -221,12 +221,12 @@ bool cmVisualStudioSlnParser::State::Process(
         } else {
           this->IgnoreUntilTag("EndProject");
         }
-      } else if (line.GetTag().compare("Global") == 0) {
+      } else if (line.GetTag() == "Global") {
 
         this->Stack.push(FileStateGlobal);
-      } else if (line.GetTag().compare("VisualStudioVersion") == 0) {
+      } else if (line.GetTag() == "VisualStudioVersion") {
         output.SetVisualStudioVersion(line.GetValue(0));
-      } else if (line.GetTag().compare("MinimumVisualStudioVersion") == 0) {
+      } else if (line.GetTag() == "MinimumVisualStudioVersion") {
         output.SetMinimumVisualStudioVersion(line.GetValue(0));
       } else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
@@ -234,11 +234,11 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateProject:
-      if (line.GetTag().compare("EndProject") == 0) {
+      if (line.GetTag() == "EndProject") {
         this->Stack.pop();
-      } else if (line.GetTag().compare("ProjectSection") == 0) {
-        if (line.GetArg().compare("ProjectDependencies") == 0 &&
-            line.GetValue(0).compare("postProject") == 0) {
+      } else if (line.GetTag() == "ProjectSection") {
+        if (line.GetArg() == "ProjectDependencies" &&
+            line.GetValue(0) == "postProject") {
           if (this->RequestedData.test(DataGroupProjectDependenciesBit)) {
             this->Stack.push(FileStateProjectDependencies);
           } else {
@@ -253,7 +253,7 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateProjectDependencies:
-      if (line.GetTag().compare("EndProjectSection") == 0) {
+      if (line.GetTag() == "EndProjectSection") {
         this->Stack.pop();
       } else if (line.IsKeyValuePair()) {
         // implement dependency storing here, once needed
@@ -264,26 +264,25 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateGlobal:
-      if (line.GetTag().compare("EndGlobal") == 0) {
+      if (line.GetTag() == "EndGlobal") {
         this->Stack.pop();
-      } else if (line.GetTag().compare("GlobalSection") == 0) {
-        if (line.GetArg().compare("SolutionConfigurationPlatforms") == 0 &&
-            line.GetValue(0).compare("preSolution") == 0) {
+      } else if (line.GetTag() == "GlobalSection") {
+        if (line.GetArg() == "SolutionConfigurationPlatforms" &&
+            line.GetValue(0) == "preSolution") {
           if (this->RequestedData.test(DataGroupSolutionConfigurationsBit)) {
             this->Stack.push(FileStateSolutionConfigurations);
           } else {
             this->IgnoreUntilTag("EndGlobalSection");
           }
-        } else if (line.GetArg().compare("ProjectConfigurationPlatforms") ==
-                     0 &&
-                   line.GetValue(0).compare("postSolution") == 0) {
+        } else if (line.GetArg() == "ProjectConfigurationPlatforms" &&
+                   line.GetValue(0) == "postSolution") {
           if (this->RequestedData.test(DataGroupProjectConfigurationsBit)) {
             this->Stack.push(FileStateProjectConfigurations);
           } else {
             this->IgnoreUntilTag("EndGlobalSection");
           }
-        } else if (line.GetArg().compare("NestedProjects") == 0 &&
-                   line.GetValue(0).compare("preSolution") == 0) {
+        } else if (line.GetArg() == "NestedProjects" &&
+                   line.GetValue(0) == "preSolution") {
           if (this->RequestedData.test(DataGroupSolutionFiltersBit)) {
             this->Stack.push(FileStateSolutionFilters);
           } else {
@@ -301,7 +300,7 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateSolutionConfigurations:
-      if (line.GetTag().compare("EndGlobalSection") == 0) {
+      if (line.GetTag() == "EndGlobalSection") {
         this->Stack.pop();
       } else if (line.IsKeyValuePair()) {
         output.AddConfiguration(line.GetValue(0));
@@ -311,7 +310,7 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateProjectConfigurations:
-      if (line.GetTag().compare("EndGlobalSection") == 0) {
+      if (line.GetTag() == "EndGlobalSection") {
         this->Stack.pop();
       } else if (line.IsKeyValuePair()) {
         std::vector<std::string> tagElements =
@@ -332,7 +331,7 @@ bool cmVisualStudioSlnParser::State::Process(
           return false;
         }
 
-        if (activeBuild.compare("ActiveCfg") == 0) {
+        if (activeBuild == "ActiveCfg") {
           projectEntry->AddProjectConfiguration(solutionConfiguration,
                                                 line.GetValue(0));
         }
@@ -342,7 +341,7 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateSolutionFilters:
-      if (line.GetTag().compare("EndGlobalSection") == 0) {
+      if (line.GetTag() == "EndGlobalSection") {
         this->Stack.pop();
       } else if (line.IsKeyValuePair()) {
         // implement filter storing here, once needed
@@ -353,7 +352,7 @@ bool cmVisualStudioSlnParser::State::Process(
       }
       break;
     case FileStateGlobalSection:
-      if (line.GetTag().compare("EndGlobalSection") == 0) {
+      if (line.GetTag() == "EndGlobalSection") {
         this->Stack.pop();
       } else if (line.IsKeyValuePair()) {
         // implement section storing here, once needed