summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Aizatsky <aizatsky@chromium.org>2016-11-18 20:48:52 +0000
committerMike Aizatsky <aizatsky@chromium.org>2016-11-18 20:48:52 +0000
commit7594ec3355cf4410663868a119a5ffb05649e095 (patch)
treec1dfd9d5e9d2bd9fd5df362547ce526683ba655d
parenta47464b2738c5180061f4cfe6b3f72238b3cfa7d (diff)
downloadbcm5719-llvm-7594ec3355cf4410663868a119a5ffb05649e095.tar.gz
bcm5719-llvm-7594ec3355cf4410663868a119a5ffb05649e095.zip
rename InternalBinarySearch to InternalLowerBound
Summary: The new name better corresponds to its logic. Reviewers: kcc Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D26821 llvm-svn: 287377
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h6
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc34
3 files changed, 22 insertions, 22 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 63956aed94d..499bc07dff5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -637,9 +637,9 @@ void InternalSort(Container *v, uptr size, Compare comp) {
// Works like std::lower_bound: finds the first element that is not less
// than the val.
-template<class Container, class Value, class Compare>
-uptr InternalBinarySearch(const Container &v, uptr first, uptr last,
- const Value &val, Compare comp) {
+template <class Container, class Value, class Compare>
+uptr InternalLowerBound(const Container &v, uptr first, uptr last,
+ const Value &val, Compare comp) {
while (last > first) {
uptr mid = (first + last) / 2;
if (comp(v[mid], val))
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc
index 2ec7a82d162..214dda56df3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc
@@ -153,8 +153,8 @@ StackTrace StackDepotReverseMap::Get(u32 id) {
if (!map_.size())
return StackTrace();
IdDescPair pair = {id, nullptr};
- uptr idx = InternalBinarySearch(map_, 0, map_.size(), pair,
- IdDescPair::IdComparator);
+ uptr idx =
+ InternalLowerBound(map_, 0, map_.size(), pair, IdDescPair::IdComparator);
if (idx > map_.size() || map_[idx].id != id)
return StackTrace();
return map_[idx].desc->load();
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc
index 0980cf4e47c..ebc885db752 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc
@@ -172,7 +172,7 @@ bool UptrLess(uptr a, uptr b) {
return a < b;
}
-TEST(SanitizerCommon, InternalBinarySearch) {
+TEST(SanitizerCommon, InternalLowerBound) {
static const uptr kSize = 5;
int arr[kSize];
arr[0] = 1;
@@ -181,22 +181,22 @@ TEST(SanitizerCommon, InternalBinarySearch) {
arr[3] = 7;
arr[4] = 11;
- EXPECT_EQ(0u, InternalBinarySearch(arr, 0, kSize, 0, UptrLess));
- EXPECT_EQ(0u, InternalBinarySearch(arr, 0, kSize, 1, UptrLess));
- EXPECT_EQ(1u, InternalBinarySearch(arr, 0, kSize, 2, UptrLess));
- EXPECT_EQ(1u, InternalBinarySearch(arr, 0, kSize, 3, UptrLess));
- EXPECT_EQ(2u, InternalBinarySearch(arr, 0, kSize, 4, UptrLess));
- EXPECT_EQ(2u, InternalBinarySearch(arr, 0, kSize, 5, UptrLess));
- EXPECT_EQ(3u, InternalBinarySearch(arr, 0, kSize, 6, UptrLess));
- EXPECT_EQ(3u, InternalBinarySearch(arr, 0, kSize, 7, UptrLess));
- EXPECT_EQ(4u, InternalBinarySearch(arr, 0, kSize, 8, UptrLess));
- EXPECT_EQ(4u, InternalBinarySearch(arr, 0, kSize, 9, UptrLess));
- EXPECT_EQ(4u, InternalBinarySearch(arr, 0, kSize, 10, UptrLess));
- EXPECT_EQ(4u, InternalBinarySearch(arr, 0, kSize, 11, UptrLess));
- EXPECT_EQ(5u, InternalBinarySearch(arr, 0, kSize, 12, UptrLess));
+ EXPECT_EQ(0u, InternalLowerBound(arr, 0, kSize, 0, UptrLess));
+ EXPECT_EQ(0u, InternalLowerBound(arr, 0, kSize, 1, UptrLess));
+ EXPECT_EQ(1u, InternalLowerBound(arr, 0, kSize, 2, UptrLess));
+ EXPECT_EQ(1u, InternalLowerBound(arr, 0, kSize, 3, UptrLess));
+ EXPECT_EQ(2u, InternalLowerBound(arr, 0, kSize, 4, UptrLess));
+ EXPECT_EQ(2u, InternalLowerBound(arr, 0, kSize, 5, UptrLess));
+ EXPECT_EQ(3u, InternalLowerBound(arr, 0, kSize, 6, UptrLess));
+ EXPECT_EQ(3u, InternalLowerBound(arr, 0, kSize, 7, UptrLess));
+ EXPECT_EQ(4u, InternalLowerBound(arr, 0, kSize, 8, UptrLess));
+ EXPECT_EQ(4u, InternalLowerBound(arr, 0, kSize, 9, UptrLess));
+ EXPECT_EQ(4u, InternalLowerBound(arr, 0, kSize, 10, UptrLess));
+ EXPECT_EQ(4u, InternalLowerBound(arr, 0, kSize, 11, UptrLess));
+ EXPECT_EQ(5u, InternalLowerBound(arr, 0, kSize, 12, UptrLess));
}
-TEST(SanitizerCommon, InternalBinarySearchVsLowerBound) {
+TEST(SanitizerCommon, InternalLowerBoundVsStdLowerBound) {
std::vector<int> data;
auto create_item = [] (size_t i, size_t j) {
auto v = i * 10000 + j;
@@ -215,8 +215,8 @@ TEST(SanitizerCommon, InternalBinarySearchVsLowerBound) {
for (auto to_find : {val - 1, val, val + 1}) {
uptr expected =
std::lower_bound(data.begin(), data.end(), to_find) - data.begin();
- EXPECT_EQ(expected, InternalBinarySearch(data.data(), 0, data.size(),
- to_find, std::less<int>()));
+ EXPECT_EQ(expected, InternalLowerBound(data.data(), 0, data.size(),
+ to_find, std::less<int>()));
}
}
}
OpenPOWER on IntegriCloud