Skip to content

Commit

Permalink
Export of internal Abseil changes
Browse files Browse the repository at this point in the history
--
7f6c15aadc4d97e217dd446518dbb4fdc86b36a3 by Derek Mauro <[email protected]>:

Upgrade GCC automated testing to use GCC 9.2 and Cmake 3.16.2

PiperOrigin-RevId: 288488783

--
a978cee848d3cf65b0826c981bfd81022fc36660 by Abseil Team <[email protected]>:

Removing formatting traits that were only used internally. ON_CALL/EXPECT_CALL do a sufficient job here.

PiperOrigin-RevId: 288386509

--
fdec6f40293d5883220f1f0ea1261f7c5b60a66e by Derek Mauro <[email protected]>:

Upgrade MacOS tests to use Bazel 2.0.0

PiperOrigin-RevId: 288373298

--
465865c4123e9481ab50ea0527e92b39519704dd by Derek Mauro <[email protected]>:

Changes to support GCC 9
 * Fix several -Wredundant-move warnings
 * Remove FlatHashMap.Any test, which basically doesn't work on any platform
   any more (see https://cplusplus.github.io/LWG/lwg-active.html#3121)
 * Fix a constant sign-compare warning
 * Conditionally compile out the PoisonHash test which doesn't build

PiperOrigin-RevId: 288360204

--
57c4bb07fc58e7dd2a04f3c45027aab5ecaccf25 by Andy Soffer <[email protected]>:

Deflaking MockingBitGen test. Because MockingBitGen can return random values,
it is inherently flaky. For log-unifrom, 2040 is a common enough value that
tests failed unreasonably frequently. Replacing it with a significantly larger
value so as to be much less common. 50000 is a good choice because it is (tied for) the least likely to occur randomly from this distribution, but is still in the distribution.

PiperOrigin-RevId: 288360112

--
86f38e4109899d972de353b1c556c018cfe37956 by Matt Calabrese <[email protected]>:

Remove construction tests for the internal `CompressedTuple<std::any>` instantiation. This was not guaranteed to work for the reasons that `std::tuple<std::any>` copy construction does not actually work by standard specification (some implementations introduce workarounds for this). In GCC9, `CompressedTuple<std::any>` and `std::tuple<std::any>` both fail for the same reasons, and a proper "fix" requires updating `std::any`, which is out of our control.

PiperOrigin-RevId: 288351977
GitOrigin-RevId: 7f6c15aadc4d97e217dd446518dbb4fdc86b36a3
Change-Id: I5d5c62bd297dc0ff1f2970ff076bb5cd088a7e4c
  • Loading branch information
Abseil Team authored and derekmauro committed Jan 7, 2020
1 parent a048203 commit 63ee2f8
Show file tree
Hide file tree
Showing 22 changed files with 386 additions and 76 deletions.
35 changes: 0 additions & 35 deletions absl/container/flat_hash_map_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,41 +253,6 @@ TEST(FlatHashMap, EraseIf) {
}
}

#if (defined(ABSL_USES_STD_ANY) || !defined(_LIBCPP_VERSION)) && \
!defined(__EMSCRIPTEN__)
TEST(FlatHashMap, Any) {
absl::flat_hash_map<int, absl::any> m;
m.emplace(1, 7);
auto it = m.find(1);
ASSERT_NE(it, m.end());
EXPECT_EQ(7, absl::any_cast<int>(it->second));

m.emplace(std::piecewise_construct, std::make_tuple(2), std::make_tuple(8));
it = m.find(2);
ASSERT_NE(it, m.end());
EXPECT_EQ(8, absl::any_cast<int>(it->second));

m.emplace(std::piecewise_construct, std::make_tuple(3),
std::make_tuple(absl::any(9)));
it = m.find(3);
ASSERT_NE(it, m.end());
EXPECT_EQ(9, absl::any_cast<int>(it->second));

struct H {
size_t operator()(const absl::any&) const { return 0; }
};
struct E {
bool operator()(const absl::any&, const absl::any&) const { return true; }
};
absl::flat_hash_map<absl::any, int, H, E> m2;
m2.emplace(1, 7);
auto it2 = m2.find(1);
ASSERT_NE(it2, m2.end());
EXPECT_EQ(7, it2->second);
}
#endif // (defined(ABSL_USES_STD_ANY) || !defined(_LIBCPP_VERSION)) &&
// !defined(__EMSCRIPTEN__)

} // namespace
} // namespace container_internal
ABSL_NAMESPACE_END
Expand Down
4 changes: 0 additions & 4 deletions absl/container/internal/compressed_tuple_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ TEST(CompressedTupleTest, AnyElements) {

a = 0.5f;
EXPECT_EQ(absl::any_cast<float>(x.get<1>()), 0.5);

// Ensure copy construction work in the face of a type with a universal
// implicit constructor;
CompressedTuple<absl::any> c{}, d(c); // NOLINT
}

