From: Kazu Hirata Date: Wed, 15 Mar 2023 01:56:06 +0000 (-0700) Subject: [llvm] Use *{Set,Map}::contains (NFC) X-Git-Tag: upstream/17.0.6~14774 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b595eb83e5c128ee969fb6491372438ea1974169;p=platform%2Fupstream%2Fllvm.git [llvm] Use *{Set,Map}::contains (NFC) --- diff --git a/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h b/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h index c05f770..9882c48 100644 --- a/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h +++ b/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h @@ -269,7 +269,7 @@ public: bool isLQFull() const { return LQSize && LQSize == UsedLQEntries; } bool isValidGroupID(unsigned Index) const { - return Index && (Groups.find(Index) != Groups.end()); + return Index && Groups.contains(Index); } /// Check if a peviously dispatched instruction IR is now ready for execution. diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index ec963c2..ebebe05 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -493,8 +493,7 @@ Expected Pattern::parseNumericVariableDefinition( // Detect collisions between string and numeric variables when the latter // is created later than the former. - if (Context->DefinedVariableTable.find(Name) != - Context->DefinedVariableTable.end()) + if (Context->DefinedVariableTable.contains(Name)) return ErrorDiagnostic::get( SM, Name, "string variable with name '" + Name + "' already exists"); @@ -1072,8 +1071,7 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix, // Detect collisions between string and numeric variables when the // former is created later than the latter. - if (Context->GlobalNumericVariableTable.find(Name) != - Context->GlobalNumericVariableTable.end()) { + if (Context->GlobalNumericVariableTable.contains(Name)) { SM.PrintMessage( SMLoc::getFromPointer(Name.data()), SourceMgr::DK_Error, "numeric variable with name '" + Name + "' already exists"); @@ -2753,8 +2751,7 @@ Error FileCheckPatternContext::defineCmdlineVariables( // Detect collisions between string and numeric variables when the former // is created later than the latter. - if (GlobalNumericVariableTable.find(Name) != - GlobalNumericVariableTable.end()) { + if (GlobalNumericVariableTable.contains(Name)) { Errs = joinErrors(std::move(Errs), ErrorDiagnostic::get(SM, Name, "numeric variable with name '" + diff --git a/llvm/lib/IR/SafepointIRVerifier.cpp b/llvm/lib/IR/SafepointIRVerifier.cpp index 5d3fa28..ed99d05 100644 --- a/llvm/lib/IR/SafepointIRVerifier.cpp +++ b/llvm/lib/IR/SafepointIRVerifier.cpp @@ -485,9 +485,7 @@ public: InstructionVerifier &Verifier); /// Returns true for reachable and live blocks. - bool isMapped(const BasicBlock *BB) const { - return BlockMap.find(BB) != BlockMap.end(); - } + bool isMapped(const BasicBlock *BB) const { return BlockMap.contains(BB); } private: /// Returns true if the instruction may be safely skipped during verification. diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp index 5d09630..036d821 100644 --- a/llvm/lib/MC/MCParser/MasmParser.cpp +++ b/llvm/lib/MC/MCParser/MasmParser.cpp @@ -479,7 +479,7 @@ public: void addDirectiveHandler(StringRef Directive, ExtensionDirectiveHandler Handler) override { ExtensionDirectiveMap[Directive] = Handler; - if (DirectiveKindMap.find(Directive) == DirectiveKindMap.end()) { + if (!DirectiveKindMap.contains(Directive)) { DirectiveKindMap[Directive] = DK_HANDLER_DIRECTIVE; } } @@ -6260,9 +6260,9 @@ bool MasmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) { parseEOL()) return true; - if (BuiltinSymbolMap.find(Name.lower()) != BuiltinSymbolMap.end()) { + if (BuiltinSymbolMap.contains(Name.lower())) { is_defined = true; - } else if (Variables.find(Name.lower()) != Variables.end()) { + } else if (Variables.contains(Name.lower())) { is_defined = true; } else { MCSymbol *Sym = getContext().lookupSymbol(Name.lower()); @@ -6381,9 +6381,9 @@ bool MasmParser::parseDirectiveElseIfdef(SMLoc DirectiveLoc, parseEOL()) return true; - if (BuiltinSymbolMap.find(Name.lower()) != BuiltinSymbolMap.end()) { + if (BuiltinSymbolMap.contains(Name.lower())) { is_defined = true; - } else if (Variables.find(Name.lower()) != Variables.end()) { + } else if (Variables.contains(Name.lower())) { is_defined = true; } else { MCSymbol *Sym = getContext().lookupSymbol(Name); @@ -6551,9 +6551,9 @@ bool MasmParser::parseDirectiveErrorIfdef(SMLoc DirectiveLoc, if (check(parseIdentifier(Name), "expected identifier after '.errdef'")) return true; - if (BuiltinSymbolMap.find(Name.lower()) != BuiltinSymbolMap.end()) { + if (BuiltinSymbolMap.contains(Name.lower())) { IsDefined = true; - } else if (Variables.find(Name.lower()) != Variables.end()) { + } else if (Variables.contains(Name.lower())) { IsDefined = true; } else { MCSymbol *Sym = getContext().lookupSymbol(Name); diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp index ab6acf0..f5d26d1 100644 --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -583,7 +583,7 @@ void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm, // If we could not find the symbol directly in SymbolIndexMap, this symbol // could either be a temporary symbol or an undefined symbol. In this case, // we would need to have the relocation reference its csect instead. - return SymbolIndexMap.find(Sym) != SymbolIndexMap.end() + return SymbolIndexMap.contains(Sym) ? SymbolIndexMap[Sym] : SymbolIndexMap[ContainingCsect->getQualNameSymbol()]; }; diff --git a/llvm/lib/MCA/InstrBuilder.cpp b/llvm/lib/MCA/InstrBuilder.cpp index 7f3a4bb..7ca5513 100644 --- a/llvm/lib/MCA/InstrBuilder.cpp +++ b/llvm/lib/MCA/InstrBuilder.cpp @@ -612,7 +612,7 @@ InstrBuilder::getOrCreateInstrDesc(const MCInst &MCI, unsigned CPUID = STI.getSchedModel().getProcessorID(); SchedClassID = STI.resolveVariantSchedClass(SchedClassID, &MCI, &MCII, CPUID); auto VDKey = std::make_pair(&MCI, SchedClassID); - if (VariantDescriptors.find(VDKey) != VariantDescriptors.end()) + if (VariantDescriptors.contains(VDKey)) return *VariantDescriptors[VDKey]; return createInstrDescImpl(MCI, IVec); diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index af3c27e..8fd42b7 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -200,7 +200,7 @@ void InstrProfWriter::overlapRecord(NamedInstrProfRecord &&Other, auto Name = Other.Name; auto Hash = Other.Hash; Other.accumulateCounts(FuncLevelOverlap.Test); - if (FunctionData.find(Name) == FunctionData.end()) { + if (!FunctionData.contains(Name)) { Overlap.addOneUnique(FuncLevelOverlap.Test); return; } diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 6663250..92e69db 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -208,8 +208,7 @@ public: bool HadErrors = false; if (O->hasArgStr()) { // If it's a DefaultOption, check to make sure it isn't already there. - if (O->isDefaultOption() && - SC->OptionsMap.find(O->ArgStr) != SC->OptionsMap.end()) + if (O->isDefaultOption() && SC->OptionsMap.contains(O->ArgStr)) return; // Add argument to the argument map! diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp index 0fb65ac..4650347 100644 --- a/llvm/lib/Support/SpecialCaseList.cpp +++ b/llvm/lib/Support/SpecialCaseList.cpp @@ -175,7 +175,7 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB, StringRef Category = SplitRegexp.second; // Create this section if it has not been seen before. - if (SectionsMap.find(Section) == SectionsMap.end()) { + if (!SectionsMap.contains(Section)) { std::unique_ptr M = std::make_unique(); std::string REError; if (!M->insert(std::string(Section), LineNo, REError)) { diff --git a/llvm/tools/llvm-mca/CodeRegion.h b/llvm/tools/llvm-mca/CodeRegion.h index b5b2f3a..f9b999f 100644 --- a/llvm/tools/llvm-mca/CodeRegion.h +++ b/llvm/tools/llvm-mca/CodeRegion.h @@ -167,7 +167,7 @@ public: bool isValid() const { return !FoundErrors; } bool isRegionActive(llvm::StringRef Description) const { - return ActiveRegions.find(Description) != ActiveRegions.end(); + return ActiveRegions.contains(Description); } }; diff --git a/llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp b/llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp index c2d6a703..b254ccd 100644 --- a/llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp +++ b/llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp @@ -52,7 +52,7 @@ void PressureTracker::getResourceUsers(uint64_t ResourceMask, const MCProcResourceDesc &PRDesc = *SM.getProcResource(ProcResID); for (unsigned I = 0, E = PRDesc.NumUnits; I < E; ++I) { const User U = getResourceUser(ProcResID, I); - if (U.second && IPI.find(U.first) != IPI.end()) + if (U.second && IPI.contains(U.first)) Users.emplace_back(U); } } diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index e27d0be..28c4db6 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -635,7 +635,7 @@ adjustInstrProfile(std::unique_ptr &WC, } } - if (StaticFuncMap.find(NewName) == StaticFuncMap.end()) { + if (!StaticFuncMap.contains(NewName)) { StaticFuncMap[NewName] = Name; } else { StaticFuncMap[NewName] = DuplicateNameStr; diff --git a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp index 1286ec9..ef84ed5 100644 --- a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp +++ b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp @@ -232,7 +232,8 @@ static bool FindExactlyAttributes(RetainedKnowledgeMap &Map, Value *WasOn, }) { bool ShouldHaveAttr = Reg.match(Attr, &Matches) && Matches[0] == Attr; - if (ShouldHaveAttr != (Map.find(RetainedKnowledgeKey{WasOn, Attribute::getAttrKindFromName(Attr)}) != Map.end())) + if (ShouldHaveAttr != (Map.contains(RetainedKnowledgeKey{ + WasOn, Attribute::getAttrKindFromName(Attr)}))) return false; } return true; diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp index b19fe55..8963156 100644 --- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp +++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp @@ -27,7 +27,7 @@ public: void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) override { // If we've seen this module before, note that. const std::string ModuleID = M->getModuleIdentifier(); - if (ObjMap.find(ModuleID) != ObjMap.end()) + if (ObjMap.contains(ModuleID)) DuplicateInserted = true; // Store a copy of the buffer in our map. ObjMap[ModuleID] = copyBuffer(Obj); @@ -47,8 +47,7 @@ public: bool wereDuplicatesInserted() { return DuplicateInserted; } bool wasModuleLookedUp(const Module *M) { - return ModulesLookedUp.find(M->getModuleIdentifier()) - != ModulesLookedUp.end(); + return ModulesLookedUp.contains(M->getModuleIdentifier()); } const MemoryBuffer* getObjectInternal(const Module* M) { diff --git a/llvm/unittests/Support/FileCollectorTest.cpp b/llvm/unittests/Support/FileCollectorTest.cpp index 0e8e450..184d0e3 100644 --- a/llvm/unittests/Support/FileCollectorTest.cpp +++ b/llvm/unittests/Support/FileCollectorTest.cpp @@ -35,9 +35,7 @@ public: using FileCollector::Seen; using FileCollector::VFSWriter; - bool hasSeen(StringRef fs) { - return Seen.find(fs) != Seen.end(); - } + bool hasSeen(StringRef fs) { return Seen.contains(fs); } }; } // end anonymous namespace diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index eec4de4..8b9cfee 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -2000,9 +2000,8 @@ bool TreePatternNode::isIsomorphicTo(const TreePatternNode *N, if (isLeaf()) { if (DefInit *DI = dyn_cast(getLeafValue())) { if (DefInit *NDI = dyn_cast(N->getLeafValue())) { - return ((DI->getDef() == NDI->getDef()) - && (DepVars.find(getName()) == DepVars.end() - || getName() == N->getName())); + return ((DI->getDef() == NDI->getDef()) && + (!DepVars.contains(getName()) || getName() == N->getName())); } } return getLeafValue() == N->getLeafValue(); diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index 8c0dac3..04219a6 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/CodeGenSchedule.cpp @@ -298,12 +298,12 @@ processSTIPredicate(STIPredicateFunction &Fn, RecVec Classes = Def->getValueAsListOfDefs("Classes"); for (const Record *EC : Classes) { const Record *Pred = EC->getValueAsDef("Predicate"); - if (Predicate2Index.find(Pred) == Predicate2Index.end()) + if (!Predicate2Index.contains(Pred)) Predicate2Index[Pred] = NumUniquePredicates++; RecVec Opcodes = EC->getValueAsListOfDefs("Opcodes"); for (const Record *Opcode : Opcodes) { - if (Opcode2Index.find(Opcode) == Opcode2Index.end()) { + if (!Opcode2Index.contains(Opcode)) { Opcode2Index[Opcode] = OpcodeMappings.size(); OpcodeMappings.emplace_back(Opcode, OpcodeInfo()); } diff --git a/llvm/utils/TableGen/DXILEmitter.cpp b/llvm/utils/TableGen/DXILEmitter.cpp index 33a2f73..5239cb7 100644 --- a/llvm/utils/TableGen/DXILEmitter.cpp +++ b/llvm/utils/TableGen/DXILEmitter.cpp @@ -322,7 +322,7 @@ static void emitDXILOperationTable(std::vector &DXILOps, for (auto &DXILOp : DXILOps) { OpStrings.add(DXILOp.DXILOp.str()); - if (ClassSet.find(DXILOp.DXILClass) != ClassSet.end()) + if (ClassSet.contains(DXILOp.DXILClass)) continue; ClassSet.insert(DXILOp.DXILClass); OpClassStrings.add(getDXILOpClassName(DXILOp.DXILClass)); diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index 70f38ae..dfeb7aa 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -3369,7 +3369,7 @@ unsigned RuleMatcher::getInsnVarID(InstructionMatcher &InsnMatcher) const { } void RuleMatcher::defineOperand(StringRef SymbolicName, OperandMatcher &OM) { - if (DefinedOperands.find(SymbolicName) == DefinedOperands.end()) { + if (!DefinedOperands.contains(SymbolicName)) { DefinedOperands[SymbolicName] = &OM; return; } @@ -3383,7 +3383,7 @@ void RuleMatcher::defineOperand(StringRef SymbolicName, OperandMatcher &OM) { } void RuleMatcher::definePhysRegOperand(Record *Reg, OperandMatcher &OM) { - if (PhysRegOperands.find(Reg) == PhysRegOperands.end()) { + if (!PhysRegOperands.contains(Reg)) { PhysRegOperands[Reg] = &OM; return; }