1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[libFuzzer] Clean up headers and file formatting of LibFuzzer files.

Reorganize #includes to follow LLVM Coding Standards.
Include some missing headers. Required to use `Printf()`.

Aside from that, this patch contains no functional change.
It is purely a re-organization.

Differential Revision: https://reviews.llvm.org/D27363

llvm-svn: 289560
This commit is contained in:
Marcos Pividori 2016-12-13 17:46:11 +00:00
parent 79b26fd29b
commit 750e7046bb
23 changed files with 48 additions and 28 deletions

View File

@ -12,14 +12,14 @@
#ifndef LLVM_FUZZER_CORPUS
#define LLVM_FUZZER_CORPUS
#include <random>
#include <unordered_set>
#include "FuzzerDefs.h"
#include "FuzzerIO.h"
#include "FuzzerRandom.h"
#include "FuzzerSHA1.h"
#include "FuzzerTracePC.h"
#include <numeric>
#include <random>
#include <unordered_set>
namespace fuzzer {

View File

@ -9,11 +9,10 @@
// Cross over test inputs.
//===----------------------------------------------------------------------===//
#include <cstring>
#include "FuzzerDefs.h"
#include "FuzzerMutate.h"
#include "FuzzerRandom.h"
#include <cstring>
namespace fuzzer {

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// Basic definitions.
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_DEFS_H
#define LLVM_FUZZER_DEFS_H
@ -77,4 +78,5 @@ inline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); }
inline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); }
} // namespace fuzzer
#endif // LLVM_FUZZER_DEFS_H

View File

@ -122,4 +122,3 @@ bool ParseDictionaryFile(const std::string &Text, std::vector<Unit> *Units);
} // namespace fuzzer
#endif // LLVM_FUZZER_DICTIONARY_H

View File

@ -15,7 +15,6 @@
#include "FuzzerIO.h"
#include "FuzzerMutate.h"
#include "FuzzerRandom.h"
#include <algorithm>
#include <atomic>
#include <chrono>

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// Defines an interface to (possibly optional) functions.
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_EXT_FUNCTIONS_H
#define LLVM_FUZZER_EXT_FUNCTIONS_H
@ -30,4 +31,5 @@ struct ExternalFunctions {
#undef EXT_FUNC
};
} // namespace fuzzer
#endif

View File

@ -46,5 +46,7 @@ ExternalFunctions::ExternalFunctions() {
#undef EXT_FUNC
}
} // namespace fuzzer
#endif // LIBFUZZER_APPLE

View File

@ -47,5 +47,7 @@ ExternalFunctions::ExternalFunctions() {
#undef EXT_FUNC
}
} // namespace fuzzer
#endif // LIBFUZZER_LINUX

View File

@ -50,5 +50,7 @@ ExternalFunctions::ExternalFunctions() {
#undef EXT_FUNC
}
} // namespace fuzzer
#endif // LIBFUZZER_WINDOWS

View File

@ -15,10 +15,9 @@
#ifndef LLVM_FUZZER_ADAPTER_H
#define LLVM_FUZZER_ADAPTER_H
#include <algorithm>
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// IO functions.
//===----------------------------------------------------------------------===//
#include "FuzzerIO.h"
#include "FuzzerDefs.h"
#include "FuzzerExtFunctions.h"
@ -15,8 +16,8 @@
#include <cstdarg>
#include <fstream>
#include <iterator>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
namespace fuzzer {

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// IO interface.
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_IO_H
#define LLVM_FUZZER_IO_H
@ -59,4 +60,5 @@ int DuplicateFile(int Fd);
void DeleteFile(const std::string &Path);
} // namespace fuzzer
#endif // LLVM_FUZZER_IO_H

View File

@ -8,9 +8,9 @@
//===----------------------------------------------------------------------===//
// IO functions implementation using Posix API.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_POSIX
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
#include <cstdarg>
@ -84,4 +84,5 @@ std::string DirName(const std::string &FileName) {
}
} // namespace fuzzer
#endif // LIBFUZZER_POSIX

