Lines Matching refs:Rand
27 MutationDispatcher::MutationDispatcher(Random &Rand, in MutationDispatcher() argument
29 : Rand(Rand), Options(Options) { in MutationDispatcher()
63 static char RandCh(Random &Rand) { in RandCh() argument
64 if (Rand.RandBool()) return Rand(256); in RandCh()
66 return Special[Rand(sizeof(Special) - 1)]; in RandCh()
71 return EF->LLVMFuzzerCustomMutator(Data, Size, MaxSize, Rand.Rand()); in Mutate_Custom()
85 Data, Size, Other.data(), Other.size(), U.data(), U.size(), Rand.Rand()); in Mutate_CustomCrossOver()
97 Rand(std::min(Size, (size_t)8)) + 1; // [1,8] and <= Size. in Mutate_ShuffleBytes()
98 size_t ShuffleStart = Rand(Size - ShuffleAmount); in Mutate_ShuffleBytes()
100 std::shuffle(Data + ShuffleStart, Data + ShuffleStart + ShuffleAmount, Rand); in Mutate_ShuffleBytes()
107 size_t N = Rand(Size / 2) + 1; in Mutate_EraseBytes()
109 size_t Idx = Rand(Size - N + 1); in Mutate_EraseBytes()
119 size_t Idx = Rand(Size + 1); in Mutate_InsertByte()
122 Data[Idx] = RandCh(Rand); in Mutate_InsertByte()
132 size_t N = Rand(MaxBytesToInsert - kMinBytesToInsert + 1) + kMinBytesToInsert; in Mutate_InsertRepeatedBytes()
134 size_t Idx = Rand(Size + 1); in Mutate_InsertRepeatedBytes()
138 uint8_t Byte = Rand.RandBool() ? Rand(256) : (Rand.RandBool() ? 0 : 255); in Mutate_InsertRepeatedBytes()
147 size_t Idx = Rand(Size); in Mutate_ChangeByte()
148 Data[Idx] = RandCh(Rand); in Mutate_ChangeByte()
155 size_t Idx = Rand(Size); in Mutate_ChangeBit()
156 Data[Idx] ^= 1 << Rand(8); in Mutate_ChangeBit()
172 Rand.RandBool(); in ApplyDictionaryEntry()
173 if (Rand.RandBool()) { // Insert W. in ApplyDictionaryEntry()
175 size_t Idx = UsePositionHint ? DE.GetPositionHint() : Rand(Size + 1); in ApplyDictionaryEntry()
181 size_t Idx = UsePositionHint ? DE.GetPositionHint() : Rand(Size - W.size()); in ApplyDictionaryEntry()
198 bool HandleFirst = Rand.RandBool(); in MakeDictionaryEntryFromCMP()
218 return DictionaryEntry(W, Positions[Rand(NumPositions)]); in MakeDictionaryEntryFromCMP()
228 if (Rand.RandBool()) Arg1 = Bswap(Arg1); in MakeDictionaryEntryFromCMP()
229 if (Rand.RandBool()) Arg2 = Bswap(Arg2); in MakeDictionaryEntryFromCMP()
230 T Arg1Mutation = Arg1 + Rand(-1, 1); in MakeDictionaryEntryFromCMP()
231 T Arg2Mutation = Arg2 + Rand(-1, 1); in MakeDictionaryEntryFromCMP()
246 switch (Rand(4)) { in Mutate_AddWordFromTORC()
248 auto X = TPC.TORC8.Get(Rand.Rand()); in Mutate_AddWordFromTORC()
252 auto X = TPC.TORC4.Get(Rand.Rand()); in Mutate_AddWordFromTORC()
253 if ((X.A >> 16) == 0 && (X.B >> 16) == 0 && Rand.RandBool()) in Mutate_AddWordFromTORC()
259 auto X = TPC.TORCW.Get(Rand.Rand()); in Mutate_AddWordFromTORC()
263 auto X = TPC.MMT.Get(Rand.Rand()); in Mutate_AddWordFromTORC()
289 DictionaryEntry &DE = D[Rand(D.size())]; in AddWordFromDictionary()
302 size_t ToBeg = Rand(ToSize); in CopyPartOf()
303 size_t CopySize = Rand(ToSize - ToBeg) + 1; in CopyPartOf()
306 size_t FromBeg = Rand(FromSize - CopySize + 1); in CopyPartOf()
320 size_t CopySize = Rand(MaxCopySize) + 1; in InsertPartOf()
321 size_t FromBeg = Rand(FromSize - CopySize + 1); in InsertPartOf()
323 size_t ToInsertPos = Rand(ToSize + 1); in InsertPartOf()
343 if (Size == MaxSize || Rand.RandBool()) in Mutate_CopyPart()
352 size_t B = Rand(Size); in Mutate_ChangeASCIIInteger()
365 switch(Rand(5)) { in Mutate_ChangeASCIIInteger()
370 case 4: Val = Rand(Val * Val); break; in Mutate_ChangeASCIIInteger()
384 size_t ChangeBinaryInteger(uint8_t *Data, size_t Size, Random &Rand) { in ChangeBinaryInteger() argument
386 size_t Off = Rand(Size - sizeof(T) + 1); in ChangeBinaryInteger()
389 if (Off < 64 && !Rand(4)) { in ChangeBinaryInteger()
391 if (Rand.RandBool()) in ChangeBinaryInteger()
395 T Add = Rand(21); in ChangeBinaryInteger()
397 if (Rand.RandBool()) in ChangeBinaryInteger()
401 if (Add == 0 || Rand.RandBool()) // Maybe negate. in ChangeBinaryInteger()
412 switch (Rand(4)) { in Mutate_ChangeBinaryInteger()
413 case 3: return ChangeBinaryInteger<uint64_t>(Data, Size, Rand); in Mutate_ChangeBinaryInteger()
414 case 2: return ChangeBinaryInteger<uint32_t>(Data, Size, Rand); in Mutate_ChangeBinaryInteger()
415 case 1: return ChangeBinaryInteger<uint16_t>(Data, Size, Rand); in Mutate_ChangeBinaryInteger()
416 case 0: return ChangeBinaryInteger<uint8_t>(Data, Size, Rand); in Mutate_ChangeBinaryInteger()
430 switch(Rand(3)) { in Mutate_CrossOver()
531 auto M = Mutators[Rand(Mutators.size())]; in MutateImpl()