TEST(CompressedTupleTest, Constexpr) {
Expand Down
5 changes: 4 additions & 1 deletion absl/hash/hash_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ struct DummyFooBar {
const char* bar = "bar";
h = H::combine_contiguous(std::move(h), foo, 3);
h = H::combine_contiguous(std::move(h), bar, 3);
return std::move(h);
return h;
}
};

Expand Down Expand Up @@ -595,7 +595,10 @@ TEST(IsHashableTest, PoisonHash) {
EXPECT_FALSE(absl::is_copy_assignable<absl::Hash<X>>::value);
EXPECT_FALSE(absl::is_move_assignable<absl::Hash<X>>::value);
EXPECT_FALSE(IsHashCallable<X>::value);
#if !defined(__GNUC__) || __GNUC__ < 9
// This doesn't compile on GCC 9.
EXPECT_FALSE(IsAggregateInitializable<absl::Hash<X>>::value);
#endif
}
#endif // ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_

Expand Down
6 changes: 3 additions & 3 deletions absl/hash/internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PiecewiseCombiner;

// Internal detail: Large buffers are hashed in smaller chunks. This function
// returns the size of these chunks.
constexpr int PiecewiseChunkSize() { return 1024; }
constexpr size_t PiecewiseChunkSize() { return 1024; }

// HashStateBase
//
Expand Down Expand Up @@ -951,7 +951,7 @@ H PiecewiseCombiner::add_buffer(H state, const unsigned char* data,
// This partial chunk does not fill our existing buffer
memcpy(buf_ + position_, data, size);
position_ += size;
return std::move(state);
return state;
}

// Complete the buffer and hash it
Expand All @@ -970,7 +970,7 @@ H PiecewiseCombiner::add_buffer(H state, const unsigned char* data,
// Fill the buffer with the remainder
memcpy(buf_, data, size);
position_ = size;
return std::move(state);
return state;
}

// HashStateBase::PiecewiseCombiner::finalize()
Expand Down
1 change: 1 addition & 0 deletions absl/random/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ cc_library(
"bernoulli_distribution.h",
"beta_distribution.h",
"discrete_distribution.h",
"distribution_format_traits.h",
"distributions.h",
"exponential_distribution.h",
"gaussian_distribution.h",
Expand Down
2 changes: 2 additions & 0 deletions absl/random/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ absl_cc_library(
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::random_random
absl::strings
)

# Internal-only target, do not depend on directly.
Expand Down Expand Up @@ -167,6 +168,7 @@ absl_cc_library(
"bernoulli_distribution.h"
"beta_distribution.h"
"discrete_distribution.h"
"distribution_format_traits.h"
"distributions.h"
"exponential_distribution.h"
"gaussian_distribution.h"
Expand Down
5 changes: 3 additions & 2 deletions absl/random/bit_gen_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,16 @@ namespace random_internal {

template <>
struct DistributionCaller<absl::BitGenRef> {
template <typename DistrT, typename... Args>
template <typename DistrT, typename FormatT, typename... Args>
static typename DistrT::result_type Call(absl::BitGenRef* gen_ref,
Args&&... args) {
auto* mock_ptr = gen_ref->mocked_gen_ptr_;
if (mock_ptr == nullptr) {
DistrT dist(std::forward<Args>(args)...);
return dist(*gen_ref);
} else {
return mock_ptr->template Call<DistrT>(std::forward<Args>(args)...);
return mock_ptr->template Call<DistrT, FormatT>(
std::forward<Args>(args)...);
}
}
};
Expand Down
Loading

0 comments on commit 63ee2f8

Please sign in to comment.