neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 40139738eb479d0913ec6ce751ca5adfa50ad8c3
parent 5b765fcab42308cd4d97a4c37da0c2b1cdb3514d
Author: dundargoc <gocdundar@gmail.com>
Date:   Sun, 26 Nov 2023 21:36:02 +0100

build: enable IWYU on mac

Diffstat:
MMakefile | 2+-
Mcmake.config/iwyu/mapping.imp | 7+++----
Mcmake.config/iwyu/posix.imp | 117++++++++++++++-----------------------------------------------------------------
Msrc/nvim/CMakeLists.txt | 1+
Msrc/nvim/base64.c | 2+-
Msrc/nvim/buffer_defs.h | 2+-
Msrc/nvim/cmdexpand.c | 1+
Msrc/nvim/edit.c | 1+
Msrc/nvim/eval.c | 1+
Msrc/nvim/eval/typval.c | 1+
Msrc/nvim/event/rstream.c | 2+-
Msrc/nvim/ex_docmd.c | 1+
Msrc/nvim/fileio.c | 1+
Msrc/nvim/keycodes.c | 1+
Msrc/nvim/lua/stdlib.c | 2+-
Msrc/nvim/main.c | 21+++++++++++----------
Msrc/nvim/marktree.c | 1+
Msrc/nvim/mbyte.c | 1+
Msrc/nvim/memline.c | 1+
Msrc/nvim/message.c | 1+
Msrc/nvim/ops.c | 1+
Msrc/nvim/os/fileio.c | 4++++
Msrc/nvim/os/fs.c | 2--
Msrc/nvim/os/process.c | 12+++++++++---
Msrc/nvim/os/signal.c | 6+++++-
Msrc/nvim/os/time.c | 2--
Msrc/nvim/os/unix_defs.h | 17++++++++++-------
Msrc/nvim/ui_compositor.c | 2+-
Msrc/nvim/undo.c | 1+
29 files changed, 82 insertions(+), 132 deletions(-)

