Bug 1437482 - gcc 8 has no-sanitize but not the {un,}signed-integer-overflow option r?waldo draft
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 12 Feb 2018 12:07:52 +0100
changeset 754862 1d14781a9ace221501d3f40327410fdc6688ea33
parent 754572 e43f2f6ea111c2d059d95fa9a71516b869a69698
child 756008 0a2d6ac06578b810d706e315361febea128ce86e
push id99018
push userbmo:sledru@mozilla.com
push dateWed, 14 Feb 2018 12:24:03 +0000
reviewerswaldo
bugs1437482
milestone60.0a1
Bug 1437482 - gcc 8 has no-sanitize but not the {un,}signed-integer-overflow option r?waldo MozReview-Commit-ID: EfRYhaISZfL
mfbt/Attributes.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -233,16 +233,23 @@
 #endif
 
 #if defined(__has_attribute)
 #  if __has_attribute(no_sanitize)
 #    define MOZ_HAVE_NO_SANITIZE_ATTR
 #  endif
 #endif
 
+#ifdef __clang__
+#  ifdef MOZ_HAVE_NO_SANITIZE_ATTR
+#    define MOZ_HAVE_UNSIGNED_OVERFLOW_SANITIZE_ATTR
+#    define MOZ_HAVE_SIGNED_OVERFLOW_SANITIZE_ATTR
+#  endif
+#endif
+
 /*
  * MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW disables *un*signed integer overflow
  * checking on the function it annotates, in builds configured to perform it.
  * (Currently this is only Clang using -fsanitize=unsigned-integer-overflow, or
  * via --enable-unsigned-overflow-sanitizer in Mozilla's build system.)  It has
  * no effect in other builds.
  *
  * Place this attribute at the very beginning of a function declaration.
@@ -266,17 +273,17 @@
  * The compiler instrumentation to detect unsigned integer overflow has costs
  * both at compile time and at runtime.  Functions that are repeatedly inlined
  * at compile time will also implicitly inline the necessary instrumentation,
  * increasing compile time.  Similarly, frequently-executed functions that
  * require large amounts of instrumentation will also notice significant runtime
  * slowdown to execute that instrumentation.  Use this attribute to eliminate
  * those costs -- but only after carefully verifying that no overflow can occur.
  */
-#if defined(MOZ_HAVE_NO_SANITIZE_ATTR)
+#ifdef MOZ_HAVE_UNSIGNED_OVERFLOW_SANITIZE_ATTR
 #  define MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow")))
 #else
 #  define MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW /* nothing */
 #endif
 
 /*
  * MOZ_NO_SANITIZE_SIGNED_OVERFLOW disables *signed* integer overflow checking
  * on the function it annotates, in builds configured to perform it.  (Currently
@@ -294,17 +301,17 @@
  * The compiler instrumentation to detect signed integer overflow has costs both
  * at compile time and at runtime.  Functions that are repeatedly inlined at
  * compile time will also implicitly inline the necessary instrumentation,
  * increasing compile time.  Similarly, frequently-executed functions that
  * require large amounts of instrumentation will also notice significant runtime
  * slowdown to execute that instrumentation.  Use this attribute to eliminate
  * those costs -- but only after carefully verifying that no overflow can occur.
  */
-#if defined(MOZ_HAVE_NO_SANITIZE_ATTR)
+#ifdef MOZ_HAVE_SIGNED_OVERFLOW_SANITIZE_ATTR
 #  define MOZ_NO_SANITIZE_SIGNED_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow")))
 #else
 #  define MOZ_NO_SANITIZE_SIGNED_OVERFLOW /* nothing */
 #endif
 
 #undef MOZ_HAVE_NO_SANITIZE_ATTR