summaryrefslogtreecommitdiff
path: root/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2018-08-30 15:54:44 +0000
committerMatt Morehouse <mascasa@google.com>2018-08-30 15:54:44 +0000
commitcf39be7355d4a581676afa3703be3c2383319d91 (patch)
tree8405cbb71f14c910e308d6669e185756c536cce6 /compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
parent91402023b47d8afff1cb7c0abdace7a630a9aaeb (diff)
[libFuzzer] Port to Windows
Summary: Port libFuzzer to windows-msvc. This patch allows libFuzzer targets to be built and run on Windows, using -fsanitize=fuzzer and/or fsanitize=fuzzer-no-link. It allows these forms of coverage instrumentation to work on Windows as well. It does not fix all issues, such as those with -fsanitize-coverage=stack-depth, which is not usable on Windows as of this patch. It also does not fix any libFuzzer integration tests. Nearly all of them fail to compile, fixing them will come in a later patch, so libFuzzer tests are disabled on Windows until them. Patch By: metzman Reviewers: morehouse, rnk Reviewed By: morehouse, rnk Subscribers: #sanitizers, delcypher, morehouse, kcc, eraman Differential Revision: https://reviews.llvm.org/D51022
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
index 17e884d3c4c..401b4cbbf74 100644
--- a/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
@@ -46,6 +46,13 @@ size_t FileSize(const std::string &Path) {
return St.st_size;
}
+std::string Basename(const std::string &Path) {
+ size_t Pos = Path.rfind(GetSeparator());
+ if (Pos == std::string::npos) return Path;
+ assert(Pos < Path.size());
+ return Path.substr(Pos + 1);
+}
+
void ListFilesInDirRecursive(const std::string &Dir, long *Epoch,
Vector<std::string> *V, bool TopDir) {
auto E = GetEpoch(Dir);