build: enable IWYU on mac

This commit is contained in:
dundargoc 2023-11-26 21:36:02 +01:00 committed by dundargoc
parent 5b765fcab4
commit 40139738eb
29 changed files with 82 additions and 132 deletions

View File

@ -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\

View File

@ -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:

View File

@ -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:

View File

@ -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}")

View File

@ -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"

View File

@ -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.

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -11,6 +11,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <uv.h>

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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"

View File

@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <wctype.h>
#include "auto/config.h"

View File

@ -39,6 +39,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <uv.h>

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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; \

View File

@ -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"

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -77,6 +77,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <uv.h>