func_attr: Allow disabling UBSAN for a function

This commit is contained in:
James McCoy
2017-05-06 21:26:44 -04:00
parent 43534cab02
commit fb2b3f98bb

View File

@@ -95,6 +95,10 @@
# undef FUNC_ATTR_NORETURN # undef FUNC_ATTR_NORETURN
#endif #endif
#ifdef FUNC_ATTR_NO_SANITIZE_UNDEFINED
# undef FUNC_ATTR_NO_SANITIZE_UNDEFINED
#endif
#ifndef DID_REAL_ATTR #ifndef DID_REAL_ATTR
# define DID_REAL_ATTR # define DID_REAL_ATTR
# ifdef __GNUC__ # ifdef __GNUC__
@@ -122,6 +126,12 @@
# define REAL_FATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) # define REAL_FATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
# define REAL_FATTR_ALLOC_SIZE_PROD(x, y) __attribute__((alloc_size(x, y))) # define REAL_FATTR_ALLOC_SIZE_PROD(x, y) __attribute__((alloc_size(x, y)))
# endif # 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 # endif
// Define attributes that are not defined for this compiler. // Define attributes that are not defined for this compiler.
@@ -177,6 +187,10 @@
# ifndef REAL_FATTR_NORETURN # ifndef REAL_FATTR_NORETURN
# define REAL_FATTR_NORETURN # define REAL_FATTR_NORETURN
# endif # endif
# ifndef REAL_FATTR_NO_SANITIZE_UNDEFINED
# define REAL_FATTR_NO_SANITIZE_UNDEFINED
# endif
#endif #endif
#ifdef DEFINE_FUNC_ATTRIBUTES #ifdef DEFINE_FUNC_ATTRIBUTES
@@ -198,6 +212,7 @@
# define FUNC_ATTR_NONNULL_ARG(...) REAL_FATTR_NONNULL_ARG(__VA_ARGS__) # define FUNC_ATTR_NONNULL_ARG(...) REAL_FATTR_NONNULL_ARG(__VA_ARGS__)
# define FUNC_ATTR_NONNULL_RET REAL_FATTR_NONNULL_RET # define FUNC_ATTR_NONNULL_RET REAL_FATTR_NONNULL_RET
# define FUNC_ATTR_NORETURN REAL_FATTR_NORETURN # 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) #elif !defined(DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
# define FUNC_ATTR_MALLOC # define FUNC_ATTR_MALLOC
# define FUNC_ATTR_ALLOC_SIZE(x) # define FUNC_ATTR_ALLOC_SIZE(x)
@@ -212,4 +227,5 @@
# define FUNC_ATTR_NONNULL_ARG(...) # define FUNC_ATTR_NONNULL_ARG(...)
# define FUNC_ATTR_NONNULL_RET # define FUNC_ATTR_NONNULL_RET
# define FUNC_ATTR_NORETURN # define FUNC_ATTR_NORETURN
# define FUNC_ATTR_NO_SANITIZE_UNDEFINED
#endif #endif