[DominatorTree] Add support for mixed pre/post CFG views.
[llvm-project.git] / compiler-rt / lib / fuzzer / FuzzerDefs.h
blob1a2752af2f4d5626336140f62159eaab0536cc62
1 //===- FuzzerDefs.h - Internal header for the Fuzzer ------------*- C++ -* ===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // Basic definitions.
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_FUZZER_DEFS_H
12 #define LLVM_FUZZER_DEFS_H
14 #include <cassert>
15 #include <cstddef>
16 #include <cstdint>
17 #include <cstring>
18 #include <memory>
19 #include <set>
20 #include <string>
21 #include <vector>
24 namespace fuzzer {
26 template <class T> T Min(T a, T b) { return a < b ? a : b; }
27 template <class T> T Max(T a, T b) { return a > b ? a : b; }
29 class Random;
30 class Dictionary;
31 class DictionaryEntry;
32 class MutationDispatcher;
33 struct FuzzingOptions;
34 class InputCorpus;
35 struct InputInfo;
36 struct ExternalFunctions;
38 // Global interface to functions that may or may not be available.
39 extern ExternalFunctions *EF;
41 // We are using a custom allocator to give a different symbol name to STL
42 // containers in order to avoid ODR violations.
43 template<typename T>
44 class fuzzer_allocator: public std::allocator<T> {
45 public:
46 fuzzer_allocator() = default;
48 template<class U>
49 fuzzer_allocator(const fuzzer_allocator<U>&) {}
51 template<class Other>
52 struct rebind { typedef fuzzer_allocator<Other> other; };
55 template<typename T>
56 using Vector = std::vector<T, fuzzer_allocator<T>>;
58 template<typename T>
59 using Set = std::set<T, std::less<T>, fuzzer_allocator<T>>;
61 typedef Vector<uint8_t> Unit;
62 typedef Vector<Unit> UnitVector;
63 typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
65 int FuzzerDriver(int *argc, char ***argv, UserCallback Callback);
67 uint8_t *ExtraCountersBegin();
68 uint8_t *ExtraCountersEnd();
69 void ClearExtraCounters();
71 extern bool RunningUserCallback;
73 } // namespace fuzzer
75 #endif // LLVM_FUZZER_DEFS_H