diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h index 5d503f2d2d727f..c423466fe75be6 100644 --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -796,10 +796,7 @@ class FunctionSamples { return Name; assert(GUIDToFuncNameMap && "GUIDToFuncNameMap needs to be popluated first"); - auto iter = GUIDToFuncNameMap->find(std::stoull(Name.data())); - if (iter == GUIDToFuncNameMap->end()) - return StringRef(); - return iter->second; + return GUIDToFuncNameMap->lookup(std::stoull(Name.data())); } /// Returns the line offset to the start line of the subprogram. diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 1b9436d56fdb1a..c8578f9ce32cb0 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -531,11 +531,7 @@ Option *CommandLineParser::LookupOption(SubCommand &Sub, StringRef &Arg, // If we have an equals sign, remember the value. if (EqualPos == StringRef::npos) { // Look up the option. - auto I = Sub.OptionsMap.find(Arg); - if (I == Sub.OptionsMap.end()) - return nullptr; - - return I != Sub.OptionsMap.end() ? I->second : nullptr; + return Sub.OptionsMap.lookup(Arg); } // If the argument before the = is a valid option name and the option allows diff --git a/llvm/tools/llvm-objcopy/COFF/Object.cpp b/llvm/tools/llvm-objcopy/COFF/Object.cpp index a706000c0df46d..acb1d2524f4260 100644 --- a/llvm/tools/llvm-objcopy/COFF/Object.cpp +++ b/llvm/tools/llvm-objcopy/COFF/Object.cpp @@ -31,10 +31,7 @@ void Object::updateSymbols() { } const Symbol *Object::findSymbol(size_t UniqueId) const { - auto It = SymbolMap.find(UniqueId); - if (It == SymbolMap.end()) - return nullptr; - return It->second; + return SymbolMap.lookup(UniqueId); } Error Object::removeSymbols( @@ -86,10 +83,7 @@ void Object::updateSections() { } const Section *Object::findSection(ssize_t UniqueId) const { - auto It = SectionMap.find(UniqueId); - if (It == SectionMap.end()) - return nullptr; - return It->second; + return SectionMap.lookup(UniqueId); } void Object::removeSections(function_ref ToRemove) { diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp index a24691589cee77..f520c1dbc5d2b4 100644 --- a/llvm/utils/TableGen/CodeGenRegisters.cpp +++ b/llvm/utils/TableGen/CodeGenRegisters.cpp @@ -1238,8 +1238,7 @@ CodeGenSubRegIndex *CodeGenRegBank::getSubRegIdx(Record *Def) { const CodeGenSubRegIndex * CodeGenRegBank::findSubRegIdx(const Record* Def) const { - auto I = Def2SubRegIdx.find(Def); - return (I == Def2SubRegIdx.end()) ? nullptr : I->second; + return Def2SubRegIdx.lookup(Def); } CodeGenRegister *CodeGenRegBank::getReg(Record *Def) { diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp index d31405af1c7bf8..2cfcd1820cc1d8 100644 --- a/llvm/utils/TableGen/CodeGenTarget.cpp +++ b/llvm/utils/TableGen/CodeGenTarget.cpp @@ -393,11 +393,7 @@ void CodeGenTarget::ReadRegAltNameIndices() const { /// getRegisterByName - If there is a register with the specific AsmName, /// return it. const CodeGenRegister *CodeGenTarget::getRegisterByName(StringRef Name) const { - const StringMap &Regs = getRegBank().getRegistersByName(); - StringMap::const_iterator I = Regs.find(Name); - if (I == Regs.end()) - return nullptr; - return I->second; + return getRegBank().getRegistersByName().lookup(Name); } std::vector CodeGenTarget::getRegisterVTs(Record *R) diff --git a/llvm/utils/TableGen/GlobalISel/GIMatchTree.h b/llvm/utils/TableGen/GlobalISel/GIMatchTree.h index b86f6454589c87..bf41a2e0e23461 100644 --- a/llvm/utils/TableGen/GlobalISel/GIMatchTree.h +++ b/llvm/utils/TableGen/GlobalISel/GIMatchTree.h @@ -353,10 +353,7 @@ class GIMatchTreeBuilderLeafInfo { void declareOperand(unsigned InstrID, unsigned OpIdx); GIMatchTreeInstrInfo *getInstrInfo(unsigned ID) const { - auto I = InstrIDToInfo.find(ID); - if (I != InstrIDToInfo.end()) - return I->second; - return nullptr; + return InstrIDToInfo.lookup(ID); } void dump(raw_ostream &OS) const {