[clang] 0e9373a - [Basic] Use llvm::is_contained (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 10 08:52:27 PDT 2021
Author: Kazu Hirata
Date: 2021-10-10T08:52:14-07:00
New Revision: 0e9373a6a638430c67fa8378c774003acfcf5990
URL: https://github.com/llvm/llvm-project/commit/0e9373a6a638430c67fa8378c774003acfcf5990
DIFF: https://github.com/llvm/llvm-project/commit/0e9373a6a638430c67fa8378c774003acfcf5990.diff
LOG: [Basic] Use llvm::is_contained (NFC)
Added:
Modified:
clang/lib/Basic/Module.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/AVR.cpp
clang/lib/Basic/Targets/BPF.cpp
clang/lib/Basic/Targets/Mips.cpp
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/Sparc.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/X86.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 4ec0699e40d49..09bd3251fea0c 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -121,9 +121,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
.Default(Target.hasFeature(Feature) ||
isPlatformEnvironment(Target, Feature));
if (!HasFeature)
- HasFeature = std::find(LangOpts.ModuleFeatures.begin(),
- LangOpts.ModuleFeatures.end(),
- Feature) != LangOpts.ModuleFeatures.end();
+ HasFeature = llvm::is_contained(LangOpts.ModuleFeatures, Feature);
return HasFeature;
}
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 700b76452eea2..8b9d7ce79c16f 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -440,7 +440,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
WavefrontSize = 64;
bool IsOn = F.front() == '+';
StringRef Name = StringRef(F).drop_front();
- if (llvm::find(TargetIDFeatures, Name) == TargetIDFeatures.end())
+ if (!llvm::is_contained(TargetIDFeatures, Name))
return;
assert(OffloadArchFeatures.find(Name) == OffloadArchFeatures.end());
OffloadArchFeatures[Name] = IsOn;
diff --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index 8fa19064d41f7..38ce61386bb4c 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -311,8 +311,7 @@ static constexpr llvm::StringLiteral ValidFamilyNames[] = {
"avrxmega6", "avrxmega7", "avrtiny"};
bool AVRTargetInfo::isValidCPUName(StringRef Name) const {
- bool IsFamily =
- llvm::find(ValidFamilyNames, Name) != std::end(ValidFamilyNames);
+ bool IsFamily = llvm::is_contained(ValidFamilyNames, Name);
bool IsMCU =
llvm::find_if(AVRMcus, [&](const MCUInfo &Info) {
diff --git a/clang/lib/Basic/Targets/BPF.cpp b/clang/lib/Basic/Targets/BPF.cpp
index 0b0298df30a57..2dfe21564cc1a 100644
--- a/clang/lib/Basic/Targets/BPF.cpp
+++ b/clang/lib/Basic/Targets/BPF.cpp
@@ -35,7 +35,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
"v3", "probe"};
bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
- return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
+ return llvm::is_contained(ValidCPUNames, Name);
}
void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 3a32fd492c6bb..39246f650cce2 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -50,7 +50,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {
{"octeon"}, {"octeon+"}, {"p5600"}};
bool MipsTargetInfo::isValidCPUName(StringRef Name) const {
- return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
+ return llvm::is_contained(ValidCPUNames, Name);
}
void MipsTargetInfo::fillValidCPUList(
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 26be2bd9c5d7b..da21e97885dec 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -437,11 +437,11 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
const std::vector<std::string> &FeaturesVec) {
// vsx was not explicitly turned off.
- if (llvm::find(FeaturesVec, "-vsx") == FeaturesVec.end())
+ if (!llvm::is_contained(FeaturesVec, "-vsx"))
return true;
auto FindVSXSubfeature = [&](StringRef Feature, StringRef Option) {
- if (llvm::find(FeaturesVec, Feature) != FeaturesVec.end()) {
+ if (llvm::is_contained(FeaturesVec, Feature)) {
Diags.Report(diag::err_opt_not_valid_with_opt) << Option << "-mno-vsx";
return true;
}
@@ -562,28 +562,28 @@ bool PPCTargetInfo::initFeatureMap(
return false;
if (!(ArchDefs & ArchDefinePwr9) && (ArchDefs & ArchDefinePpcgr) &&
- llvm::find(FeaturesVec, "+float128") != FeaturesVec.end()) {
+ llvm::is_contained(FeaturesVec, "+float128")) {
// We have __float128 on PPC but not power 9 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" << CPU;
return false;
}
if (!(ArchDefs & ArchDefinePwr10) &&
- llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
+ llvm::is_contained(FeaturesVec, "+mma")) {
// We have MMA on PPC but not power 10 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
return false;
}
if (!(ArchDefs & ArchDefinePwr8) &&
- llvm::find(FeaturesVec, "+rop-protect") != FeaturesVec.end()) {
+ llvm::is_contained(FeaturesVec, "+rop-protect")) {
// We can turn on ROP Protect on Power 8 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mrop-protect" << CPU;
return false;
}
if (!(ArchDefs & ArchDefinePwr8) &&
- llvm::find(FeaturesVec, "+privileged") != FeaturesVec.end()) {
+ llvm::is_contained(FeaturesVec, "+privileged")) {
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mprivileged" << CPU;
return false;
}
@@ -782,7 +782,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {
{"powerpc64le"}, {"ppc64le"}, {"future"}};
bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
- return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
+ return llvm::is_contained(ValidCPUNames, Name);
}
void PPCTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 07844abafe11b..22a1621fcb9fe 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -39,10 +39,8 @@ class LLVM_LIBRARY_VISIBILITY SparcTargetInfo : public TargetInfo {
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
// Check if software floating point is enabled
- auto Feature = llvm::find(Features, "+soft-float");
- if (Feature != Features.end()) {
+ if (llvm::is_contained(Features, "+soft-float"))
SoftFloat = true;
- }
return true;
}
void getTargetDefines(const LangOptions &Opts,
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 61c35e65fccc1..4cba861f61d2c 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -60,7 +60,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
}
bool WebAssemblyTargetInfo::isValidCPUName(StringRef Name) const {
- return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
+ return llvm::is_contained(ValidCPUNames, Name);
}
void WebAssemblyTargetInfo::fillValidCPUList(
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index b8b15074c9ca9..f40d8a6ed7312 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -139,26 +139,26 @@ bool X86TargetInfo::initFeatureMap(
// Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
auto I = Features.find("sse4.2");
if (I != Features.end() && I->getValue() &&
- llvm::find(UpdatedFeaturesVec, "-popcnt") == UpdatedFeaturesVec.end())
+ !llvm::is_contained(UpdatedFeaturesVec, "-popcnt"))
Features["popcnt"] = true;
// Additionally, if SSE is enabled and mmx is not explicitly disabled,
// then enable MMX.
I = Features.find("sse");
if (I != Features.end() && I->getValue() &&
- llvm::find(UpdatedFeaturesVec, "-mmx") == UpdatedFeaturesVec.end())
+ !llvm::is_contained(UpdatedFeaturesVec, "-mmx"))
Features["mmx"] = true;
// Enable xsave if avx is enabled and xsave is not explicitly disabled.
I = Features.find("avx");
if (I != Features.end() && I->getValue() &&
- llvm::find(UpdatedFeaturesVec, "-xsave") == UpdatedFeaturesVec.end())
+ !llvm::is_contained(UpdatedFeaturesVec, "-xsave"))
Features["xsave"] = true;
// Enable CRC32 if SSE4.2 is enabled and CRC32 is not explicitly disabled.
I = Features.find("sse4.2");
if (I != Features.end() && I->getValue() &&
- llvm::find(UpdatedFeaturesVec, "-crc32") == UpdatedFeaturesVec.end())
+ !llvm::is_contained(UpdatedFeaturesVec, "-crc32"))
Features["crc32"] = true;
return true;
More information about the cfe-commits
mailing list