diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2015-01-29 15:49:22 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2015-01-29 15:49:22 +0000 |
commit | 7b54ed221a20d30b6a67f4544b75da5b6d4d4380 (patch) | |
tree | b953ad1d38f66558e8f776232e4c601a34507c77 /llvm/lib/Fuzzer/FuzzerMutate.cpp | |
parent | 4b2f17a1d333ba539b219c400000d1ca2be4c7a4 (diff) | |
download | llvm-7b54ed221a20d30b6a67f4544b75da5b6d4d4380.zip llvm-7b54ed221a20d30b6a67f4544b75da5b6d4d4380.tar.gz llvm-7b54ed221a20d30b6a67f4544b75da5b6d4d4380.tar.bz2 |
Temporarily reverting the fuzzer library as it causes too many build issues for MSVC users. This reverts: 227445, 227395, 227389, 227357, 227254, 227252
llvm-svn: 227452
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerMutate.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerMutate.cpp | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerMutate.cpp b/llvm/lib/Fuzzer/FuzzerMutate.cpp deleted file mode 100644 index 2db8fac9..0000000 --- a/llvm/lib/Fuzzer/FuzzerMutate.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===- FuzzerMutate.cpp - Mutate a test input -----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// Mutate a test input. -//===----------------------------------------------------------------------===// - -#include "FuzzerInternal.h" - -namespace fuzzer { - -static char FlipRandomBit(char X) { - int Bit = rand() % 8; - char Mask = 1 << Bit; - char R; - if (X & (1 << Bit)) - R = X & ~Mask; - else - R = X | Mask; - assert(R != X); - return R; -} - -static char RandCh() { - if (rand() % 2) return rand(); - const char *Special = "!*'();:@&=+$,/?%#[]123ABCxyz-`~."; - return Special[rand() % (sizeof(Special) - 1)]; -} - -void Mutate(Unit *U, size_t MaxLen) { - assert(MaxLen > 0); - assert(U->size() <= MaxLen); - switch (rand() % 3) { - case 0: - if (U->size()) - U->erase(U->begin() + rand() % U->size()); - break; - case 1: - if (U->empty()) { - U->push_back(RandCh()); - } else if (U->size() < MaxLen) { - U->insert(U->begin() + rand() % U->size(), RandCh()); - } else { // At MaxLen. - uint8_t Ch = RandCh(); - size_t Idx = rand() % U->size(); - (*U)[Idx] = Ch; - } - break; - default: - if (!U->empty()) { - size_t idx = rand() % U->size(); - (*U)[idx] = FlipRandomBit((*U)[idx]); - } - break; - } -} - -} // namespace fuzzer |