aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2017-05-06 21:26:44 -0400
committerJames McCoy <jamessan@jamessan.com>2017-06-04 22:12:15 -0400
commitfb2b3f98bbb90c8cebe0d272cb94c4d49789df21 (patch)
tree58fe56eb8666901fc4bcf95ff079eb481bdc9106 /src
parent43534cab025fa57109c832f13fb567da2299e707 (diff)
downloadrneovim-fb2b3f98bbb90c8cebe0d272cb94c4d49789df21.tar.gz
rneovim-fb2b3f98bbb90c8cebe0d272cb94c4d49789df21.tar.bz2
rneovim-fb2b3f98bbb90c8cebe0d272cb94c4d49789df21.zip
func_attr: Allow disabling UBSAN for a function
Diffstat (limited to 'src')
-rw-r--r--src/nvim/func_attr.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h
index f1a1d9a563..d2d88924e5 100644
--- a/src/nvim/func_attr.h
+++ b/src/nvim/func_attr.h
@@ -95,6 +95,10 @@
# undef FUNC_ATTR_NORETURN
#endif
+#ifdef FUNC_ATTR_NO_SANITIZE_UNDEFINED
+# undef FUNC_ATTR_NO_SANITIZE_UNDEFINED
+#endif
+
#ifndef DID_REAL_ATTR
# define DID_REAL_ATTR
# ifdef __GNUC__
@@ -122,6 +126,12 @@
# define REAL_FATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
# define REAL_FATTR_ALLOC_SIZE_PROD(x, y) __attribute__((alloc_size(x, y)))
# endif
+
+# if NVIM_HAS_ATTRIBUTE(no_sanitize_undefined)
+# define REAL_FATTR_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
+# elif NVIM_HAS_ATTRIBUTE(no_sanitize)
+# define REAL_FATTR_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
+# endif
# endif
// Define attributes that are not defined for this compiler.
@@ -177,6 +187,10 @@
# ifndef REAL_FATTR_NORETURN
# define REAL_FATTR_NORETURN
# endif
+
+# ifndef REAL_FATTR_NO_SANITIZE_UNDEFINED
+# define REAL_FATTR_NO_SANITIZE_UNDEFINED
+# endif
#endif
#ifdef DEFINE_FUNC_ATTRIBUTES
@@ -198,6 +212,7 @@
# define FUNC_ATTR_NONNULL_ARG(...) REAL_FATTR_NONNULL_ARG(__VA_ARGS__)
# define FUNC_ATTR_NONNULL_RET REAL_FATTR_NONNULL_RET
# define FUNC_ATTR_NORETURN REAL_FATTR_NORETURN
+# define FUNC_ATTR_NO_SANITIZE_UNDEFINED REAL_FATTR_NO_SANITIZE_UNDEFINED
#elif !defined(DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
# define FUNC_ATTR_MALLOC
# define FUNC_ATTR_ALLOC_SIZE(x)
@@ -212,4 +227,5 @@
# define FUNC_ATTR_NONNULL_ARG(...)
# define FUNC_ATTR_NONNULL_RET
# define FUNC_ATTR_NORETURN
+# define FUNC_ATTR_NO_SANITIZE_UNDEFINED
#endif