[ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h utilities. NFC

llvm-svn: 357269
This commit is contained in:
Fangrui Song 2019-03-29 16:21:16 +00:00
parent 515d1306ff
commit 8048fe2b8c
7 changed files with 16 additions and 22 deletions

View File

@ -551,9 +551,9 @@ static void implementPatch(uint64_t AdrpAddr, uint64_t PatcheeOffset,
// and replace the relocation with a R_AARCH_JUMP26 branch relocation.
// Case 4: No relocation. We must create a new R_AARCH64_JUMP26 branch
// relocation at the offset.
auto RelIt = std::find_if(
IS->Relocations.begin(), IS->Relocations.end(),
[=](const Relocation &R) { return R.Offset == PatcheeOffset; });
auto RelIt = llvm::find_if(IS->Relocations, [=](const Relocation &R) {
return R.Offset == PatcheeOffset;
});
if (RelIt != IS->Relocations.end() &&
(RelIt->Type == R_AARCH64_JUMP26 || RelIt->Expr == R_RELAX_TLS_IE_TO_LE))
return;

View File

@ -96,7 +96,7 @@ void EhReader::skipBytes(size_t Count) {
// Read a null-terminated string.
StringRef EhReader::readString() {
const uint8_t *End = std::find(D.begin(), D.end(), '\0');
const uint8_t *End = llvm::find(D, '\0');
if (End == D.end())
failOn(D.data(), "corrupted CIE (failed to read string)");
StringRef S = toStringRef(D.slice(0, End - D.begin()));

View File

@ -2029,7 +2029,7 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
// Find the first section after PT_GNU_RELRO. If it is in a PT_LOAD we
// have to align it to a page.
auto End = OutputSections.end();
auto I = std::find(OutputSections.begin(), End, P->LastSec);
auto I = llvm::find(OutputSections, P->LastSec);
if (I == End || (I + 1) == End)
continue;

View File

@ -387,12 +387,9 @@ private:
// Gather the personality functions now, so that they're in deterministic
// order (derived from the DefinedAtom order).
if (unwindEntry.personalityFunction) {
auto pFunc = std::find(personalities.begin(), personalities.end(),
unwindEntry.personalityFunction);
if (pFunc == personalities.end())
personalities.push_back(unwindEntry.personalityFunction);
}
if (unwindEntry.personalityFunction &&
!llvm::count(personalities, unwindEntry.personalityFunction))
personalities.push_back(unwindEntry.personalityFunction);
}
}
@ -551,8 +548,7 @@ private:
}
}
auto personality = std::find(personalities.begin(), personalities.end(),
entry.personalityFunction);
auto personality = llvm::find(personalities, entry.personalityFunction);
uint32_t personalityIdx = personality == personalities.end()
? 0
: personality - personalities.begin() + 1;

View File

@ -767,8 +767,7 @@ void MachOLinkingContext::registerDylib(MachODylibFile *dylib,
bool upward) const {
std::lock_guard<std::mutex> lock(_dylibsMutex);
if (std::find(_allDylibs.begin(),
_allDylibs.end(), dylib) == _allDylibs.end())
if (!llvm::count(_allDylibs, dylib))
_allDylibs.push_back(dylib);
_pathToDylibMap[dylib->installName()] = dylib;
// If path is different than install name, register path too.

View File

@ -270,9 +270,8 @@ public:
mergedFile.addAtom(*helperCacheNLPAtom);
// Add reference to dyld_stub_binder in libSystem.dylib
auto I = std::find_if(
mergedFile.sharedLibrary().begin(), mergedFile.sharedLibrary().end(),
[&](const SharedLibraryAtom *atom) {
auto I = llvm::find_if(
mergedFile.sharedLibrary(), [&](const SharedLibraryAtom *atom) {
return atom->name().equals(_stubInfo.binderSymbolName);
});
assert(I != mergedFile.sharedLibrary().end() &&

View File

@ -687,10 +687,10 @@ void Writer::createProducersSection() {
std::make_pair(&Info.SDKs, &SDKs)})
for (auto &Producer : *Producers.first)
if (Producers.second->end() ==
std::find_if(Producers.second->begin(), Producers.second->end(),
[&](std::pair<std::string, std::string> Seen) {
return Seen.first == Producer.first;
}))
llvm::find_if(*Producers.second,
[&](std::pair<std::string, std::string> Seen) {
return Seen.first == Producer.first;
}))
Producers.second->push_back(Producer);
}
int FieldCount =