[libFuzzer] add -only_ascii flag
[oota-llvm.git] / lib / Fuzzer / FuzzerUtil.cpp
index e381c04063217982b97ea3cdca5e6d922af361db..e76adb37481ce400e64a6b3db06e6956fc79ae4a 100644 (file)
@@ -73,4 +73,17 @@ void ExecuteCommand(const std::string &Command) {
   system(Command.c_str());
 }
 
+bool ToASCII(Unit &U) {
+  bool Changed = false;
+  for (auto &X : U) {
+    auto NewX = X;
+    NewX &= 127;
+    if (!isspace(NewX) && !isprint(NewX))
+      NewX = ' ';
+    Changed |= NewX != X;
+    X = NewX;
+  }
+  return Changed;
+}
+
 }  // namespace fuzzer