aboutsummaryrefslogtreecommitdiff
path: root/lib/Fuzzer/FuzzerDefs.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fuzzer/FuzzerDefs.h')
-rw-r--r--lib/Fuzzer/FuzzerDefs.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Fuzzer/FuzzerDefs.h b/lib/Fuzzer/FuzzerDefs.h
index bd1827508002..27f5719236dd 100644
--- a/lib/Fuzzer/FuzzerDefs.h
+++ b/lib/Fuzzer/FuzzerDefs.h
@@ -36,17 +36,29 @@
#error "Support for your platform has not been implemented"
#endif
+#ifndef __has_attribute
+# define __has_attribute(x) 0
+#endif
+
#define LIBFUZZER_POSIX LIBFUZZER_APPLE || LIBFUZZER_LINUX
#ifdef __x86_64
-#define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt")))
+# if __has_attribute(target)
+# define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt")))
+# else
+# define ATTRIBUTE_TARGET_POPCNT
+# endif
#else
-#define ATTRIBUTE_TARGET_POPCNT
+# define ATTRIBUTE_TARGET_POPCNT
#endif
#ifdef __clang__ // avoid gcc warning.
-# define ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
+# if __has_attribute(no_sanitize)
+# define ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
+# else
+# define ATTRIBUTE_NO_SANITIZE_MEMORY
+# endif
# define ALWAYS_INLINE __attribute__((always_inline))
#else
# define ATTRIBUTE_NO_SANITIZE_MEMORY