From d64adb9267213c0031b376633b70707ddcfc9ba6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 22 Nov 2022 14:42:54 -0500 Subject: clang-tidy: fix `readability-string-compare` lints --- Source/cmGlobalVisualStudio10Generator.cxx | 2 +- Source/cmVSSetupHelper.cxx | 6 ++-- Source/cmVisualStudioSlnParser.cxx | 45 +++++++++++++++--------------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6931301..6154d8e 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/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); diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index e4cbe49..5729d2f 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/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; } diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 756245d..71c758e 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/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 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 -- cgit v0.12