[lib/Fuzzer] start getting rid of std::cerr. Sadly, these parts of C++ library used in libFuzzer badly interract with the same code used in the target function and also with dfsan. It's easier to just not use std::cerr than to defeat these issues.
llvm-svn: 238078
diff --git a/llvm/lib/Fuzzer/FuzzerIO.cpp b/llvm/lib/Fuzzer/FuzzerIO.cpp
index c6636c8..85703c8 100644
--- a/llvm/lib/Fuzzer/FuzzerIO.cpp
+++ b/llvm/lib/Fuzzer/FuzzerIO.cpp
@@ -9,13 +9,13 @@
// IO functions.
//===----------------------------------------------------------------------===//
#include "FuzzerInternal.h"
-#include <iostream>
#include <iterator>
#include <fstream>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <cstdio>
namespace fuzzer {
@@ -56,9 +56,7 @@
}
void CopyFileToErr(const std::string &Path) {
- std::ifstream T(Path);
- std::copy(std::istreambuf_iterator<char>(T), std::istreambuf_iterator<char>(),
- std::ostream_iterator<char>(std::cerr, ""));
+ Printf("%s", FileToString(Path).c_str());
}
void WriteToFile(const Unit &U, const std::string &Path) {
@@ -86,4 +84,11 @@
ExecuteCommand(Cmd);
}
+void Printf(const char *Fmt, ...) {
+ va_list ap;
+ va_start(ap, Fmt);
+ vfprintf(stderr, Fmt, ap);
+ va_end(ap);
+}
+
} // namespace fuzzer