CxxTokensTest.cpp 648 B

123456789101112131415161718192021222324
  1. // Simple test for a fuzzer. The fuzzer must find a sequence of C++ tokens.
  2. #include <cstdint>
  3. #include <cstdlib>
  4. #include <cstddef>
  5. #include <cstring>
  6. #include <iostream>
  7. static void Found() {
  8. std::cout << "BINGO; Found the target, exiting\n";
  9. exit(1);
  10. }
  11. extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
  12. // looking for "thread_local unsigned A;"
  13. if (Size < 24) return;
  14. if (0 == memcmp(&Data[0], "thread_local", 12))
  15. if (Data[12] == ' ')
  16. if (0 == memcmp(&Data[13], "unsigned", 8))
  17. if (Data[21] == ' ')
  18. if (Data[22] == 'A')
  19. if (Data[23] == ';')
  20. Found();
  21. }