build: don't define FUNC_ATTR_* as empty in headers (#26317)

FUNC_ATTR_* should only be used in .c files with generated headers.
Defining FUNC_ATTR_* as empty in headers causes misuses of them to be
silently ignored. Instead don't define them by default, and only define
them as empty after a .c file has included its generated header.
This commit is contained in:
zeertzjq 2023-11-30 15:51:05 +08:00 committed by GitHub
parent 85be914879
commit 543e0256c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
136 changed files with 142 additions and 186 deletions

View File

@ -190,7 +190,7 @@ Function declarations ~
Every function must not have a separate declaration.
Function declarations are created by the gendeclarations.lua script. >c
Function declarations are created by the gen_declarations.lua script. >c
static void f(void);

View File

@ -160,10 +160,12 @@
(v).size = 0, \
(v).items = (v).init_array)
static inline void *_memcpy_free(void *restrict dest, void *restrict src, size_t size)
REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET REAL_FATTR_ALWAYS_INLINE;
/// Move data to a new destination and free source
static inline void *_memcpy_free(void *const restrict dest, void *const restrict src,
const size_t size)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET FUNC_ATTR_ALWAYS_INLINE
{
memcpy(dest, src, size);
XFREE_CLEAR(src);

View File

@ -463,7 +463,7 @@ endif()
#-------------------------------------------------------------------------------
get_target_property(prop main_lib INTERFACE_COMPILE_DEFINITIONS)
foreach(gen_cdef DO_NOT_DEFINE_EMPTY_ATTRIBUTES ${prop})
foreach(gen_cdef ${prop})
if(NOT ${gen_cdef} MATCHES "INCLUDE_GENERATED_DECLARATIONS")
list(APPEND gen_cflags "-D${gen_cdef}")
endif()

View File

@ -17,7 +17,6 @@
#include "nvim/buffer.h"
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
#include "nvim/memory.h"

View File

@ -24,7 +24,6 @@
#include "nvim/drawscreen.h"
#include "nvim/ex_cmds.h"
#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
#include "nvim/mapping.h"

View File

@ -18,7 +18,6 @@
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/globals.h"
#include "nvim/lua/executor.h"

View File

@ -14,7 +14,6 @@
#include "nvim/buffer_defs.h"
#include "nvim/decoration.h"
#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"

View File

@ -17,7 +17,6 @@
#include "nvim/decoration_provider.h"
#include "nvim/drawscreen.h"
#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/grid.h"
#include "nvim/highlight_group.h"
#include "nvim/marktree.h"

View File

@ -11,7 +11,6 @@
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/eval/window.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/macros_defs.h"
#include "nvim/memory.h"

View File

@ -11,7 +11,6 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/func_attr.h"
#include "nvim/lua/executor.h"
#include "nvim/memory.h"
#include "nvim/types_defs.h"

View File

@ -20,7 +20,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_eval.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/globals.h"
#include "nvim/highlight_group.h"

View File

@ -6,11 +6,14 @@
#include "nvim/api/tabpage.h"
#include "nvim/api/vim.h"
#include "nvim/buffer_defs.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/memory.h"
#include "nvim/window.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/tabpage.c.generated.h"
#endif
/// Gets the windows in a tabpage
///
/// @param tabpage Tabpage handle, or 0 for current tabpage

View File

@ -17,7 +17,6 @@
#include "nvim/eval.h"
#include "nvim/event/loop.h"
#include "nvim/event/wstream.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"

View File

@ -31,7 +31,6 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
#include "nvim/grid.h"

View File

@ -15,7 +15,6 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_docmd.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/globals.h"
#include "nvim/memory.h"

View File

@ -13,7 +13,6 @@
#include "nvim/buffer_defs.h"
#include "nvim/decoration.h"
#include "nvim/drawscreen.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight_group.h"

View File

@ -15,7 +15,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval/window.h"
#include "nvim/ex_docmd.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
@ -27,6 +26,10 @@
#include "nvim/types_defs.h"
#include "nvim/window.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/window.c.generated.h"
#endif
/// Gets the current buffer in a window
///
/// @param window Window handle, or 0 for current window

View File

@ -22,7 +22,6 @@
#include "nvim/arabic.h"
#include "nvim/ascii_defs.h"
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
#include "nvim/option_vars.h"

View File

@ -20,7 +20,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -107,6 +107,10 @@ static inline bool ascii_isbdigit(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;
static inline bool ascii_isodigit(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;
static inline bool ascii_isspace(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;

View File

@ -23,7 +23,6 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#include <string.h>
#include "auto/config.h" // IWYU pragma: keep
#include "auto/config.h"
#include "nvim/base64.h"
#include "nvim/memory.h"
@ -12,7 +12,7 @@
#endif
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "base64.c.generated.h" // IWYU pragma: export
# include "base64.c.generated.h"
#endif
static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@ -65,6 +65,7 @@ static inline uint32_t htobe32(uint32_t host_32bits)
/// @param src_len Length of the string
/// @return Base64 encoded string
char *base64_encode(const char *src, size_t src_len)
FUNC_ATTR_NONNULL_ALL
{
assert(src != NULL);

View File

@ -11,7 +11,6 @@
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
#include "nvim/buffer_updates.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/lua/executor.h"
@ -22,7 +21,7 @@
#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "buffer_updates.c.generated.h" // IWYU pragma: export
# include "buffer_updates.c.generated.h"
#endif
// Register a channel. Return True if the channel was added, or already added.

View File

@ -23,7 +23,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_eval.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"

View File

@ -21,7 +21,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/extmark.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"

View File

@ -122,7 +122,9 @@ static inline Channel *find_channel(uint64_t id)
}
static inline Stream *channel_instream(Channel *chan)
FUNC_ATTR_NONNULL_ALL
REAL_FATTR_NONNULL_ALL;
static inline Stream *channel_instream(Channel *chan)
{
switch (chan->streamtype) {
case kChannelStreamProc:
@ -142,7 +144,9 @@ static inline Stream *channel_instream(Channel *chan)
}
static inline Stream *channel_outstream(Channel *chan)
FUNC_ATTR_NONNULL_ALL
REAL_FATTR_NONNULL_ALL;
static inline Stream *channel_outstream(Channel *chan)
{
switch (chan->streamtype) {
case kChannelStreamProc:

View File

@ -26,7 +26,6 @@
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/garray_defs.h"
#include "nvim/getchar.h"

View File

@ -15,7 +15,6 @@
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/macros_defs.h"

View File

@ -16,7 +16,6 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_docmd.h"
#include "nvim/func_attr.h"
#include "nvim/hashtab.h"
#include "nvim/keycodes.h"
#include "nvim/memory.h"

View File

@ -8,7 +8,6 @@
#include "nvim/charset.h"
#include "nvim/cursor_shape.h"
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/highlight_group.h"

View File

@ -18,7 +18,6 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -32,7 +32,6 @@
#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -17,7 +17,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -76,7 +76,6 @@
#include "nvim/eval.h"
#include "nvim/ex_getln.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -24,7 +24,6 @@
#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -36,7 +36,6 @@
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/ex_session.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -14,7 +14,6 @@
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/macros_defs.h"
#include "nvim/memline.h"

View File

@ -14,7 +14,6 @@
#include "nvim/eval/encode.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/macros_defs.h"

View File

@ -36,9 +36,11 @@ typedef struct {
size_t li_length; ///< Length of the string inside the read item.
} ListReaderState;
static inline ListReaderState encode_init_lrstate(const list_T *list)
REAL_FATTR_NONNULL_ALL;
/// Initialize ListReaderState structure
static inline ListReaderState encode_init_lrstate(const list_T *const list)
FUNC_ATTR_NONNULL_ALL
{
return (ListReaderState) {
.list = list,

View File

@ -5,7 +5,6 @@
#include "nvim/eval/executor.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
@ -15,7 +14,7 @@
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "eval/executor.c.generated.h" // IWYU pragma: export
# include "eval/executor.c.generated.h"
#endif
char *e_list_index_out_of_range_nr

View File

@ -58,7 +58,6 @@
#include "nvim/ex_getln.h"
#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -85,6 +85,9 @@ static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
l->lv_lock = lock;
}
static inline void tv_list_set_copyid(list_T *l, int copyid)
REAL_FATTR_NONNULL_ALL;
/// Set list copyID
///
/// Does not expect NULL list, be careful.
@ -92,7 +95,6 @@ static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
/// @param[out] l List to modify.
/// @param[in] copyid New copyID.
static inline void tv_list_set_copyid(list_T *const l, const int copyid)
FUNC_ATTR_NONNULL_ALL
{
l->lv_copyID = copyid;
}
@ -442,22 +444,20 @@ static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret
}
static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q)
REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET REAL_FATTR_PURE
REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
FUNC_ATTR_NO_SANITIZE_ADDRESS;
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET
REAL_FATTR_NO_SANITIZE_ADDRESS REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
/// Compute the `DictWatcher` address from a QUEUE node.
///
/// This only exists for .asan-blacklist (ASAN doesn't handle QUEUE_DATA pointer
/// arithmetic).
static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q)
FUNC_ATTR_NO_SANITIZE_ADDRESS
{
return QUEUE_DATA(q, DictWatcher, node);
}
static inline bool tv_is_func(typval_T tv)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST;
REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST;
/// Check whether given typval_T contains a function
///

View File

@ -23,7 +23,6 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -25,7 +25,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -7,7 +7,6 @@
#include "nvim/event/libuv_process.h"
#include "nvim/event/process.h"
#include "nvim/event/stream.h"
#include "nvim/func_attr.h"
#include "nvim/log.h"
#include "nvim/os/os.h"
#include "nvim/ui_client.h"

View File

@ -48,7 +48,6 @@
#include "nvim/event/defs.h"
#include "nvim/event/multiqueue.h"
#include "nvim/func_attr.h"
#include "nvim/lib/queue.h"
#include "nvim/memory.h"

View File

@ -7,7 +7,6 @@
#include "nvim/event/libuv_process.h"
#include "nvim/event/loop.h"
#include "nvim/event/process.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/main.h"

View File

@ -8,7 +8,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/rstream.h"
#include "nvim/event/stream.h"
#include "nvim/func_attr.h"
#include "nvim/log.h"
#include "nvim/macros_defs.h"
#include "nvim/main.h"

View File

@ -3,7 +3,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/signal.h"
#include "nvim/func_attr.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/signal.c.generated.h"

View File

@ -10,7 +10,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/socket.h"
#include "nvim/event/stream.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/log.h"
#include "nvim/main.h"

View File

@ -6,7 +6,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/stream.h"
#include "nvim/func_attr.h"
#include "nvim/log.h"
#include "nvim/rbuffer.h"
#ifdef MSWIN

View File

@ -3,7 +3,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/time.h"
#include "nvim/func_attr.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/time.c.generated.h"

View File

@ -5,7 +5,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/stream.h"
#include "nvim/event/wstream.h"
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
#include "nvim/memory.h"

View File

@ -43,7 +43,6 @@
#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -39,7 +39,6 @@
#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -18,7 +18,6 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_eval_defs.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/memory.h"

View File

@ -34,7 +34,6 @@
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -20,7 +20,6 @@
#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -31,7 +31,6 @@
#include "nvim/ex_eval.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/garray_defs.h"
#include "nvim/getchar.h"

View File

@ -27,7 +27,6 @@
#include "nvim/ex_session.h"
#include "nvim/extmark.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/garray_defs.h"
#include "nvim/gettext.h"

View File

@ -1,24 +1,16 @@
// If DEFINE_FUNC_ATTRIBUTES macro is not defined then all function attributes
// are defined as empty values.
//
// If DO_NOT_DEFINE_EMPTY_ATTRIBUTES then empty macros are not defined. Thus
// undefined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES
// Undefined DEFINE_FUNC_ATTRIBUTES and undefined DEFINE_EMPTY_ATTRIBUTES
// leaves file with untouched FUNC_ATTR_* macros. This variant is used for
// scripts/gendeclarations.lua.
// scripts/gen_declarations.lua.
//
// Empty macros are used for *.c files. (undefined DEFINE_FUNC_ATTRIBUTES and
// undefined DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
// Empty macros are used for *.c files.
// (undefined DEFINE_FUNC_ATTRIBUTES and defined DEFINE_EMPTY_ATTRIBUTES)
//
// Macros defined as __attribute__((*)) are used by generated header files.
// (defined DEFINE_FUNC_ATTRIBUTES and undefined
// DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
//
// Defined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES is
// not used by anything.
// (defined DEFINE_FUNC_ATTRIBUTES and undefined DEFINE_EMPTY_ATTRIBUTES)
// FUNC_ATTR_* macros should be in *.c files for declarations generator. If you
// define a function for which declaration is not generated by
// gendeclarations.lua (e.g. template hash implementation) then you should use
// gen_declarations.lua (e.g. template hash implementation) then you should use
// REAL_FATTR_* macros.
// gcc and clang expose their version as follows:
@ -217,7 +209,7 @@
# endif
#endif
#ifdef DEFINE_FUNC_ATTRIBUTES
#if defined(DEFINE_FUNC_ATTRIBUTES) || defined(DEFINE_EMPTY_ATTRIBUTES)
/// Fast (non-deferred) API function.
# define FUNC_API_FAST
/// Internal C function not exposed in the RPC API.
@ -234,6 +226,9 @@
# define FUNC_API_SINCE(X)
/// API function deprecated since the given API level.
# define FUNC_API_DEPRECATED_SINCE(X)
#endif
#if defined(DEFINE_FUNC_ATTRIBUTES)
# define FUNC_ATTR_MALLOC REAL_FATTR_MALLOC
# define FUNC_ATTR_ALLOC_SIZE(x) REAL_FATTR_ALLOC_SIZE(x)
# define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) REAL_FATTR_ALLOC_SIZE_PROD(x, y)
@ -250,7 +245,7 @@
# define FUNC_ATTR_NO_SANITIZE_UNDEFINED REAL_FATTR_NO_SANITIZE_UNDEFINED
# define FUNC_ATTR_NO_SANITIZE_ADDRESS REAL_FATTR_NO_SANITIZE_ADDRESS
# define FUNC_ATTR_PRINTF(x, y) REAL_FATTR_PRINTF(x, y)
#elif !defined(DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
#elif defined(DEFINE_EMPTY_ATTRIBUTES)
# define FUNC_ATTR_MALLOC
# define FUNC_ATTR_ALLOC_SIZE(x)
# define FUNC_ATTR_ALLOC_SIZE_PROD(x, y)

View File

@ -5,7 +5,6 @@
#include <stdint.h>
#include <string.h>
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/log.h"
#include "nvim/memory.h"
@ -13,7 +12,7 @@
#include "nvim/strings.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "garray.c.generated.h" // IWYU pragma: export
# include "garray.c.generated.h"
#endif
/// Clear an allocated growing array.

View File

@ -752,9 +752,9 @@ for _, fn in ipairs(functions) do
end
output:write(string.format([[
void nlua_add_api_functions(lua_State *lstate); // silence -Wmissing-prototypes
void nlua_add_api_functions(lua_State *lstate)
FUNC_ATTR_NONNULL_ALL
REAL_FATTR_NONNULL_ALL;
void nlua_add_api_functions(lua_State *lstate)
{
lua_createtable(lstate, 0, %u);
]], #lua_c_functions))

View File

@ -164,7 +164,7 @@ if fname == '--help' then
print([[
Usage:
gendeclarations.lua definitions.c static.h non-static.h definitions.i
gen_declarations.lua definitions.c static.h non-static.h definitions.i
Generates declarations for a C file definitions.c, putting declarations for
static functions into static.h and declarations for non-static functions into
@ -202,17 +202,10 @@ local text = preproc_f:read("*all")
preproc_f:close()
local header = [[
local non_static = [[
#define DEFINE_FUNC_ATTRIBUTES
#include "nvim/func_attr.h"
#undef DEFINE_FUNC_ATTRIBUTES
]]
local footer = [[
#include "nvim/func_attr.h"
]]
local non_static = header .. [[
#ifndef DLLEXPORT
# ifdef MSWIN
# define DLLEXPORT __declspec(dllexport)
@ -222,7 +215,20 @@ local non_static = header .. [[
#endif
]]
local static = header
local static = [[
#define DEFINE_FUNC_ATTRIBUTES
#include "nvim/func_attr.h"
#undef DEFINE_FUNC_ATTRIBUTES
]]
local non_static_footer = [[
#include "nvim/func_attr.h"
]]
local static_footer = [[
#define DEFINE_EMPTY_ATTRIBUTES
#include "nvim/func_attr.h" // IWYU pragma: export
]]
if fname:find('.*/src/nvim/.*%.c$') then
-- Add an IWYU pragma comment if the corresponding .h file exists.
@ -307,8 +313,8 @@ while init ~= nil do
end
end
non_static = non_static .. footer
static = static .. footer
non_static = non_static .. non_static_footer
static = static .. static_footer
local F
F = io.open(static_fname, 'w')

View File

@ -26,7 +26,6 @@
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -24,7 +24,6 @@
#include <string.h>
#include "nvim/ascii_defs.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/hashtab.h"
#include "nvim/memory.h"

View File

@ -16,7 +16,6 @@
#include "nvim/ex_docmd.h"
#include "nvim/extmark_defs.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -24,7 +24,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_docmd.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -17,7 +17,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/indent.h"

View File

@ -9,7 +9,6 @@
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"

View File

@ -24,7 +24,6 @@
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -10,7 +10,6 @@
#include "nvim/charset.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/keycodes.h"

View File

@ -44,22 +44,29 @@ typedef struct _queue {
}
// ffi.cdef is unable to swallow `bool` in place of `int` here.
static inline int QUEUE_EMPTY(const QUEUE *q)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
static inline int QUEUE_EMPTY(const QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return q == q->next;
}
#define QUEUE_HEAD(q) (q)->next
static inline void QUEUE_INIT(QUEUE *const q) FUNC_ATTR_ALWAYS_INLINE
static inline void QUEUE_INIT(QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_INIT(QUEUE *const q)
{
q->next = q;
q->prev = q;
}
static inline void QUEUE_ADD(QUEUE *h, QUEUE *n)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
FUNC_ATTR_ALWAYS_INLINE
{
h->prev->next = n->next;
n->next->prev = h->prev;
@ -67,8 +74,10 @@ static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
h->prev->next = h;
}
static inline void QUEUE_INSERT_HEAD(QUEUE *h, QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{
q->next = h->next;
q->prev = h;
@ -76,8 +85,10 @@ static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
h->next = q;
}
static inline void QUEUE_INSERT_TAIL(QUEUE *h, QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{
q->next = h;
q->prev = h->prev;
@ -85,7 +96,10 @@ static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q)
h->prev = q;
}
static inline void QUEUE_REMOVE(QUEUE *const q) FUNC_ATTR_ALWAYS_INLINE
static inline void QUEUE_REMOVE(QUEUE *q)
REAL_FATTR_ALWAYS_INLINE;
static inline void QUEUE_REMOVE(QUEUE *const q)
{
q->prev->next = q->next;
q->next->prev = q->prev;

View File

@ -19,7 +19,6 @@
#include "auto/config.h"
#include "nvim/ascii_defs.h"
#include "nvim/eval.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/memory.h"

View File

@ -16,7 +16,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/typval_encode.h"
#include "nvim/eval/userfunc.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/lua/converter.h"
#include "nvim/lua/executor.h"

View File

@ -22,7 +22,6 @@
#include "nvim/eval/vars.h"
#include "nvim/ex_eval.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/lua/base64.h"
#include "nvim/lua/converter.h"

View File

@ -44,7 +44,6 @@
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -24,7 +24,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_session.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -50,9 +50,11 @@
SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_, view_); \
} while (0)
static inline int mark_global_index(char name)
REAL_FATTR_CONST;
/// Convert mark name to the offset
static inline int mark_global_index(const char name)
FUNC_ATTR_CONST
{
return (ASCII_ISUPPER(name)
? (name - 'A')
@ -61,9 +63,11 @@ static inline int mark_global_index(const char name)
: -1));
}
static inline int mark_local_index(char name)
REAL_FATTR_CONST;
/// Convert local mark name to the offset
static inline int mark_local_index(const char name)
FUNC_ATTR_CONST
{
return (ASCII_ISLOWER(name)
? (name - 'a')

View File

@ -16,7 +16,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"

View File

@ -7,10 +7,11 @@
#include "nvim/math.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "math.c.generated.h" // IWYU pragma: export
# include "math.c.generated.h"
#endif
int xfpclassify(double d)
FUNC_ATTR_CONST
{
uint64_t m;
@ -29,11 +30,13 @@ int xfpclassify(double d)
}
int xisinf(double d)
FUNC_ATTR_CONST
{
return FP_INFINITE == xfpclassify(d);
}
int xisnan(double d)
FUNC_ATTR_CONST
{
return FP_NAN == xfpclassify(d);
}

View File

@ -56,7 +56,6 @@
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -16,7 +16,6 @@
#include "nvim/decoration_provider.h"
#include "nvim/drawline.h"
#include "nvim/eval.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"

View File

@ -15,7 +15,6 @@
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -24,7 +24,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_eval.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"

View File

@ -15,7 +15,6 @@
#include "nvim/eval/typval.h"
#include "nvim/ex_docmd.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
#include "nvim/grid.h"

View File

@ -22,7 +22,6 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/window.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -20,7 +20,6 @@
#include "nvim/event/rstream.h"
#include "nvim/event/stream.h"
#include "nvim/event/wstream.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/main.h"

View File

@ -10,7 +10,6 @@
#include "msgpack/pack.h"
#include "nvim/api/private/helpers.h"
#include "nvim/assert_defs.h"
#include "nvim/func_attr.h"
#include "nvim/memory.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/types_defs.h"

View File

@ -7,7 +7,6 @@
#include "nvim/channel.h"
#include "nvim/eval.h"
#include "nvim/event/socket.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/log.h"
#include "nvim/main.h"

View File

@ -34,7 +34,6 @@
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -102,13 +102,15 @@ typedef enum {
YREG_PUT,
} yreg_mode_t;
static inline int op_reg_index(int regname)
REAL_FATTR_CONST;
/// Convert register name into register index
///
/// @param[in] regname Register name.
///
/// @return Index in y_regs array or -1 if register name was not recognized.
static inline int op_reg_index(const int regname)
FUNC_ATTR_CONST
{
if (ascii_isdigit(regname)) {
return regname - '0';
@ -127,11 +129,13 @@ static inline int op_reg_index(const int regname)
}
}
static inline bool is_literal_register(int regname)
REAL_FATTR_CONST;
/// @see get_yank_register
/// @return true when register should be inserted literally
/// (selection or clipboard)
static inline bool is_literal_register(const int regname)
FUNC_ATTR_CONST
{
return regname == '*' || regname == '+';
}

View File

@ -49,7 +49,6 @@
#include "nvim/ex_getln.h"
#include "nvim/ex_session.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -19,7 +19,6 @@
#include "nvim/eval/vars.h"
#include "nvim/ex_getln.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/highlight_group.h"

View File

@ -14,7 +14,6 @@
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/eval.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/log.h"
@ -46,6 +45,10 @@
# include <sys/utsname.h>
#endif
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/env.c.generated.h"
#endif
// Because `uv_os_getenv` requires allocating, we must manage a map to maintain
// the behavior of `os_getenv`.
static PMap(cstr_t) envmap = MAP_INIT;

View File

@ -17,7 +17,6 @@
#endif
#include "auto/config.h"
#include "nvim/func_attr.h"
#include "nvim/os/fs.h"
#if defined(HAVE_ACL)

View File

@ -12,7 +12,6 @@
#include "nvim/event/multiqueue.h"
#include "nvim/event/rstream.h"
#include "nvim/event/stream.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"

View File

@ -44,7 +44,7 @@
#endif
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/process.c.generated.h" // IWYU pragma: export
# include "os/process.c.generated.h"
#endif
#ifdef MSWIN
@ -114,6 +114,7 @@ bool os_proc_tree_kill(int pid, int sig)
/// @param[out] proc_count Number of child processes.
/// @return 0 on success, 1 if process not found, 2 on other error.
int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
FUNC_ATTR_NONNULL_ALL
{
if (ppid < 0) {
return 2;

View File

@ -35,7 +35,6 @@
#include "nvim/event/loop.h"
#include "nvim/event/process.h"
#include "nvim/event/stream.h"
#include "nvim/func_attr.h"
#include "nvim/log.h"
#include "nvim/os/fs.h"
#include "nvim/os/os_defs.h"

View File

@ -20,7 +20,6 @@
#include "nvim/event/wstream.h"
#include "nvim/ex_cmds.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/macros_defs.h"

Some files were not shown because too many files have changed in this diff Show More