diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp index d9dba9a05ac4b3..cf991a16307bc4 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 &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 107044647f0822..100f5d876513a5 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 acb1d2524f4260..1c17b8408ee7b5 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 ToRemove) { DenseSet AssociatedSections; auto RemoveAssociated = [&AssociatedSections](const Section &Sec) { - return AssociatedSections.count(Sec.UniqueId) == 1; + return AssociatedSections.contains(Sec.UniqueId); }; do { DenseSet RemovedSections; @@ -109,7 +109,7 @@ void Object::removeSections(function_ref 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 4376802d41ee45..fef4a0ae559429 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");