summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-03-28 00:00:09 +0000
committerRui Ueyama <ruiu@google.com>2015-03-28 00:00:09 +0000
commit6fab3c73b842d91d6dbfbff6f902b53a8eb688cb (patch)
tree6777e092657c8155bff28518cc25e8218ba3d4a2
parent286494717fd5163d98ce228d2d503bfaee7eccf3 (diff)
downloadbcm5719-llvm-6fab3c73b842d91d6dbfbff6f902b53a8eb688cb.tar.gz
bcm5719-llvm-6fab3c73b842d91d6dbfbff6f902b53a8eb688cb.zip
Use lambda for std::find_if.
llvm-svn: 233454
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFFile.h23
1 files changed, 8 insertions, 15 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h
index 7d42668b55f..79638281694 100644
--- a/lld/lib/ReaderWriter/ELF/ELFFile.h
+++ b/lld/lib/ReaderWriter/ELF/ELFFile.h
@@ -40,6 +40,7 @@ template <class ELFT> class ELFFile : public File {
const Elf_Shdr *_shdr;
int64_t _offset;
};
+
struct MergeSectionEq {
int64_t operator()(const MergeSectionKey &k) const {
return llvm::hash_combine((int64_t)(k._shdr->sh_name),
@@ -71,23 +72,15 @@ template <class ELFT> class ELFFile : public File {
// offset
typedef std::vector<ELFMergeAtom<ELFT> *> MergeAtomsT;
- /// \brief find a mergeAtom given a start offset
- struct FindByOffset {
- const Elf_Shdr *_shdr;
- int64_t _offset;
- FindByOffset(const Elf_Shdr *shdr, int64_t offset)
- : _shdr(shdr), _offset(offset) {}
- bool operator()(const ELFMergeAtom<ELFT> *a) {
- int64_t off = a->offset();
- return (_shdr->sh_name == a->section()) &&
- ((_offset >= off) && (_offset <= off + (int64_t)a->size()));
- }
- };
-
/// \brief find a merge atom given a offset
- ELFMergeAtom<ELFT> *findMergeAtom(const Elf_Shdr *shdr, uint64_t offset) {
+ ELFMergeAtom<ELFT> *findMergeAtom(const Elf_Shdr *shdr, int64_t offset) {
auto it = std::find_if(_mergeAtoms.begin(), _mergeAtoms.end(),
- FindByOffset(shdr, offset));
+ [=](const ELFMergeAtom<ELFT> *a) {
+ int64_t off = a->offset();
+ return shdr->sh_name == a->section() &&
+ offset >= off &&
+ offset <= off + (int64_t)a->size();
+ });
assert(it != _mergeAtoms.end());
return *it;
}
OpenPOWER on IntegriCloud