mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 13:45:15 -07:00
66360675cf
Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
306 lines
18 KiB
TOML
306 lines
18 KiB
TOML
# This was initially taken from the IWYU repository:
|
|
# github.com/include-what-you-use/include-what-you-use/blob/164b8fe7597805ae55f029ecf6580dc46a74c7ed/gcc.symbols.imp
|
|
# It has useful mappings that are normally enabled by default, but there are
|
|
# other default mappings that conflict with our builds. The best solution seems
|
|
# to be to disable all defaults, import the defaults from the IWYU repo and
|
|
# modify the rules that conflict with our build.
|
|
#
|
|
# TODO(dundargoc): Check if there is a way to disable specific builtin maps as
|
|
# to avoid this file entirely.
|
|
|
|
# For library symbols that can be defined in more than one header
|
|
# file, maps from symbol-name to legitimate header files.
|
|
# This list was generated via
|
|
# grep -R '__.*_defined' /usr/include | perl -nle 'm,/usr/include/([^:]*):#\s*\S+ __(.*)_defined, and print qq@ { symbol: [ "$2", public, "<$1>", public ] },@' | sort -u
|
|
# I ignored all entries that only appeared once on the list (eg uint32_t).
|
|
# I then added in NULL, which according to [diff.null] C.2.2.3, can
|
|
# be defined in <clocale>, <cstddef>, <cstdio>, <cstdlib>,
|
|
# <cstring>, <ctime>, or <cwchar>. We also allow their C
|
|
# equivalents.
|
|
# In each case, I ordered them so <sys/types.h> was first, if it was
|
|
# an option for this type. That's the preferred #include all else
|
|
# equal. The same goes for <stdint.h>. The visibility on the
|
|
# symbol-name is ignored; by convention we always set it to private.
|
|
[
|
|
{ symbol: [ "aiocb", private, "<aio.h>", public ] },
|
|
{ symbol: [ "blkcnt_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "blkcnt_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "blksize_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "blksize_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "cc_t", private, "<termios.h>", private ] },
|
|
{ symbol: [ "clock_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "clock_t", private, "<sys/time.h>", public ] },
|
|
{ symbol: [ "clock_t", private, "<time.h>", public ] },
|
|
{ symbol: [ "clockid_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "clockid_t", private, "<time.h>", public ] },
|
|
{ symbol: [ "daddr_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "daddr_t", private, "<rpc/types.h>", public ] },
|
|
{ symbol: [ "dev_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "dev_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "div_t", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "double_t", private, "<math.h>", public ] },
|
|
{ symbol: [ "error_t", private, "<errno.h>", public ] },
|
|
{ symbol: [ "error_t", private, "<argp.h>", public ] },
|
|
{ symbol: [ "error_t", private, "<argz.h>", public ] },
|
|
{ symbol: [ "fd_set", private, "<sys/select.h>", public ] },
|
|
{ symbol: [ "fd_set", private, "<sys/time.h>", public ] },
|
|
{ symbol: [ "fenv_t", private, "<fenv.h>", public ] },
|
|
{ symbol: [ "fexcept_t", private, "<fenv.h>", public ] },
|
|
{ symbol: [ "FILE", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "FILE", private, "<wchar.h>", public ] },
|
|
{ symbol: [ "float_t", private, "<math.h>", public ] },
|
|
{ symbol: [ "fsblkcnt_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "fsblkcnt_t", private, "<sys/statvfs.h>", public ] },
|
|
{ symbol: [ "fsfilcnt_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "fsfilcnt_t", private, "<sys/statvfs.h>", public ] },
|
|
{ symbol: [ "getopt", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "gid_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<grp.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<pwd.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<signal.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<stropts.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<sys/ipc.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "gid_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "htonl", private, "<arpa/inet.h>", private ] },
|
|
{ symbol: [ "htons", private, "<arpa/inet.h>", private ] },
|
|
{ symbol: [ "id_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "id_t", private, "<sys/resource.h>", public ] },
|
|
{ symbol: [ "imaxdiv_t", private, "<inttypes.h>", public ] },
|
|
{ symbol: [ "intmax_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "uintmax_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "ino64_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "ino64_t", private, "<dirent.h>", public ] },
|
|
{ symbol: [ "ino_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "ino_t", private, "<dirent.h>", public ] },
|
|
{ symbol: [ "ino_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "int8_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "int16_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "int32_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "int64_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "uint8_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "uint16_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "uint32_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "uint64_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "intptr_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "uintptr_t", private, "<stdint.h>", public ] },
|
|
{ symbol: [ "iovec", private, "<sys/uio.h>", public ] },
|
|
{ symbol: [ "iovec", private, "<sys/socket.h>", private ] },
|
|
{ symbol: [ "itimerspec", private, "<time.h>", public ] },
|
|
{ symbol: [ "itimerspec", private, "<sys/timerfd.h>", public ] },
|
|
{ symbol: [ "key_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "key_t", private, "<sys/ipc.h>", public ] },
|
|
{ symbol: [ "lconv", private, "<locale.h>", public ] },
|
|
{ symbol: [ "ldiv_t", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "lldiv_t", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "max_align_t", private, "<stddef.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<fcntl.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<ndbm.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<spawn.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<sys/ipc.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<sys/mman.h>", public ] },
|
|
{ symbol: [ "mode_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "nlink_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "nlink_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "ntohl", private, "<arpa/inet.h>", private ] },
|
|
{ symbol: [ "ntohs", private, "<arpa/inet.h>", private ] },
|
|
{ symbol: [ "off64_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "off64_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "off_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "off_t", private, "<aio.h>", public ] },
|
|
{ symbol: [ "off_t", private, "<fcntl.h>", public ] },
|
|
{ symbol: [ "off_t", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "off_t", private, "<sys/mman.h>", public ] },
|
|
{ symbol: [ "off_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "off_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "optarg", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "opterr", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "optind", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "optopt", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "pid_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<fcntl.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<sched.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<signal.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<spawn.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<sys/msg.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<sys/sem.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<sys/shm.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<sys/wait.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<termios.h>", private ] },
|
|
{ symbol: [ "pid_t", private, "<time.h>", public ] },
|
|
{ symbol: [ "pid_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "pid_t", private, "<utmpx.h>", public ] },
|
|
{ symbol: [ "ptrdiff_t", private, "<stddef.h>", public ] },
|
|
{ symbol: [ "regex_t", private, "<regex.h>", public ] },
|
|
{ symbol: [ "regmatch_t", private, "<regex.h>", public ] },
|
|
{ symbol: [ "regoff_t", private, "<regex.h>", public ] },
|
|
{ symbol: [ "sigevent", private, "<signal.h>", public ] },
|
|
{ symbol: [ "sigevent", private, "<aio.h>", public ] },
|
|
{ symbol: [ "sigevent", private, "<mqueue.h>", public ] },
|
|
{ symbol: [ "sigevent", private, "<time.h>", public ] },
|
|
{ symbol: [ "siginfo_t", private, "<signal.h>", public ] },
|
|
{ symbol: [ "siginfo_t", private, "<sys/wait.h>", public ] },
|
|
{ symbol: [ "sigset_t", private, "<signal.h>", public ] },
|
|
{ symbol: [ "sigset_t", private, "<spawn.h>", public ] },
|
|
{ symbol: [ "sigset_t", private, "<sys/select.h>", public ] },
|
|
{ symbol: [ "sigval", private, "<signal.h>", public ] },
|
|
{ symbol: [ "sockaddr", private, "<sys/socket.h>", private ] },
|
|
{ symbol: [ "socklen_t", private, "<sys/socket.h>", private ] },
|
|
{ symbol: [ "socklen_t", private, "<netdb.h>", private ] },
|
|
{ symbol: [ "ssize_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<aio.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<monetary.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<mqueue.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<sys/msg.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<sys/socket.h>", private ] },
|
|
{ symbol: [ "ssize_t", private, "<sys/uio.h>", public ] },
|
|
{ symbol: [ "ssize_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "stat", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "stat", private, "<ftw.h>", public ] },
|
|
{ symbol: [ "suseconds_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "suseconds_t", private, "<sys/select.h>", public ] },
|
|
{ symbol: [ "suseconds_t", private, "<sys/time.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<time.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sched.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/msg.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/select.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/sem.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/shm.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/time.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "time_t", private, "<utime.h>", public ] },
|
|
{ symbol: [ "timer_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "timer_t", private, "<time.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<time.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<aio.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<mqueue.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<sched.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<signal.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<sys/select.h>", public ] },
|
|
{ symbol: [ "timespec", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "timeval", private, "<sys/time.h>", public ] },
|
|
{ symbol: [ "timeval", private, "<sys/resource.h>", public ] },
|
|
{ symbol: [ "timeval", private, "<sys/select.h>", public ] },
|
|
{ symbol: [ "timeval", private, "<utmpx.h>", public ] },
|
|
{ symbol: [ "tm", private, "<time.h>", public ] },
|
|
{ symbol: [ "u_char", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "u_char", private, "<rpc/types.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<pwd.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<signal.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<stropts.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<sys/ipc.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<sys/stat.h>", public ] },
|
|
{ symbol: [ "uid_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "useconds_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "useconds_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "wchar_t", private, "<stddef.h>", public ] },
|
|
{ symbol: [ "wchar_t", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<stddef.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<aio.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<glob.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<grp.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<iconv.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<monetary.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<mqueue.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<ndbm.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<pwd.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<regex.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<search.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<signal.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<string.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<strings.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<sys/mman.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<sys/msg.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<sys/sem.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<sys/shm.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<sys/socket.h>", private ] },
|
|
{ symbol: [ "size_t", private, "<sys/types.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<sys/uio.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<time.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<uchar.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "size_t", private, "<wchar.h>", public ] },
|
|
{ symbol: [ "size_t", private, "<wordexp.h>", public ] },
|
|
# Macros that can be defined in more than one file, don't have the
|
|
# same __foo_defined guard that other types do, so the grep above
|
|
# doesn't discover them. Until I figure out a better way, I just
|
|
# add them in by hand as I discover them.
|
|
{ symbol: [ "EOF", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "EOF", private, "<libio.h>", public ] },
|
|
{ symbol: [ "FILE", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "MAP_POPULATE", private, "<sys/mman.h>", public ] },
|
|
{ symbol: [ "MAP_POPULATE", private, "<linux/mman.h>", public ] },
|
|
{ symbol: [ "MAP_STACK", private, "<sys/mman.h>", public ] },
|
|
{ symbol: [ "MAP_STACK", private, "<linux/mman.h>", public ] },
|
|
{ symbol: [ "MAXHOSTNAMELEN", private, "<sys/param.h>", public ] },
|
|
{ symbol: [ "MAXHOSTNAMELEN", private, "<protocols/timed.h>", public ] },
|
|
{ symbol: [ "SIGABRT", private, "<signal.h>", public ] },
|
|
{ symbol: [ "SIGCHLD", private, "<signal.h>", public ] },
|
|
{ symbol: [ "SIGCHLD", private, "<linux/signal.h>", public ] },
|
|
{ symbol: [ "va_list", private, "<stdarg.h>", public ] },
|
|
{ symbol: [ "va_list", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "va_list", private, "<wchar.h>", public ] },
|
|
# These are symbols that could be defined in either stdlib.h or
|
|
# malloc.h, but we always want the stdlib location.
|
|
{ symbol: [ "malloc", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "calloc", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "realloc", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "free", private, "<stdlib.h>", public ] },
|
|
# Entries for NULL
|
|
{ symbol: [ "NULL", private, "<stddef.h>", public ] }, # 'canonical' location for NULL
|
|
{ symbol: [ "NULL", private, "<clocale>", public ] },
|
|
{ symbol: [ "NULL", private, "<cstddef>", public ] },
|
|
{ symbol: [ "NULL", private, "<cstdio>", public ] },
|
|
{ symbol: [ "NULL", private, "<cstdlib>", public ] },
|
|
{ symbol: [ "NULL", private, "<cstring>", public ] },
|
|
{ symbol: [ "NULL", private, "<ctime>", public ] },
|
|
{ symbol: [ "NULL", private, "<cwchar>", public ] },
|
|
{ symbol: [ "NULL", private, "<locale.h>", public ] },
|
|
{ symbol: [ "NULL", private, "<stdio.h>", public ] },
|
|
{ symbol: [ "NULL", private, "<stdlib.h>", public ] },
|
|
{ symbol: [ "NULL", private, "<string.h>", public ] },
|
|
{ symbol: [ "NULL", private, "<time.h>", public ] },
|
|
{ symbol: [ "NULL", private, "<unistd.h>", private ] },
|
|
{ symbol: [ "NULL", private, "<wchar.h>", public ] },
|
|
|
|
# Kludge time: almost all STL types take an allocator, but they
|
|
# almost always use the default value. Usually we detect that
|
|
# and don't try to do IWYU, but sometimes it passes through.
|
|
# For instance, when adding two strings, we end up calling
|
|
# template<_CharT,_Traits,_Alloc> ... operator+(
|
|
# basic_string<_CharT,_Traits,_Alloc>, ...)
|
|
# These look like normal template args to us, so we see they're
|
|
# used and declare an iwyu dependency, even though we don't need
|
|
# to #include the traits or alloc type ourselves. The surest way
|
|
# to deal with this is to just say that everyone provides
|
|
# std::allocator. We can add more here at need.
|
|
{ symbol: [ "std::allocator", private, "<memory>", public ] },
|
|
{ symbol: [ "std::allocator", private, "<string>", public ] },
|
|
{ symbol: [ "std::allocator", private, "<vector>", public ] },
|
|
{ symbol: [ "std::allocator", private, "<map>", public ] },
|
|
{ symbol: [ "std::allocator", private, "<set>", public ] },
|
|
# A similar kludge for std::char_traits. basic_string,
|
|
# basic_ostream and basic_istream have this as a default template
|
|
# argument, and sometimes it bleeds through when clang desugars the
|
|
# string/ostream/istream type.
|
|
{ symbol: [ "std::char_traits", private, "<string>", public ] },
|
|
{ symbol: [ "std::char_traits", private, "<ostream>", public ] },
|
|
{ symbol: [ "std::char_traits", private, "<istream>", public ] },
|
|
|
|
{ symbol: [ "std::size_t", private, "<cstddef>", public ] },
|
|
{ symbol: [ "std::size_t", private, "<cstdio>", public ] },
|
|
{ symbol: [ "std::size_t", private, "<cstdlib>", public ] },
|
|
{ symbol: [ "std::size_t", private, "<cstring>", public ] },
|
|
{ symbol: [ "std::size_t", private, "<ctime>", public ] },
|
|
{ symbol: [ "std::size_t", private, "<cuchar>", public ] },
|
|
{ symbol: [ "std::size_t", private, "<cwchar>", public ] }
|
|
]
|
|
|
|
# vim: set ft=toml:
|