[libFuzzer] make libFuzzer build even with a compiler that does not have sanitizer...
[oota-llvm.git] / lib / Fuzzer / FuzzerDFSan.h
index 6398575e6955454f0f97ae5de891f95272c81c60..eb206ec61ce860fa67b9cc9cea36773377a5971f 100644 (file)
 #ifndef LLVM_FUZZER_DFSAN_H
 #define LLVM_FUZZER_DFSAN_H
 
-#ifndef LLVM_FUZZER_SUPPORTS_DFSAN
-# if defined(__linux__)
-#  define LLVM_FUZZER_SUPPORTS_DFSAN 1
-# else
-#  define LLVM_FUZZER_SUPPORTS_DFSAN 0
-# endif  // __linux__
-#endif  // LLVM_FUZZER_SUPPORTS_DFSAN
+#define LLVM_FUZZER_SUPPORTS_DFSAN 0
+#if defined(__has_include)
+# if __has_include(<sanitizer/dfsan_interface.h>)
+#  if defined (__linux__)
+#   undef LLVM_FUZZER_SUPPORTS_DFSAN
+#   define LLVM_FUZZER_SUPPORTS_DFSAN 1
+#   include <sanitizer/dfsan_interface.h>
+#  endif  // __linux__
+# endif
+#endif  // defined(__has_include)
 
-#include <sanitizer/dfsan_interface.h>
 #if LLVM_FUZZER_SUPPORTS_DFSAN
 
 extern "C" {
@@ -42,6 +44,14 @@ static bool ReallyHaveDFSan() {
 }
 }  // namespace fuzzer
 #else
+// When compiling with a compiler which does not support dfsan,
+// this code is still expected to build (but not necessary work).
+typedef unsigned short dfsan_label;
+struct dfsan_label_info {
+  dfsan_label l1, l2;
+  const char *desc;
+  void *userdata;
+};
 namespace fuzzer {
 static bool ReallyHaveDFSan() { return false; }
 }  // namespace fuzzer