[libFuzzer] Clean up headers and file formatting of LibFuzzer files.
authorMarcos Pividori <mpividori@google.com>
Tue, 13 Dec 2016 17:46:11 +0000 (17:46 +0000)
committerMarcos Pividori <mpividori@google.com>
Tue, 13 Dec 2016 17:46:11 +0000 (17:46 +0000)
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

23 files changed:
llvm/lib/Fuzzer/FuzzerCorpus.h
llvm/lib/Fuzzer/FuzzerCrossOver.cpp
llvm/lib/Fuzzer/FuzzerDefs.h
llvm/lib/Fuzzer/FuzzerDictionary.h
llvm/lib/Fuzzer/FuzzerDriver.cpp
llvm/lib/Fuzzer/FuzzerExtFunctions.h
llvm/lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp
llvm/lib/Fuzzer/FuzzerExtFunctionsWeak.cpp
llvm/lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp
llvm/lib/Fuzzer/FuzzerFnAdapter.h
llvm/lib/Fuzzer/FuzzerIO.cpp
llvm/lib/Fuzzer/FuzzerIO.h
llvm/lib/Fuzzer/FuzzerIOPosix.cpp
llvm/lib/Fuzzer/FuzzerIOWindows.cpp
llvm/lib/Fuzzer/FuzzerInternal.h
llvm/lib/Fuzzer/FuzzerLoop.cpp
llvm/lib/Fuzzer/FuzzerSHA1.h
llvm/lib/Fuzzer/FuzzerTracePC.h
llvm/lib/Fuzzer/FuzzerUtil.h
llvm/lib/Fuzzer/FuzzerUtilDarwin.cpp
llvm/lib/Fuzzer/FuzzerUtilLinux.cpp
llvm/lib/Fuzzer/FuzzerUtilPosix.cpp
llvm/lib/Fuzzer/FuzzerUtilWindows.cpp

index bbe192f..88e83b3 100644 (file)
 #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 {
 
index e86e23f..8b0fd7d 100644 (file)
@@ -9,11 +9,10 @@
 // Cross over test inputs.
 //===----------------------------------------------------------------------===//
 
-#include <cstring>
-
 #include "FuzzerDefs.h"
 #include "FuzzerMutate.h"
 #include "FuzzerRandom.h"
+#include <cstring>
 
 namespace fuzzer {
 
index 89d675a..a699045 100644 (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
index b23b4b0..eba0eab 100644 (file)
@@ -122,4 +122,3 @@ bool ParseDictionaryFile(const std::string &Text, std::vector<Unit> *Units);
 }  // namespace fuzzer
 
 #endif  // LLVM_FUZZER_DICTIONARY_H
-
index f4f1a4d..fb86cbc 100644 (file)
@@ -15,7 +15,6 @@
 #include "FuzzerIO.h"
 #include "FuzzerMutate.h"
 #include "FuzzerRandom.h"
-
 #include <algorithm>
 #include <atomic>
 #include <chrono>
index 2ec86cb..2672a38 100644 (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
index 65b0458..06bddd5 100644 (file)
@@ -46,5 +46,7 @@ ExternalFunctions::ExternalFunctions() {
 
 #undef EXT_FUNC
 }
+
 } // namespace fuzzer
+
 #endif // LIBFUZZER_APPLE
index cb3b311..7b02b6f 100644 (file)
@@ -47,5 +47,7 @@ ExternalFunctions::ExternalFunctions() {
 
 #undef EXT_FUNC
 }
+
 } // namespace fuzzer
+
 #endif // LIBFUZZER_LINUX
index 3c42e53..e10f7b4 100644 (file)
@@ -50,5 +50,7 @@ ExternalFunctions::ExternalFunctions() {
 
 #undef EXT_FUNC
 }
+
 } // namespace fuzzer
+
 #endif // LIBFUZZER_WINDOWS
index eb2c219..e53b628 100644 (file)
 #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>
index 5d4d415..eda8e87 100644 (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 {
 
index 39634f9..f5651cf 100644 (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
index a4290fa..53a58f9 100644 (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
index aaa2e34..df530cd 100644 (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
index e3a1801..f1e7415 100644 (file)
 #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 {
 
index f96fc74..93db617 100644 (file)
@@ -15,7 +15,6 @@
 #include "FuzzerMutate.h"
 #include "FuzzerRandom.h"
 #include "FuzzerTracePC.h"
-
 #include <algorithm>
 #include <cstring>
 #include <memory>
index b3e6111..3b5e6e8 100644 (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
index acff27f..df03739 100644 (file)
 #ifndef LLVM_FUZZER_TRACE_PC
 #define LLVM_FUZZER_TRACE_PC
 
-#include <set>
-
 #include "FuzzerDefs.h"
 #include "FuzzerValueBitMap.h"
+#include <set>
 
 namespace fuzzer {
 
index 78b7c24..08058c5 100644 (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
index 62f0f22..9674368 100644 (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
index 060cec0..dfe7e6f 100644 (file)
 //===----------------------------------------------------------------------===//
 #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
index fc058cd..8b484b8 100644 (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
index 91509cc..fea09a6 100644 (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