mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
merge bitcoin#20812: Bump FuzzedDataProvider.h
This commit is contained in:
parent
f6b2a1722a
commit
ba90fb6338
@ -14,6 +14,7 @@
|
|||||||
#define LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_
|
#define LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -72,6 +73,8 @@ class FuzzedDataProvider {
|
|||||||
|
|
||||||
// Returns a value from the given array.
|
// Returns a value from the given array.
|
||||||
template <typename T, size_t size> T PickValueInArray(const T (&array)[size]);
|
template <typename T, size_t size> T PickValueInArray(const T (&array)[size]);
|
||||||
|
template <typename T, size_t size>
|
||||||
|
T PickValueInArray(const std::array<T, size> &array);
|
||||||
template <typename T> T PickValueInArray(std::initializer_list<const T> list);
|
template <typename T> T PickValueInArray(std::initializer_list<const T> list);
|
||||||
|
|
||||||
// Writes data to the given destination and returns number of bytes written.
|
// Writes data to the given destination and returns number of bytes written.
|
||||||
@ -302,6 +305,12 @@ T FuzzedDataProvider::PickValueInArray(const T (&array)[size]) {
|
|||||||
return array[ConsumeIntegralInRange<size_t>(0, size - 1)];
|
return array[ConsumeIntegralInRange<size_t>(0, size - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t size>
|
||||||
|
T FuzzedDataProvider::PickValueInArray(const std::array<T, size> &array) {
|
||||||
|
static_assert(size > 0, "The array must be non empty.");
|
||||||
|
return array[ConsumeIntegralInRange<size_t>(0, size - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T FuzzedDataProvider::PickValueInArray(std::initializer_list<const T> list) {
|
T FuzzedDataProvider::PickValueInArray(std::initializer_list<const T> list) {
|
||||||
// TODO(Dor1s): switch to static_assert once C++14 is allowed.
|
// TODO(Dor1s): switch to static_assert once C++14 is allowed.
|
||||||
|
Loading…
Reference in New Issue
Block a user