Roll abseil_revision 093cc27604..4b4f9aae75
Change Log:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+log/093cc27604..4b4f9aae75
Full diff:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+/093cc27604..4b4f9aae75
No .def file changes.
Bug: None
Change-Id: Ie56604087d635647c9d4dff01aaa7ce332299f89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2456347
Reviewed-by: Danil Chapovalov <danilchap@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814720}
GitOrigin-RevId: f0005f63e317032452e203dac2db08a3f2a06828
diff --git a/README.chromium b/README.chromium
index fc65cd9..288e986 100644
--- a/README.chromium
+++ b/README.chromium
@@ -4,7 +4,7 @@
License: Apache 2.0
License File: LICENSE
Version: 0
-Revision: 093cc27604df1c4a179b73bc3f00d4d1ce2ce113
+Revision: 4b4f9aae75d3c85bdc07b0575de5d4db40cea439
Security Critical: yes
Description:
diff --git a/absl/algorithm/container.h b/absl/algorithm/container.h
index 5c03357..3c4fd73 100644
--- a/absl/algorithm/container.h
+++ b/absl/algorithm/container.h
@@ -90,10 +90,10 @@
// lookup of std::begin and std::end, i.e.
// using std::begin;
// using std::end;
-// std::foo(begin(c), end(c);
+// std::foo(begin(c), end(c));
// becomes
// std::foo(container_algorithm_internal::begin(c),
-// container_algorithm_internal::end(c));
+// container_algorithm_internal::end(c));
// These are meant for internal use only.
template <typename C>
@@ -340,24 +340,43 @@
// c_mismatch()
//
// Container-based version of the <algorithm> `std::mismatch()` function to
-// return the first element where two ordered containers differ.
+// return the first element where two ordered containers differ. Applies `==` to
+// the first N elements of `c1` and `c2`, where N = min(size(c1), size(c2)).
template <typename C1, typename C2>
container_algorithm_internal::ContainerIterPairType<C1, C2>
c_mismatch(C1& c1, C2& c2) {
- return std::mismatch(container_algorithm_internal::c_begin(c1),
- container_algorithm_internal::c_end(c1),
- container_algorithm_internal::c_begin(c2));
+ auto first1 = container_algorithm_internal::c_begin(c1);
+ auto last1 = container_algorithm_internal::c_end(c1);
+ auto first2 = container_algorithm_internal::c_begin(c2);
+ auto last2 = container_algorithm_internal::c_end(c2);
+
+ for (; first1 != last1 && first2 != last2; ++first1, (void)++first2) {
+ if (*first1 != *first2) {
+ break;
+ }
+ }
+
+ return std::make_pair(first1, first2);
}
// Overload of c_mismatch() for using a predicate evaluation other than `==` as
-// the function's test condition.
+// the function's test condition. Applies `pred`to the first N elements of `c1`
+// and `c2`, where N = min(size(c1), size(c2)).
template <typename C1, typename C2, typename BinaryPredicate>
container_algorithm_internal::ContainerIterPairType<C1, C2>
-c_mismatch(C1& c1, C2& c2, BinaryPredicate&& pred) {
- return std::mismatch(container_algorithm_internal::c_begin(c1),
- container_algorithm_internal::c_end(c1),
- container_algorithm_internal::c_begin(c2),
- std::forward<BinaryPredicate>(pred));
+c_mismatch(C1& c1, C2& c2, BinaryPredicate pred) {
+ auto first1 = container_algorithm_internal::c_begin(c1);
+ auto last1 = container_algorithm_internal::c_end(c1);
+ auto first2 = container_algorithm_internal::c_begin(c2);
+ auto last2 = container_algorithm_internal::c_end(c2);
+
+ for (; first1 != last1 && first2 != last2; ++first1, (void)++first2) {
+ if (!pred(*first1, *first2)) {
+ break;
+ }
+ }
+
+ return std::make_pair(first1, first2);
}
// c_equal()
diff --git a/absl/algorithm/container_test.cc b/absl/algorithm/container_test.cc
index 3abf5ce..fb94056 100644
--- a/absl/algorithm/container_test.cc
+++ b/absl/algorithm/container_test.cc
@@ -57,9 +57,7 @@
};
struct AccumulateCalls {
- void operator()(int value) {
- calls.push_back(value);
- }
+ void operator()(int value) { calls.push_back(value); }
std::vector<int> calls;
};
@@ -68,7 +66,6 @@
bool Equals(int v1, int v2) { return v1 == v2; }
bool IsOdd(int x) { return x % 2 != 0; }
-
TEST_F(NonMutatingTest, Distance) {
EXPECT_EQ(container_.size(), absl::c_distance(container_));
EXPECT_EQ(sequence_.size(), absl::c_distance(sequence_));
@@ -151,13 +148,79 @@
}
TEST_F(NonMutatingTest, Mismatch) {
- absl::c_mismatch(container_, sequence_);
- absl::c_mismatch(sequence_, container_);
+ // Testing necessary as absl::c_mismatch executes logic.
+ {
+ auto result = absl::c_mismatch(vector_, sequence_);
+ EXPECT_EQ(result.first, vector_.end());
+ EXPECT_EQ(result.second, sequence_.end());
+ }
+ {
+ auto result = absl::c_mismatch(sequence_, vector_);
+ EXPECT_EQ(result.first, sequence_.end());
+ EXPECT_EQ(result.second, vector_.end());
+ }
+
+ sequence_.back() = 5;
+ {
+ auto result = absl::c_mismatch(vector_, sequence_);
+ EXPECT_EQ(result.first, std::prev(vector_.end()));
+ EXPECT_EQ(result.second, std::prev(sequence_.end()));
+ }
+ {
+ auto result = absl::c_mismatch(sequence_, vector_);
+ EXPECT_EQ(result.first, std::prev(sequence_.end()));
+ EXPECT_EQ(result.second, std::prev(vector_.end()));
+ }
+
+ sequence_.pop_back();
+ {
+ auto result = absl::c_mismatch(vector_, sequence_);
+ EXPECT_EQ(result.first, std::prev(vector_.end()));
+ EXPECT_EQ(result.second, sequence_.end());
+ }
+ {
+ auto result = absl::c_mismatch(sequence_, vector_);
+ EXPECT_EQ(result.first, sequence_.end());
+ EXPECT_EQ(result.second, std::prev(vector_.end()));
+ }
}
TEST_F(NonMutatingTest, MismatchWithPredicate) {
- absl::c_mismatch(container_, sequence_, BinPredicate);
- absl::c_mismatch(sequence_, container_, BinPredicate);
+ // Testing necessary as absl::c_mismatch executes logic.
+ {
+ auto result = absl::c_mismatch(vector_, sequence_, BinPredicate);
+ EXPECT_EQ(result.first, vector_.begin());
+ EXPECT_EQ(result.second, sequence_.begin());
+ }
+ {
+ auto result = absl::c_mismatch(sequence_, vector_, BinPredicate);
+ EXPECT_EQ(result.first, sequence_.begin());
+ EXPECT_EQ(result.second, vector_.begin());
+ }
+
+ sequence_.front() = 0;
+ {
+ auto result = absl::c_mismatch(vector_, sequence_, BinPredicate);
+ EXPECT_EQ(result.first, vector_.begin());
+ EXPECT_EQ(result.second, sequence_.begin());
+ }
+ {
+ auto result = absl::c_mismatch(sequence_, vector_, BinPredicate);
+ EXPECT_EQ(result.first, std::next(sequence_.begin()));
+ EXPECT_EQ(result.second, std::next(vector_.begin()));
+ }
+
+ sequence_.clear();
+ {
+ auto result = absl::c_mismatch(vector_, sequence_, BinPredicate);
+ EXPECT_EQ(result.first, vector_.begin());
+ EXPECT_EQ(result.second, sequence_.end());
+ }
+ {
+ auto result = absl::c_mismatch(sequence_, vector_, BinPredicate);
+ EXPECT_EQ(result.first, sequence_.end());
+ EXPECT_EQ(result.second, vector_.begin());
+ }
}
TEST_F(NonMutatingTest, Equal) {
@@ -519,11 +582,9 @@
TEST_F(SortingTest, NthElement) {
std::vector<int> unsorted = {2, 4, 1, 3};
absl::c_nth_element(unsorted, unsorted.begin() + 2);
- EXPECT_THAT(unsorted,
- ElementsAre(Lt(3), Lt(3), 3, Gt(3)));
+ EXPECT_THAT(unsorted, ElementsAre(Lt(3), Lt(3), 3, Gt(3)));
absl::c_nth_element(unsorted, unsorted.begin() + 2, std::greater<int>());
- EXPECT_THAT(unsorted,
- ElementsAre(Gt(2), Gt(2), 2, Lt(2)));
+ EXPECT_THAT(unsorted, ElementsAre(Gt(2), Gt(2), 2, Lt(2)));
}
TEST(MutatingTest, IsPartitioned) {
@@ -778,10 +839,9 @@
TEST(MutatingTest, StableSort) {
std::vector<Element> test_vector = {{1, 1}, {2, 1}, {2, 0}, {1, 0}, {2, 2}};
absl::c_stable_sort(test_vector);
- EXPECT_THAT(
- test_vector,
- ElementsAre(IsElement(1, 1), IsElement(1, 0), IsElement(2, 1),
- IsElement(2, 0), IsElement(2, 2)));
+ EXPECT_THAT(test_vector,
+ ElementsAre(IsElement(1, 1), IsElement(1, 0), IsElement(2, 1),
+ IsElement(2, 0), IsElement(2, 2)));
}
TEST(MutatingTest, StableSortWithPredicate) {
@@ -789,10 +849,9 @@
absl::c_stable_sort(test_vector, [](const Element& e1, const Element& e2) {
return e2 < e1;
});
- EXPECT_THAT(
- test_vector,
- ElementsAre(IsElement(2, 1), IsElement(2, 0), IsElement(2, 2),
- IsElement(1, 1), IsElement(1, 0)));
+ EXPECT_THAT(test_vector,
+ ElementsAre(IsElement(2, 1), IsElement(2, 0), IsElement(2, 2),
+ IsElement(1, 1), IsElement(1, 0)));
}
TEST(MutatingTest, ReplaceCopyIf) {
diff --git a/absl/debugging/symbolize_darwin.inc b/absl/debugging/symbolize_darwin.inc
index cdadd40..443ce9e 100644
--- a/absl/debugging/symbolize_darwin.inc
+++ b/absl/debugging/symbolize_darwin.inc
@@ -77,8 +77,8 @@
char tmp_buf[1024];
if (debugging_internal::Demangle(symbol.c_str(), tmp_buf, sizeof(tmp_buf))) {
- int len = strlen(tmp_buf);
- if (len + 1 <= out_size) { // +1 for '\0'
+ size_t len = strlen(tmp_buf);
+ if (len + 1 <= static_cast<size_t>(out_size)) { // +1 for '\0'
assert(len < sizeof(tmp_buf));
memmove(out, tmp_buf, len + 1);
}
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index 0805df3..7557322 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -145,7 +145,8 @@
}
// Write the token, ending the string first if necessary/possible.
- if (!new_line && (line_len_ + token.size() >= max_line_len_)) {
+ if (!new_line &&
+ (line_len_ + static_cast<int>(token.size()) >= max_line_len_)) {
EndLine();
new_line = true;
}
diff --git a/absl/status/statusor.h b/absl/status/statusor.h
index bdf6039..0bbf6ef 100644
--- a/absl/status/statusor.h
+++ b/absl/status/statusor.h
@@ -129,7 +129,7 @@
// Example:
//
// absl::StatusOr<int> i = GetCount();
-// if (foo.ok()) {
+// if (i.ok()) {
// updated_total += *i
// }
//
diff --git a/absl/strings/internal/charconv_parse.cc b/absl/strings/internal/charconv_parse.cc
index fd6d948..a368845 100644
--- a/absl/strings/internal/charconv_parse.cc
+++ b/absl/strings/internal/charconv_parse.cc
@@ -405,7 +405,7 @@
}
exponent_adjustment -= static_cast<int>(zeros_skipped);
}
- std::size_t post_decimal_digits = ConsumeDigits<base>(
+ int64_t post_decimal_digits = ConsumeDigits<base>(
begin, end, digits_left, &mantissa, &mantissa_is_inexact);
begin += post_decimal_digits;