diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-11-22 15:05:57 -0500 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2022-11-29 12:39:45 -0500 |
commit | 707172c66ee385474027aae5e1327c76abd96ce8 (patch) | |
tree | d5fc6e2549df4eabb301f1b063521364aee96a8f | |
parent | 501408338aa403d9af50b2ba60f816cec5dcc06b (diff) | |
download | cmake-707172c66ee385474027aae5e1327c76abd96ce8.tar.gz |
clang-tidy: fix `readability-use-anyofallof` lints
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 13 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 29 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 80 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 16 |
4 files changed, 55 insertions, 83 deletions
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a6e824009f..c375d6072a 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -737,13 +737,12 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( bool cmGlobalVisualStudio7Generator::IsDependedOn( OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn) { - for (cmTargetDepend const& l : projectTargets) { - TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(l); - if (tgtdeps.count(gtIn)) { - return true; - } - } - return false; + return std::any_of(projectTargets.begin(), projectTargets.end(), + [this, gtIn](cmTargetDepend const& l) { + TargetDependSet const& tgtdeps = + this->GetTargetDirectDepends(l); + return tgtdeps.count(gtIn); + }); } std::string cmGlobalVisualStudio7Generator::Encoding() diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index c57649f4ba..89fa5c7e3f 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -405,20 +405,23 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( cmGeneratorTarget* target) { // Look for utility dependencies that magically link. - for (BT<std::pair<std::string, bool>> const& ui : target->GetUtilities()) { - if (cmGeneratorTarget* depTarget = - target->GetLocalGenerator()->FindGeneratorTargetToUse( - ui.Value.first)) { - if (depTarget->IsInBuildSystem() && - depTarget->GetProperty("EXTERNAL_MSPROJECT")) { - // This utility dependency names an external .vcproj target. - // We use LinkLibraryDependencies="true" to link to it without - // predicting the .lib file location or name. - return true; + auto const& utilities = target->GetUtilities(); + return std::any_of( + utilities.begin(), utilities.end(), + [target](BT<std::pair<std::string, bool>> const& ui) { + if (cmGeneratorTarget* depTarget = + target->GetLocalGenerator()->FindGeneratorTargetToUse( + ui.Value.first)) { + if (depTarget->IsInBuildSystem() && + depTarget->GetProperty("EXTERNAL_MSPROJECT")) { + // This utility dependency names an external .vcproj target. + // We use LinkLibraryDependencies="true" to link to it without + // predicting the .lib file location or name. + return true; + } } - } - } - return false; + return false; + }); } static cmVS7FlagTable cmVS8ExtraFlagTable[] = { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 87b13016c1..d9886243bb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1056,14 +1056,11 @@ bool cmVisualStudio10TargetGenerator::HasCustomCommands() const return true; } - for (cmGeneratorTarget::AllConfigSource const& si : - this->GeneratorTarget->GetAllConfigSources()) { - if (si.Source->GetCustomCommand()) { - return true; - } - } - - return false; + auto const& config_sources = this->GeneratorTarget->GetAllConfigSources(); + return std::any_of(config_sources.begin(), config_sources.end(), + [](cmGeneratorTarget::AllConfigSource const& si) { + return si.Source->GetCustomCommand(); + }); } void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) @@ -3069,12 +3066,9 @@ std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes( bool cmVisualStudio10TargetGenerator::ComputeClOptions() { - for (std::string const& c : this->Configurations) { - if (!this->ComputeClOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeClOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeClOptions( @@ -3445,12 +3439,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( bool cmVisualStudio10TargetGenerator::ComputeRcOptions() { - for (std::string const& c : this->Configurations) { - if (!this->ComputeRcOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeRcOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeRcOptions( @@ -3499,13 +3490,12 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions() if (!this->GlobalGenerator->IsCudaEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (this->GeneratorTarget->IsLanguageUsed("CUDA", c) && - !this->ComputeCudaOptions(c)) { - return false; - } - } - return true; + return std::all_of(this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { + return !this->GeneratorTarget->IsLanguageUsed("CUDA", + c) || + this->ComputeCudaOptions(c); + }); } bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( @@ -3675,12 +3665,9 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions() if (!this->GlobalGenerator->IsCudaEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeCudaLinkOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeCudaLinkOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions( @@ -3774,12 +3761,9 @@ bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions() if (!this->GlobalGenerator->IsMarmasmEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeMarmasmOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeMarmasmOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions( @@ -3827,12 +3811,9 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions() if (!this->GlobalGenerator->IsMasmEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeMasmOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeMasmOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeMasmOptions( @@ -3880,12 +3861,9 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions() if (!this->GlobalGenerator->IsNasmEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeNasmOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeNasmOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeNasmOptions( diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 763f676c67..6e9887456b 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -137,22 +137,14 @@ bool cmVisualStudioGeneratorOptions::IsManaged() const bool cmVisualStudioGeneratorOptions::UsingUnicode() const { // Look for a _UNICODE definition. - for (std::string const& di : this->Defines) { - if (di == "_UNICODE") { - return true; - } - } - return false; + return std::any_of(this->Defines.begin(), this->Defines.end(), + [](std::string const& di) { return di == "_UNICODE"; }); } bool cmVisualStudioGeneratorOptions::UsingSBCS() const { // Look for a _SBCS definition. - for (std::string const& di : this->Defines) { - if (di == "_SBCS") { - return true; - } - } - return false; + return std::any_of(this->Defines.begin(), this->Defines.end(), + [](std::string const& di) { return di == "_SBCS"; }); } void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() |