mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 23:38:17 +00:00
Merge pull request #6735 from justinmk/funcattr
clang 3.6+ REAL_FATTR_NONNULL_RET
This commit is contained in:
@@ -41,6 +41,8 @@
|
|||||||
// $ gcc -E -dM - </dev/null
|
// $ gcc -E -dM - </dev/null
|
||||||
// $ echo | clang -dM -E -
|
// $ echo | clang -dM -E -
|
||||||
|
|
||||||
|
#include "nvim/macros.h"
|
||||||
|
|
||||||
#ifdef FUNC_ATTR_MALLOC
|
#ifdef FUNC_ATTR_MALLOC
|
||||||
# undef FUNC_ATTR_MALLOC
|
# undef FUNC_ATTR_MALLOC
|
||||||
#endif
|
#endif
|
||||||
@@ -96,8 +98,7 @@
|
|||||||
#ifndef DID_REAL_ATTR
|
#ifndef DID_REAL_ATTR
|
||||||
# define DID_REAL_ATTR
|
# define DID_REAL_ATTR
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
// place defines for all gnulikes here, for now that's gcc, clang and
|
// For all gnulikes: gcc, clang, intel.
|
||||||
// intel.
|
|
||||||
|
|
||||||
// place these after the argument list of the function declaration
|
// place these after the argument list of the function declaration
|
||||||
// (not definition), like so:
|
// (not definition), like so:
|
||||||
@@ -113,26 +114,17 @@
|
|||||||
# define REAL_FATTR_NONNULL_ARG(...) __attribute__((nonnull(__VA_ARGS__)))
|
# define REAL_FATTR_NONNULL_ARG(...) __attribute__((nonnull(__VA_ARGS__)))
|
||||||
# define REAL_FATTR_NORETURN __attribute__((noreturn))
|
# define REAL_FATTR_NORETURN __attribute__((noreturn))
|
||||||
|
|
||||||
# ifdef __clang__
|
# if NVIM_HAS_ATTRIBUTE(returns_nonnull)
|
||||||
// clang only
|
# define REAL_FATTR_NONNULL_RET __attribute__((returns_nonnull))
|
||||||
# elif defined(__INTEL_COMPILER)
|
# endif
|
||||||
// intel only
|
|
||||||
# else
|
# if NVIM_HAS_ATTRIBUTE(alloc_size)
|
||||||
# define GCC_VERSION \
|
|
||||||
(__GNUC__ * 10000 + \
|
|
||||||
__GNUC_MINOR__ * 100 + \
|
|
||||||
__GNUC_PATCHLEVEL__)
|
|
||||||
// gcc only
|
|
||||||
# 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)))
|
||||||
# if GCC_VERSION >= 40900
|
|
||||||
# define REAL_FATTR_NONNULL_RET __attribute__((returns_nonnull))
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// define function attributes that haven't been defined for this specific
|
// Define attributes that are not defined for this compiler.
|
||||||
// compiler.
|
|
||||||
|
|
||||||
# ifndef REAL_FATTR_MALLOC
|
# ifndef REAL_FATTR_MALLOC
|
||||||
# define REAL_FATTR_MALLOC
|
# define REAL_FATTR_MALLOC
|
||||||
|
@@ -435,7 +435,7 @@ bool add_pathsep(char *p)
|
|||||||
/// @return [allocated] Copy of absolute path to `fname` or NULL when
|
/// @return [allocated] Copy of absolute path to `fname` or NULL when
|
||||||
/// `fname` is NULL.
|
/// `fname` is NULL.
|
||||||
char *FullName_save(const char *fname, bool force)
|
char *FullName_save(const char *fname, bool force)
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC
|
FUNC_ATTR_MALLOC
|
||||||
{
|
{
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -453,7 +453,7 @@ char *FullName_save(const char *fname, bool force)
|
|||||||
/// @param name An absolute or relative path.
|
/// @param name An absolute or relative path.
|
||||||
/// @return The absolute path of `name`.
|
/// @return The absolute path of `name`.
|
||||||
char_u *save_absolute_path(const char_u *name)
|
char_u *save_absolute_path(const char_u *name)
|
||||||
FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (!path_is_absolute_path(name)) {
|
if (!path_is_absolute_path(name)) {
|
||||||
return (char_u *)FullName_save((char *)name, true);
|
return (char_u *)FullName_save((char *)name, true);
|
||||||
|
Reference in New Issue
Block a user