View File

@ -8,9 +8,9 @@
//===----------------------------------------------------------------------===//
// IO functions implementation for Windows.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_WINDOWS
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
#include <cstdarg>
@ -18,8 +18,8 @@
#include <fstream>
#include <io.h>
#include <iterator>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <windows.h>
namespace fuzzer {
@ -144,4 +144,5 @@ std::string DirName(const std::string &FileName) {
}
} // namespace fuzzer
#endif // LIBFUZZER_WINDOWS

View File

@ -12,19 +12,18 @@
#ifndef LLVM_FUZZER_INTERNAL_H
#define LLVM_FUZZER_INTERNAL_H
#include <algorithm>
#include <atomic>
#include <chrono>
#include <climits>
#include <cstdlib>
#include <string.h>
#include "FuzzerDefs.h"
#include "FuzzerExtFunctions.h"
#include "FuzzerInterface.h"
#include "FuzzerOptions.h"
#include "FuzzerSHA1.h"
#include "FuzzerValueBitMap.h"
#include <algorithm>
#include <atomic>
#include <chrono>
#include <climits>
#include <cstdlib>
#include <string.h>
namespace fuzzer {

View File

@ -15,7 +15,6 @@
#include "FuzzerMutate.h"
#include "FuzzerRandom.h"
#include "FuzzerTracePC.h"
#include <algorithm>
#include <cstring>
#include <memory>

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// SHA1 utils.
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_SHA1_H
#define LLVM_FUZZER_SHA1_H
@ -28,4 +29,5 @@ std::string Sha1ToString(const uint8_t Sha1[kSHA1NumBytes]);
std::string Hash(const Unit &U);
} // namespace fuzzer
#endif // LLVM_FUZZER_SHA1_H

View File

@ -12,10 +12,9 @@
#ifndef LLVM_FUZZER_TRACE_PC
#define LLVM_FUZZER_TRACE_PC
#include <set>
#include "FuzzerDefs.h"
#include "FuzzerValueBitMap.h"
#include <set>
namespace fuzzer {

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// Util functions.
//===----------------------------------------------------------------------===//
#ifndef LLVM_FUZZER_UTIL_H
#define LLVM_FUZZER_UTIL_H
@ -67,4 +68,5 @@ inline std::string CloneArgsWithoutX(const std::vector<std::string> &Args,
}
} // namespace fuzzer
#endif // LLVM_FUZZER_UTIL_H

View File

@ -10,6 +10,7 @@
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_APPLE
#include "FuzzerIO.h"
#include <mutex>
#include <signal.h>
@ -145,5 +146,7 @@ int ExecuteCommand(const std::string &Command) {
}
return ProcessStatus;
}
}
} // namespace fuzzer
#endif // LIBFUZZER_APPLE

View File

@ -10,10 +10,15 @@
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_LINUX
#include <stdlib.h>
namespace fuzzer {
int ExecuteCommand(const std::string &Command) {
return system(Command.c_str());
}
}
} // namespace fuzzer
#endif // LIBFUZZER_LINUX

View File

@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
// Misc utils implementation using Posix API.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_POSIX
#include "FuzzerIO.h"
@ -113,5 +112,6 @@ const void *SearchMemory(const void *Data, size_t DataLen, const void *Patt,
return memmem(Data, DataLen, Patt, PattLen);
}
} // namespace fuzzer
} // namespace fuzzer
#endif // LIBFUZZER_POSIX

View File

@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
// Misc utils implementation for Windows.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_WINDOWS
#include "FuzzerIO.h"
@ -179,4 +178,5 @@ const void *SearchMemory(const void *Data, size_t DataLen, const void *Patt,
}
} // namespace fuzzer
#endif // LIBFUZZER_WINDOWS