From: Marcos Pividori Date: Tue, 13 Dec 2016 17:46:11 +0000 (+0000) Subject: [libFuzzer] Clean up headers and file formatting of LibFuzzer files. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=178fe587454a4decec0b2c9c05f71fcb44cd9311;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/lib/Fuzzer/FuzzerCorpus.h b/llvm/lib/Fuzzer/FuzzerCorpus.h index bbe192f..88e83b32 100644 --- a/llvm/lib/Fuzzer/FuzzerCorpus.h +++ b/llvm/lib/Fuzzer/FuzzerCorpus.h @@ -12,14 +12,14 @@ #ifndef LLVM_FUZZER_CORPUS #define LLVM_FUZZER_CORPUS -#include -#include - #include "FuzzerDefs.h" #include "FuzzerIO.h" #include "FuzzerRandom.h" #include "FuzzerSHA1.h" #include "FuzzerTracePC.h" +#include +#include +#include namespace fuzzer { diff --git a/llvm/lib/Fuzzer/FuzzerCrossOver.cpp b/llvm/lib/Fuzzer/FuzzerCrossOver.cpp index e86e23f..8b0fd7d 100644 --- a/llvm/lib/Fuzzer/FuzzerCrossOver.cpp +++ b/llvm/lib/Fuzzer/FuzzerCrossOver.cpp @@ -9,11 +9,10 @@ // Cross over test inputs. //===----------------------------------------------------------------------===// -#include - #include "FuzzerDefs.h" #include "FuzzerMutate.h" #include "FuzzerRandom.h" +#include namespace fuzzer { diff --git a/llvm/lib/Fuzzer/FuzzerDefs.h b/llvm/lib/Fuzzer/FuzzerDefs.h index 89d675a..a699045 100644 --- a/llvm/lib/Fuzzer/FuzzerDefs.h +++ b/llvm/lib/Fuzzer/FuzzerDefs.h @@ -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 diff --git a/llvm/lib/Fuzzer/FuzzerDictionary.h b/llvm/lib/Fuzzer/FuzzerDictionary.h index b23b4b0..eba0eab 100644 --- a/llvm/lib/Fuzzer/FuzzerDictionary.h +++ b/llvm/lib/Fuzzer/FuzzerDictionary.h @@ -122,4 +122,3 @@ bool ParseDictionaryFile(const std::string &Text, std::vector *Units); } // namespace fuzzer #endif // LLVM_FUZZER_DICTIONARY_H - diff --git a/llvm/lib/Fuzzer/FuzzerDriver.cpp b/llvm/lib/Fuzzer/FuzzerDriver.cpp index f4f1a4d..fb86cbc 100644 --- a/llvm/lib/Fuzzer/FuzzerDriver.cpp +++ b/llvm/lib/Fuzzer/FuzzerDriver.cpp @@ -15,7 +15,6 @@ #include "FuzzerIO.h" #include "FuzzerMutate.h" #include "FuzzerRandom.h" - #include #include #include diff --git a/llvm/lib/Fuzzer/FuzzerExtFunctions.h b/llvm/lib/Fuzzer/FuzzerExtFunctions.h index 2ec86cb..2672a38 100644 --- a/llvm/lib/Fuzzer/FuzzerExtFunctions.h +++ b/llvm/lib/Fuzzer/FuzzerExtFunctions.h @@ -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 diff --git a/llvm/lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp b/llvm/lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp index 65b0458..06bddd5 100644 --- a/llvm/lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp +++ b/llvm/lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp @@ -46,5 +46,7 @@ ExternalFunctions::ExternalFunctions() { #undef EXT_FUNC } + } // namespace fuzzer + #endif // LIBFUZZER_APPLE diff --git a/llvm/lib/Fuzzer/FuzzerExtFunctionsWeak.cpp b/llvm/lib/Fuzzer/FuzzerExtFunctionsWeak.cpp index cb3b311..7b02b6f 100644 --- a/llvm/lib/Fuzzer/FuzzerExtFunctionsWeak.cpp +++ b/llvm/lib/Fuzzer/FuzzerExtFunctionsWeak.cpp @@ -47,5 +47,7 @@ ExternalFunctions::ExternalFunctions() { #undef EXT_FUNC } + } // namespace fuzzer + #endif // LIBFUZZER_LINUX diff --git a/llvm/lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp b/llvm/lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp index 3c42e53..e10f7b4 100644 --- a/llvm/lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp +++ b/llvm/lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp @@ -50,5 +50,7 @@ ExternalFunctions::ExternalFunctions() { #undef EXT_FUNC } + } // namespace fuzzer + #endif // LIBFUZZER_WINDOWS diff --git a/llvm/lib/Fuzzer/FuzzerFnAdapter.h b/llvm/lib/Fuzzer/FuzzerFnAdapter.h index eb2c219..e53b628 100644 --- a/llvm/lib/Fuzzer/FuzzerFnAdapter.h +++ b/llvm/lib/Fuzzer/FuzzerFnAdapter.h @@ -15,10 +15,9 @@ #ifndef LLVM_FUZZER_ADAPTER_H #define LLVM_FUZZER_ADAPTER_H +#include #include #include - -#include #include #include #include diff --git a/llvm/lib/Fuzzer/FuzzerIO.cpp b/llvm/lib/Fuzzer/FuzzerIO.cpp index 5d4d415..eda8e87 100644 --- a/llvm/lib/Fuzzer/FuzzerIO.cpp +++ b/llvm/lib/Fuzzer/FuzzerIO.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // IO functions. //===----------------------------------------------------------------------===// + #include "FuzzerIO.h" #include "FuzzerDefs.h" #include "FuzzerExtFunctions.h" @@ -15,8 +16,8 @@ #include #include #include -#include #include +#include namespace fuzzer { diff --git a/llvm/lib/Fuzzer/FuzzerIO.h b/llvm/lib/Fuzzer/FuzzerIO.h index 39634f9..f5651cf 100644 --- a/llvm/lib/Fuzzer/FuzzerIO.h +++ b/llvm/lib/Fuzzer/FuzzerIO.h @@ -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 diff --git a/llvm/lib/Fuzzer/FuzzerIOPosix.cpp b/llvm/lib/Fuzzer/FuzzerIOPosix.cpp index a4290fa..53a58f9 100644 --- a/llvm/lib/Fuzzer/FuzzerIOPosix.cpp +++ b/llvm/lib/Fuzzer/FuzzerIOPosix.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// // IO functions implementation using Posix API. //===----------------------------------------------------------------------===// - #include "FuzzerDefs.h" #if LIBFUZZER_POSIX + #include "FuzzerExtFunctions.h" #include "FuzzerIO.h" #include @@ -84,4 +84,5 @@ std::string DirName(const std::string &FileName) { } } // namespace fuzzer + #endif // LIBFUZZER_POSIX diff --git a/llvm/lib/Fuzzer/FuzzerIOWindows.cpp b/llvm/lib/Fuzzer/FuzzerIOWindows.cpp index aaa2e34..df530cd 100644 --- a/llvm/lib/Fuzzer/FuzzerIOWindows.cpp +++ b/llvm/lib/Fuzzer/FuzzerIOWindows.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// // IO functions implementation for Windows. //===----------------------------------------------------------------------===// - #include "FuzzerDefs.h" #if LIBFUZZER_WINDOWS + #include "FuzzerExtFunctions.h" #include "FuzzerIO.h" #include @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include namespace fuzzer { @@ -144,4 +144,5 @@ std::string DirName(const std::string &FileName) { } } // namespace fuzzer + #endif // LIBFUZZER_WINDOWS diff --git a/llvm/lib/Fuzzer/FuzzerInternal.h b/llvm/lib/Fuzzer/FuzzerInternal.h index e3a1801..f1e7415 100644 --- a/llvm/lib/Fuzzer/FuzzerInternal.h +++ b/llvm/lib/Fuzzer/FuzzerInternal.h @@ -12,19 +12,18 @@ #ifndef LLVM_FUZZER_INTERNAL_H #define LLVM_FUZZER_INTERNAL_H -#include -#include -#include -#include -#include -#include - #include "FuzzerDefs.h" #include "FuzzerExtFunctions.h" #include "FuzzerInterface.h" #include "FuzzerOptions.h" #include "FuzzerSHA1.h" #include "FuzzerValueBitMap.h" +#include +#include +#include +#include +#include +#include namespace fuzzer { diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index f96fc74..93db617 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -15,7 +15,6 @@ #include "FuzzerMutate.h" #include "FuzzerRandom.h" #include "FuzzerTracePC.h" - #include #include #include diff --git a/llvm/lib/Fuzzer/FuzzerSHA1.h b/llvm/lib/Fuzzer/FuzzerSHA1.h index b3e6111..3b5e6e8 100644 --- a/llvm/lib/Fuzzer/FuzzerSHA1.h +++ b/llvm/lib/Fuzzer/FuzzerSHA1.h @@ -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 diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.h b/llvm/lib/Fuzzer/FuzzerTracePC.h index acff27f..df03739 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.h +++ b/llvm/lib/Fuzzer/FuzzerTracePC.h @@ -12,10 +12,9 @@ #ifndef LLVM_FUZZER_TRACE_PC #define LLVM_FUZZER_TRACE_PC -#include - #include "FuzzerDefs.h" #include "FuzzerValueBitMap.h" +#include namespace fuzzer { diff --git a/llvm/lib/Fuzzer/FuzzerUtil.h b/llvm/lib/Fuzzer/FuzzerUtil.h index 78b7c24..08058c5 100644 --- a/llvm/lib/Fuzzer/FuzzerUtil.h +++ b/llvm/lib/Fuzzer/FuzzerUtil.h @@ -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 &Args, } } // namespace fuzzer + #endif // LLVM_FUZZER_UTIL_H diff --git a/llvm/lib/Fuzzer/FuzzerUtilDarwin.cpp b/llvm/lib/Fuzzer/FuzzerUtilDarwin.cpp index 62f0f22..9674368 100644 --- a/llvm/lib/Fuzzer/FuzzerUtilDarwin.cpp +++ b/llvm/lib/Fuzzer/FuzzerUtilDarwin.cpp @@ -10,6 +10,7 @@ //===----------------------------------------------------------------------===// #include "FuzzerDefs.h" #if LIBFUZZER_APPLE + #include "FuzzerIO.h" #include #include @@ -145,5 +146,7 @@ int ExecuteCommand(const std::string &Command) { } return ProcessStatus; } -} + +} // namespace fuzzer + #endif // LIBFUZZER_APPLE diff --git a/llvm/lib/Fuzzer/FuzzerUtilLinux.cpp b/llvm/lib/Fuzzer/FuzzerUtilLinux.cpp index 060cec0..dfe7e6f 100644 --- a/llvm/lib/Fuzzer/FuzzerUtilLinux.cpp +++ b/llvm/lib/Fuzzer/FuzzerUtilLinux.cpp @@ -10,10 +10,15 @@ //===----------------------------------------------------------------------===// #include "FuzzerDefs.h" #if LIBFUZZER_LINUX + #include + namespace fuzzer { + int ExecuteCommand(const std::string &Command) { return system(Command.c_str()); } -} + +} // namespace fuzzer + #endif // LIBFUZZER_LINUX diff --git a/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp b/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp index fc058cd..8b484b8 100644 --- a/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp +++ b/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp @@ -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 diff --git a/llvm/lib/Fuzzer/FuzzerUtilWindows.cpp b/llvm/lib/Fuzzer/FuzzerUtilWindows.cpp index 91509cc..fea09a6 100644 --- a/llvm/lib/Fuzzer/FuzzerUtilWindows.cpp +++ b/llvm/lib/Fuzzer/FuzzerUtilWindows.cpp @@ -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