[llvm-branch-commits] [llvm] 8590a3e - [llvm] Use *Set::contains (NFC)
Kazu Hirata via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 11 18:53:26 PST 2021
Author: Kazu Hirata
Date: 2021-01-11T18:48:07-08:00
New Revision: 8590a3e3adceff1ff1f606fa68ce4622181ecae2
URL: https://github.com/llvm/llvm-project/commit/8590a3e3adceff1ff1f606fa68ce4622181ecae2
DIFF: https://github.com/llvm/llvm-project/commit/8590a3e3adceff1ff1f606fa68ce4622181ecae2.diff
LOG: [llvm] Use *Set::contains (NFC)
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
llvm/tools/llvm-objcopy/COFF/Object.cpp
llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
index d9dba9a05ac4..cf991a16307b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
@@ -2574,7 +2574,7 @@ static void removeOldExitPreds(RegionMRT *Region) {
static bool mbbHasBackEdge(MachineBasicBlock *MBB,
SmallPtrSet<MachineBasicBlock *, 8> &MBBs) {
for (auto SI = MBB->succ_begin(), SE = MBB->succ_end(); SI != SE; ++SI) {
- if (MBBs.count(*SI) != 0) {
+ if (MBBs.contains(*SI)) {
return true;
}
}
diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
index 107044647f08..100f5d876513 100644
--- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
+++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
@@ -179,7 +179,7 @@ bool FileAnalysis::willTrapOnCFIViolation(const Instr &InstrMeta) const {
if (!MIA->evaluateBranch(InstrMeta.Instruction, InstrMeta.VMAddress,
InstrMeta.InstructionSize, Target))
return false;
- return TrapOnFailFunctionAddresses.count(Target) > 0;
+ return TrapOnFailFunctionAddresses.contains(Target);
}
bool FileAnalysis::canFallThrough(const Instr &InstrMeta) const {
@@ -558,7 +558,7 @@ Error FileAnalysis::parseSymbolTable() {
auto SymNameOrErr = Sym.getName();
if (!SymNameOrErr)
consumeError(SymNameOrErr.takeError());
- else if (TrapOnFailFunctions.count(*SymNameOrErr) > 0) {
+ else if (TrapOnFailFunctions.contains(*SymNameOrErr)) {
auto AddrOrErr = Sym.getAddress();
if (!AddrOrErr)
consumeError(AddrOrErr.takeError());
@@ -574,7 +574,7 @@ Error FileAnalysis::parseSymbolTable() {
auto SymNameOrErr = Sym.getName();
if (!SymNameOrErr)
consumeError(SymNameOrErr.takeError());
- else if (TrapOnFailFunctions.count(*SymNameOrErr) > 0)
+ else if (TrapOnFailFunctions.contains(*SymNameOrErr))
TrapOnFailFunctionAddresses.insert(Addr.second);
}
}
diff --git a/llvm/tools/llvm-objcopy/COFF/Object.cpp b/llvm/tools/llvm-objcopy/COFF/Object.cpp
index acb1d2524f42..1c17b8408ee7 100644
--- a/llvm/tools/llvm-objcopy/COFF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/COFF/Object.cpp
@@ -89,7 +89,7 @@ const Section *Object::findSection(ssize_t UniqueId) const {
void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
DenseSet<ssize_t> AssociatedSections;
auto RemoveAssociated = [&AssociatedSections](const Section &Sec) {
- return AssociatedSections.count(Sec.UniqueId) == 1;
+ return AssociatedSections.contains(Sec.UniqueId);
};
do {
DenseSet<ssize_t> RemovedSections;
@@ -109,7 +109,7 @@ void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
// leave them dangling).
if (RemovedSections.count(Sym.AssociativeComdatTargetSectionId) == 1)
AssociatedSections.insert(Sym.TargetSectionId);
- return RemovedSections.count(Sym.TargetSectionId) == 1;
+ return RemovedSections.contains(Sym.TargetSectionId);
});
ToRemove = RemoveAssociated;
} while (!AssociatedSections.empty());
diff --git a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
index 4376802d41ee..fef4a0ae5594 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -178,10 +178,10 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
for (const auto &OldNew : Config.RPathsToUpdate) {
StringRef Old = OldNew.getFirst();
StringRef New = OldNew.getSecond();
- if (RPaths.count(Old) == 0)
+ if (!RPaths.contains(Old))
return createStringError(errc::invalid_argument,
"no LC_RPATH load command with path: " + Old);
- if (RPaths.count(New) != 0)
+ if (RPaths.contains(New))
return createStringError(errc::invalid_argument,
"rpath '" + New +
"' would create a duplicate load command");
@@ -220,7 +220,7 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
// Add new RPaths.
for (StringRef RPath : Config.RPathToAdd) {
- if (RPaths.count(RPath) != 0)
+ if (RPaths.contains(RPath))
return createStringError(errc::invalid_argument,
"rpath '" + RPath +
"' would create a duplicate load command");
@@ -229,7 +229,7 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
}
for (StringRef RPath : Config.RPathToPrepend) {
- if (RPaths.count(RPath) != 0)
+ if (RPaths.contains(RPath))
return createStringError(errc::invalid_argument,
"rpath '" + RPath +
"' would create a duplicate load command");
More information about the llvm-branch-commits
mailing list