forked from OSchip/llvm-project
Revert "[libFuzzer] Use std::discrete_distribution for input selection."
This reverts r339973 due to msan.test failing on sanitizer-x86_64-linux-fuzzer bot. llvm-svn: 339976
This commit is contained in:
parent
9e86844d54
commit
be57e8e328
|
@ -174,7 +174,7 @@ class InputCorpus {
|
||||||
|
|
||||||
// Returns an index of random unit from the corpus to mutate.
|
// Returns an index of random unit from the corpus to mutate.
|
||||||
size_t ChooseUnitIdxToMutate(Random &Rand) {
|
size_t ChooseUnitIdxToMutate(Random &Rand) {
|
||||||
size_t Idx = CorpusDistribution(Rand);
|
size_t Idx = static_cast<size_t>(CorpusDistribution(Rand));
|
||||||
assert(Idx < Inputs.size());
|
assert(Idx < Inputs.size());
|
||||||
return Idx;
|
return Idx;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,9 @@ private:
|
||||||
void UpdateCorpusDistribution() {
|
void UpdateCorpusDistribution() {
|
||||||
size_t N = Inputs.size();
|
size_t N = Inputs.size();
|
||||||
assert(N);
|
assert(N);
|
||||||
|
Intervals.resize(N + 1);
|
||||||
Weights.resize(N);
|
Weights.resize(N);
|
||||||
|
std::iota(Intervals.begin(), Intervals.end(), 0);
|
||||||
for (size_t i = 0; i < N; i++)
|
for (size_t i = 0; i < N; i++)
|
||||||
Weights[i] = Inputs[i]->NumFeatures
|
Weights[i] = Inputs[i]->NumFeatures
|
||||||
? (i + 1) * (Inputs[i]->HasFocusFunction ? 1000 : 1)
|
? (i + 1) * (Inputs[i]->HasFocusFunction ? 1000 : 1)
|
||||||
|
@ -289,11 +291,12 @@ private:
|
||||||
Printf("%f ", Weights[i]);
|
Printf("%f ", Weights[i]);
|
||||||
Printf("Weights\n");
|
Printf("Weights\n");
|
||||||
}
|
}
|
||||||
CorpusDistribution =
|
CorpusDistribution = std::piecewise_constant_distribution<double>(
|
||||||
std::discrete_distribution<size_t>(Weights.begin(), Weights.end());
|
Intervals.begin(), Intervals.end(), Weights.begin());
|
||||||
}
|
}
|
||||||
std::discrete_distribution<size_t> CorpusDistribution;
|
std::piecewise_constant_distribution<double> CorpusDistribution;
|
||||||
|
|
||||||
|
Vector<double> Intervals;
|
||||||
Vector<double> Weights;
|
Vector<double> Weights;
|
||||||
|
|
||||||
std::unordered_set<std::string> Hashes;
|
std::unordered_set<std::string> Hashes;
|
||||||
|
|
Loading…
Reference in New Issue