Disallow copy and assign for DataBuilder & RandomGenerator

BUG=tint:1247

Change-Id: I48f7b1e1679bcba43e4c284b2f97a02210feabb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66740
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ryan Harrison 2021-10-18 18:46:57 +00:00 committed by Tint LUCI CQ
parent 8045166b16
commit 5f5d43ff51
2 changed files with 13 additions and 1 deletions

View File

@ -34,7 +34,8 @@ class DataBuilder {
explicit DataBuilder(const uint8_t* data, size_t size) explicit DataBuilder(const uint8_t* data, size_t size)
: generator_(data, size) {} : generator_(data, size) {}
~DataBuilder() {} ~DataBuilder() = default;
DataBuilder(DataBuilder&&) = default;
/// Generate pseudo-random data of a specific type /// Generate pseudo-random data of a specific type
/// @tparam T - type of data to produce /// @tparam T - type of data to produce
@ -85,6 +86,10 @@ class DataBuilder {
private: private:
RandomGenerator generator_; RandomGenerator generator_;
// Disallow copy & assign
DataBuilder(const DataBuilder&) = delete;
DataBuilder& operator=(const DataBuilder&) = delete;
/// Get N bytes of pseudo-random data /// Get N bytes of pseudo-random data
/// @param out - pointer to location to save data /// @param out - pointer to location to save data
/// @param n - number of bytes to get /// @param n - number of bytes to get

View File

@ -33,6 +33,9 @@ class RandomGenerator {
/// @param size - size of data buffer /// @param size - size of data buffer
explicit RandomGenerator(const uint8_t* data, size_t size); explicit RandomGenerator(const uint8_t* data, size_t size);
~RandomGenerator() = default;
RandomGenerator(RandomGenerator&&) = default;
/// Get uint32_t value from uniform distribution. /// Get uint32_t value from uniform distribution.
/// @param lower - lower bound of integer generated /// @param lower - lower bound of integer generated
/// @param upper - upper bound of integer generated /// @param upper - upper bound of integer generated
@ -98,6 +101,10 @@ class RandomGenerator {
private: private:
std::mt19937_64 engine_; std::mt19937_64 engine_;
// Disallow copy & assign
RandomGenerator(const RandomGenerator&) = delete;
RandomGenerator& operator=(const RandomGenerator&) = delete;
}; // class RandomGenerator }; // class RandomGenerator
} // namespace fuzzers } // namespace fuzzers