diff options
| author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2020-01-10 15:14:38 +0100 |
|---|---|---|
| committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2020-01-10 15:14:38 +0100 |
| commit | 2f2f41e12c5201b600d887d22ce5cb4afd2ff594 (patch) | |
| tree | 290c9be7d788b983bb792a1507526ce16bca2ebe /lldb/include | |
| parent | 4569f63ae1cb520ce28f08f4800dfbcd5f255eed (diff) | |
| download | bcm5719-llvm-2f2f41e12c5201b600d887d22ce5cb4afd2ff594.tar.gz bcm5719-llvm-2f2f41e12c5201b600d887d22ce5cb4afd2ff594.zip | |
RangeDataVector: Support custom sorting for D63540
As suggested by @labath extended RangeDataVector so that user can provide
custom sorting of the Entry's `data' field for D63540.
https://reviews.llvm.org/D63540
RangeData functions were used just by RangeDataVector (=after I removed them
LLDB still builds fine) which no longer uses them so I removed them.
Differential revision: https://reviews.llvm.org/D72460
Diffstat (limited to 'lldb/include')
| -rw-r--r-- | lldb/include/lldb/Utility/RangeMap.h | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/lldb/include/lldb/Utility/RangeMap.h b/lldb/include/lldb/Utility/RangeMap.h index 709b5d2f66c..9e030735183 100644 --- a/lldb/include/lldb/Utility/RangeMap.h +++ b/lldb/include/lldb/Utility/RangeMap.h @@ -599,36 +599,17 @@ struct RangeData : public Range<B, S> { RangeData(B base, S size) : Range<B, S>(base, size), data() {} RangeData(B base, S size, DataType d) : Range<B, S>(base, size), data(d) {} - - bool operator<(const RangeData &rhs) const { - if (this->base == rhs.base) { - if (this->size == rhs.size) - return this->data < rhs.data; - else - return this->size < rhs.size; - } - return this->base < rhs.base; - } - - bool operator==(const RangeData &rhs) const { - return this->GetRangeBase() == rhs.GetRangeBase() && - this->GetByteSize() == rhs.GetByteSize() && this->data == rhs.data; - } - - bool operator!=(const RangeData &rhs) const { - return this->GetRangeBase() != rhs.GetRangeBase() || - this->GetByteSize() != rhs.GetByteSize() || this->data != rhs.data; - } }; -template <typename B, typename S, typename T, unsigned N = 0> +template <typename B, typename S, typename T, unsigned N = 0, + class Compare = std::less<T>> class RangeDataVector { public: typedef lldb_private::Range<B, S> Range; typedef RangeData<B, S, T> Entry; typedef llvm::SmallVector<Entry, N> Collection; - RangeDataVector() = default; + RangeDataVector(Compare compare = Compare()) : m_compare(compare) {} ~RangeDataVector() = default; @@ -636,7 +617,14 @@ public: void Sort() { if (m_entries.size() > 1) - std::stable_sort(m_entries.begin(), m_entries.end()); + std::stable_sort(m_entries.begin(), m_entries.end(), + [&compare = m_compare](const Entry &a, const Entry &b) { + if (a.base != b.base) + return a.base < b.base; + if (a.size != b.size) + return a.size < b.size; + return compare(a.data, b.data); + }); } #ifdef ASSERT_RANGEMAP_ARE_SORTED @@ -817,6 +805,7 @@ public: protected: Collection m_entries; + Compare m_compare; }; // A simple range with data class where you get to define the type of |