diff --git a/Makefile b/Makefile @@ -141,7 +141,7 @@ test: $(TEST) iwyu: build/.ran-cmake cmake --preset iwyu cmake --build build > build/iwyu.log - iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/\ + iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\ |src/nvim/api/autocmd.h\ |src/nvim/api/buffer.h\ |src/nvim/api/command.h\ diff --git a/cmake.config/iwyu/mapping.imp b/cmake.config/iwyu/mapping.imp @@ -17,12 +17,11 @@ # Symbols { symbol: [ "MAX", private, '"nvim/macros.h"', public ] }, { symbol: [ "MIN", private, '"nvim/macros.h"', public ] }, + { symbol: [ "extern_proc", private, '<uv.h>', public ] }, + { symbol: [ "iovec", private, '<sys/uio.h>', public ] }, # Third party headers - { include: [ '<netdb.h>', public, '"nvim/os/unix_defs.h"', private ] }, - { include: [ '<netinet/in.h>', public, '"nvim/os/unix_defs.h"', private ] }, - { include: [ '<pthread.h>', public, '"nvim/os/unix_defs.h"', private ] }, - { include: [ '<uv/unix.h>', public, '<uv.h>', public ] }, + { include: [ '<uv/unix.h>', private, '<uv.h>', public ] }, ] # vim: set ft=toml: diff --git a/cmake.config/iwyu/posix.imp b/cmake.config/iwyu/posix.imp @@ -1,110 +1,33 @@ [ - # bits/ioctls.h + { include: [ "<arm/limits.h>", private, "<limits.h>", public ] }, { include: [ "<asm/ioctls.h>", private, "<bits/ioctls.h>", private ] }, - - # errno.h - { symbol: ["E2BIG", private, "<errno.h>", public ] }, - { symbol: ["EACCES", private, "<errno.h>", public ] }, - { symbol: ["EADDRINUSE", private, "<errno.h>", public ] }, - { symbol: ["EADDRNOTAVAIL", private, "<errno.h>", public ] }, - { symbol: ["EAFNOSUPPORT", private, "<errno.h>", public ] }, - { symbol: ["EAGAIN", private, "<errno.h>", public ] }, - { symbol: ["EALREADY", private, "<errno.h>", public ] }, - { symbol: ["EBADF", private, "<errno.h>", public ] }, - { symbol: ["EBADMSG", private, "<errno.h>", public ] }, - { symbol: ["EBUSY", private, "<errno.h>", public ] }, - { symbol: ["ECANCELED", private, "<errno.h>", public ] }, - { symbol: ["ECHILD", private, "<errno.h>", public ] }, - { symbol: ["ECONNABORTED", private, "<errno.h>", public ] }, - { symbol: ["ECONNREFUSED", private, "<errno.h>", public ] }, - { symbol: ["ECONNRESET", private, "<errno.h>", public ] }, - { symbol: ["EDEADLK", private, "<errno.h>", public ] }, - { symbol: ["EDESTADDRREQ", private, "<errno.h>", public ] }, - { symbol: ["EDOM", private, "<errno.h>", public ] }, - { symbol: ["EDQUOT", private, "<errno.h>", public ] }, - { symbol: ["EEXIST", private, "<errno.h>", public ] }, - { symbol: ["EFAULT", private, "<errno.h>", public ] }, - { symbol: ["EFBIG", private, "<errno.h>", public ] }, - { symbol: ["EHOSTUNREACH", private, "<errno.h>", public ] }, - { symbol: ["EIDRM", private, "<errno.h>", public ] }, - { symbol: ["EILSEQ", private, "<errno.h>", public ] }, - { symbol: ["EINPROGRESS", private, "<errno.h>", public ] }, - { symbol: ["EINTR", private, "<errno.h>", public ] }, - { symbol: ["EINVAL", private, "<errno.h>", public ] }, - { symbol: ["EIO", private, "<errno.h>", public ] }, - { symbol: ["EISCONN", private, "<errno.h>", public ] }, - { symbol: ["EISDIR", private, "<errno.h>", public ] }, - { symbol: ["ELOOP", private, "<errno.h>", public ] }, - { symbol: ["EMFILE", private, "<errno.h>", public ] }, - { symbol: ["EMLINK", private, "<errno.h>", public ] }, - { symbol: ["EMSGSIZE", private, "<errno.h>", public ] }, - { symbol: ["EMULTIHOP", private, "<errno.h>", public ] }, - { symbol: ["ENAMETOOLONG", private, "<errno.h>", public ] }, - { symbol: ["ENETDOWN", private, "<errno.h>", public ] }, - { symbol: ["ENETRESET", private, "<errno.h>", public ] }, - { symbol: ["ENETUNREACH", private, "<errno.h>", public ] }, - { symbol: ["ENFILE", private, "<errno.h>", public ] }, - { symbol: ["ENOBUFS", private, "<errno.h>", public ] }, - { symbol: ["ENODATA", private, "<errno.h>", public ] }, - { symbol: ["ENODEV", private, "<errno.h>", public ] }, - { symbol: ["ENOENT", private, "<errno.h>", public ] }, - { symbol: ["ENOEXEC", private, "<errno.h>", public ] }, - { symbol: ["ENOLCK", private, "<errno.h>", public ] }, - { symbol: ["ENOLINK", private, "<errno.h>", public ] }, - { symbol: ["ENOMEM", private, "<errno.h>", public ] }, - { symbol: ["ENOMSG", private, "<errno.h>", public ] }, - { symbol: ["ENOPROTOOPT", private, "<errno.h>", public ] }, - { symbol: ["ENOSPC", private, "<errno.h>", public ] }, - { symbol: ["ENOSR", private, "<errno.h>", public ] }, - { symbol: ["ENOSTR", private, "<errno.h>", public ] }, - { symbol: ["ENOSYS", private, "<errno.h>", public ] }, - { symbol: ["ENOTCONN", private, "<errno.h>", public ] }, - { symbol: ["ENOTDIR", private, "<errno.h>", public ] }, - { symbol: ["ENOTEMPTY", private, "<errno.h>", public ] }, - { symbol: ["ENOTRECOVERABLE", private, "<errno.h>", public ] }, - { symbol: ["ENOTSOCK", private, "<errno.h>", public ] }, - { symbol: ["ENOTSUP", private, "<errno.h>", public ] }, - { symbol: ["ENOTTY", private, "<errno.h>", public ] }, - { symbol: ["ENXIO", private, "<errno.h>", public ] }, - { symbol: ["EOPNOTSUPP", private, "<errno.h>", public ] }, - { symbol: ["EOVERFLOW", private, "<errno.h>", public ] }, - { symbol: ["EOWNERDEAD", private, "<errno.h>", public ] }, - { symbol: ["EPERM", private, "<errno.h>", public ] }, - { symbol: ["EPIPE", private, "<errno.h>", public ] }, - { symbol: ["EPROTO", private, "<errno.h>", public ] }, - { symbol: ["EPROTONOSUPPORT", private, "<errno.h>", public ] }, - { symbol: ["EPROTOTYPE", private, "<errno.h>", public ] }, - { symbol: ["ERANGE", private, "<errno.h>", public ] }, - { symbol: ["EROFS", private, "<errno.h>", public ] }, - { symbol: ["ESPIPE", private, "<errno.h>", public ] }, - { symbol: ["ESRCH", private, "<errno.h>", public ] }, - { symbol: ["ESTALE", private, "<errno.h>", public ] }, - { symbol: ["ETIME", private, "<errno.h>", public ] }, - { symbol: ["ETIMEDOUT", private, "<errno.h>", public ] }, - { symbol: ["ETXTBSY", private, "<errno.h>", public ] }, - { symbol: ["EWOULDBLOCK", private, "<errno.h>", public ] }, - { symbol: ["EXDEV", private, "<errno.h>", public ] }, - - # limits.h - { symbol: ["SSIZE_MAX", private, "<limits.h>", public ] }, - - # signal.h - { symbol: [ "sigset_t", private, "<signal.h>", public ] }, - - # sys/socket.h - { symbol: [ "iovec", private, "<sys/socket.h>", public ] }, - { symbol: ["SOCK_STREAM", private, "<sys/socket.h>", public ] }, - - # termios.h { include: [ "<bits/termios-c_lflag.h>", private, "<termios.h>", public ] }, { include: [ "<bits/termios-struct.h>", private, "<termios.h>", public ] }, + { include: [ "<sys/errno.h>", private, "<errno.h>", public ] }, + { include: [ "<sys/fcntl.h>", private, "<fcntl.h>", public ] }, + { include: [ "<sys/signal.h>", private, "<signal.h>", public ] }, + { include: [ "<sys/termios.h>", private, "<termios.h>", public ] }, + { include: [ '<asm/errno-base.h>', private, '<errno.h>', public ] }, + { include: [ '<asm/errno.h>', private, '<errno.h>', public ] }, { include: [ '<bits/termios-c_cc.h>', private, '<termios.h>', public ] }, { include: [ '<bits/termios-c_cflag.h>', private, '<termios.h>', public ] }, { include: [ '<bits/termios-c_iflag.h>', private, '<termios.h>', public ] }, { include: [ '<bits/termios-c_oflag.h>', private, '<termios.h>', public ] }, + { include: [ '<sys/unistd.h>', private, '<unistd.h>', public ] }, - # <unistd.h + { symbol: ["SOCK_STREAM", private, "<sys/socket.h>", public ] }, + { symbol: ["SSIZE_MAX", private, "<limits.h>", public ] }, + { symbol: ["S_IREAD", private, "<sys/stat.h>", public ] }, + { symbol: ["S_IWRITE", private, "<sys/stat.h>", public ] }, { symbol: ["_POSIX_VDISABLE", private, "<unistd.h>", public ] }, + { symbol: ["flock", private, "<sys/file.h>", public ] }, + { symbol: ["iovec", private, "<sys/uio.h>", public ] }, + { symbol: ["mode_t", private, "<sys/types.h>", public ] }, + { symbol: ["ntohs", private, "<arpa/inet.h>", public ] }, + { symbol: ["pthread_sigmask", private, "<signal.h>", public ] }, + { symbol: ["sigset_t", private, "<signal.h>", public ] }, + { symbol: ["ssize_t", private, "<sys/types.h>", public ] }, + { symbol: ["uid_t", private, "<sys/types.h>", public ] }, ] # vim: set ft=toml: diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt @@ -259,6 +259,7 @@ if(ENABLE_IWYU) set(iwyu_flags "${IWYU_PRG};") string(APPEND iwyu_flags "-Xiwyu;--no_default_mappings;") + string(APPEND iwyu_flags "-Xiwyu;--no_fwd_decls;") string(APPEND iwyu_flags "-Xiwyu;--mapping_file=${PROJECT_SOURCE_DIR}/cmake.config/iwyu/mapping.imp") set_target_properties(nvim PROPERTIES C_INCLUDE_WHAT_YOU_USE "${iwyu_flags}") diff --git a/src/nvim/base64.c b/src/nvim/base64.c @@ -3,7 +3,7 @@ #include <stdint.h> #include <string.h> -#include "auto/config.h" +#include "auto/config.h" // IWYU pragma: keep #include "nvim/base64.h" #include "nvim/memory.h" diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h @@ -4,7 +4,7 @@ #include <stdint.h> #include <stdio.h> -typedef struct file_buffer buf_T; // Forward declaration +typedef struct file_buffer buf_T; /// Reference to a buffer that stores the value of buf_free_count. /// bufref_valid() only needs to check "buf" when the count differs. diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c @@ -6,6 +6,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" diff --git a/src/nvim/edit.c b/src/nvim/edit.c @@ -9,6 +9,7 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" +#include "nvim/autocmd_defs.h" #include "nvim/buffer.h" #include "nvim/change.h" #include "nvim/charset.h" diff --git a/src/nvim/eval.c b/src/nvim/eval.c @@ -7,6 +7,7 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <sys/types.h> #include "auto/config.h" #include "nvim/api/private/converter.h" diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "nvim/ascii.h" #include "nvim/assert.h" diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c @@ -2,7 +2,7 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> +#include <sys/types.h> #include <uv.h> #include "nvim/event/loop.h" diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "auto/config.h" #include "nvim/arglist.h" diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c @@ -11,6 +11,7 @@ #include <stdio.h> #include <string.h> #include <sys/stat.h> +#include <sys/types.h> #include <time.h> #include <uv.h> diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c @@ -4,6 +4,7 @@ #include <stdbool.h> #include <stdio.h> #include <string.h> +#include <sys/types.h> #include "nvim/ascii.h" #include "nvim/charset.h" diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c @@ -5,8 +5,8 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> +#include <sys/types.h> #ifdef NVIM_VENDOR_BIT # include "bit.h" diff --git a/src/nvim/main.c b/src/nvim/main.c @@ -21,6 +21,11 @@ #include "nvim/vim.h" // uncrustify:on +#include "auto/config.h" // IWYU pragma: keep +#include "nvim/api/extmark.h" +#include "nvim/api/private/defs.h" +#include "nvim/api/private/helpers.h" +#include "nvim/api/ui.h" #include "nvim/arglist.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" @@ -34,7 +39,9 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" +#include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" +#include "nvim/event/process.h" #include "nvim/event/stream.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" @@ -61,6 +68,9 @@ #include "nvim/message.h" #include "nvim/mouse.h" #include "nvim/move.h" +#include "nvim/msgpack_rpc/channel.h" +#include "nvim/msgpack_rpc/helpers.h" +#include "nvim/msgpack_rpc/server.h" #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" @@ -71,6 +81,7 @@ #include "nvim/os/input.h" #include "nvim/os/lang.h" #include "nvim/os/os.h" +#include "nvim/os/signal.h" #include "nvim/os/stdpaths_defs.h" #include "nvim/path.h" #include "nvim/popupmenu.h" @@ -91,16 +102,6 @@ #ifdef MSWIN # include "nvim/os/os_win_console.h" #endif -#include "nvim/api/extmark.h" -#include "nvim/api/private/defs.h" -#include "nvim/api/private/helpers.h" -#include "nvim/api/ui.h" -#include "nvim/event/loop.h" -#include "nvim/event/process.h" -#include "nvim/msgpack_rpc/channel.h" -#include "nvim/msgpack_rpc/helpers.h" -#include "nvim/msgpack_rpc/server.h" -#include "nvim/os/signal.h" // values for "window_layout" enum { diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c @@ -47,6 +47,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "klib/kvec.h" #include "nvim/garray.h" diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c @@ -32,6 +32,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include <wctype.h> #include "auto/config.h" diff --git a/src/nvim/memline.c b/src/nvim/memline.c @@ -39,6 +39,7 @@ #include <stddef.h> #include <stdio.h> #include <string.h> +#include <sys/types.h> #include <time.h> #include <uv.h> diff --git a/src/nvim/message.c b/src/nvim/message.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" diff --git a/src/nvim/ops.c b/src/nvim/ops.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "nvim/api/private/defs.h" #include "nvim/ascii.h" diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c @@ -28,6 +28,10 @@ # include "nvim/os/os_win_console.h" #endif +#ifdef HAVE_SYS_UIO_H +# include <sys/uio.h> +#endif + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/fileio.c.generated.h" #endif diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c @@ -67,8 +67,6 @@ static const char e_xattr_other[] = N_("E1509: Error occurred when reading or writing extended attribute"); #endif -struct iovec; - #define RUN_UV_FS_FUNC(ret, func, ...) \ do { \ uv_fs_t req; \ diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c @@ -3,18 +3,19 @@ /// psutil is a good reference for cross-platform syscall voodoo: /// https://github.com/giampaolo/psutil/tree/master/psutil/arch +// IWYU pragma: no_include <sys/param.h> + #include <assert.h> #include <signal.h> #include <stdbool.h> #include <stddef.h> -#include <stdio.h> #include <uv.h> #ifdef MSWIN # include <tlhelp32.h> #endif -#if defined(__FreeBSD__) // XXX: OpenBSD ? +#if defined(__FreeBSD__) # include <string.h> # include <sys/types.h> # include <sys/user.h> @@ -25,8 +26,13 @@ #endif #if defined(__APPLE__) || defined(BSD) -# include <pwd.h> # include <sys/sysctl.h> + +# include "nvim/macros.h" +#endif + +#if defined(__linux__) +# include <stdio.h> #endif #include "nvim/log.h" diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c @@ -1,6 +1,7 @@ #include <assert.h> #include <stdbool.h> #include <stdio.h> + #ifndef MSWIN # include <signal.h> #endif @@ -11,9 +12,12 @@ #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" -#include "nvim/memline.h" #include "nvim/os/signal.h" +#ifdef SIGPWR +# include "nvim/memline.h" +#endif + static SignalWatcher spipe, shup, squit, sterm, susr1, swinch; #ifdef SIGPWR static SignalWatcher spwr; diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c @@ -17,8 +17,6 @@ #include "nvim/os/os.h" #include "nvim/os/time.h" -struct tm; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/time.c.generated.h" // IWYU pragma: export #endif diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h @@ -1,15 +1,18 @@ #pragma once // IWYU pragma: private, include "nvim/os/os_defs.h" -#include <sys/param.h> // IWYU pragma: export -#include <sys/socket.h> // IWYU pragma: export -#include <unistd.h> // IWYU pragma: export +// IWYU pragma: begin_exports +#include <arpa/inet.h> +#include <netdb.h> +#include <netinet/in.h> +#include <pthread.h> +#include <sys/param.h> +#include <sys/socket.h> +#include <unistd.h> #if defined(HAVE_TERMIOS_H) -# include <termios.h> // IWYU pragma: export +# include <termios.h> #endif - -// POSIX.1-2008 says that NAME_MAX should be in here -#include <limits.h> +// IWYU pragma: end_exports #define TEMP_DIR_NAMES { "$TMPDIR", "/tmp", ".", "~" } #define TEMP_FILE_PATH_MAXLEN 256 diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c @@ -7,9 +7,9 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> -#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "klib/kvec.h" #include "nvim/api/private/defs.h" diff --git a/src/nvim/undo.c b/src/nvim/undo.c @@ -77,6 +77,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include <time.h> #include <uv.h>