clang-tidy: fix readability-use-anyofallof lints

This commit is contained in:
Ben Boeckel
2022-11-22 15:05:57 -05:00
parent 501408338a
commit 707172c66e
4 changed files with 55 additions and 83 deletions

View File

@@ -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()

View File

@@ -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[] = {

View File

@@ -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(

View File

@@ -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()