# 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 , , , , # , , or . We also allow their C # equivalents. # In each case, I ordered them so was first, if it was # an option for this type. That's the preferred #include all else # equal. The same goes for . The visibility on the # symbol-name is ignored; by convention we always set it to private. [ { symbol: [ "aiocb", private, "", public ] }, { symbol: [ "blkcnt_t", private, "", public ] }, { symbol: [ "blkcnt_t", private, "", public ] }, { symbol: [ "blksize_t", private, "", public ] }, { symbol: [ "blksize_t", private, "", public ] }, { symbol: [ "cc_t", private, "", private ] }, { symbol: [ "clock_t", private, "", public ] }, { symbol: [ "clock_t", private, "", public ] }, { symbol: [ "clock_t", private, "", public ] }, { symbol: [ "clockid_t", private, "", public ] }, { symbol: [ "clockid_t", private, "", public ] }, { symbol: [ "daddr_t", private, "", public ] }, { symbol: [ "daddr_t", private, "", public ] }, { symbol: [ "dev_t", private, "", public ] }, { symbol: [ "dev_t", private, "", public ] }, { symbol: [ "div_t", private, "", public ] }, { symbol: [ "double_t", private, "", public ] }, { symbol: [ "error_t", private, "", public ] }, { symbol: [ "error_t", private, "", public ] }, { symbol: [ "error_t", private, "", public ] }, { symbol: [ "fd_set", private, "", public ] }, { symbol: [ "fd_set", private, "", public ] }, { symbol: [ "fenv_t", private, "", public ] }, { symbol: [ "fexcept_t", private, "", public ] }, { symbol: [ "FILE", private, "", public ] }, { symbol: [ "FILE", private, "", public ] }, { symbol: [ "float_t", private, "", public ] }, { symbol: [ "fsblkcnt_t", private, "", public ] }, { symbol: [ "fsblkcnt_t", private, "", public ] }, { symbol: [ "fsfilcnt_t", private, "", public ] }, { symbol: [ "fsfilcnt_t", private, "", public ] }, { symbol: [ "getopt", private, "", private ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", public ] }, { symbol: [ "gid_t", private, "", private ] }, { symbol: [ "htonl", private, "", private ] }, { symbol: [ "htons", private, "", private ] }, { symbol: [ "id_t", private, "", public ] }, { symbol: [ "id_t", private, "", public ] }, { symbol: [ "imaxdiv_t", private, "", public ] }, { symbol: [ "intmax_t", private, "", public ] }, { symbol: [ "uintmax_t", private, "", public ] }, { symbol: [ "ino64_t", private, "", public ] }, { symbol: [ "ino64_t", private, "", public ] }, { symbol: [ "ino_t", private, "", public ] }, { symbol: [ "ino_t", private, "", public ] }, { symbol: [ "ino_t", private, "", public ] }, { symbol: [ "int8_t", private, "", public ] }, { symbol: [ "int16_t", private, "", public ] }, { symbol: [ "int32_t", private, "", public ] }, { symbol: [ "int64_t", private, "", public ] }, { symbol: [ "uint8_t", private, "", public ] }, { symbol: [ "uint16_t", private, "", public ] }, { symbol: [ "uint32_t", private, "", public ] }, { symbol: [ "uint64_t", private, "", public ] }, { symbol: [ "intptr_t", private, "", public ] }, { symbol: [ "uintptr_t", private, "", public ] }, { symbol: [ "iovec", private, "", public ] }, { symbol: [ "iovec", private, "", private ] }, { symbol: [ "itimerspec", private, "", public ] }, { symbol: [ "itimerspec", private, "", public ] }, { symbol: [ "key_t", private, "", public ] }, { symbol: [ "key_t", private, "", public ] }, { symbol: [ "lconv", private, "", public ] }, { symbol: [ "ldiv_t", private, "", public ] }, { symbol: [ "lldiv_t", private, "", public ] }, { symbol: [ "max_align_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "mode_t", private, "", public ] }, { symbol: [ "nlink_t", private, "", public ] }, { symbol: [ "nlink_t", private, "", public ] }, { symbol: [ "ntohl", private, "", private ] }, { symbol: [ "ntohs", private, "", private ] }, { symbol: [ "off64_t", private, "", public ] }, { symbol: [ "off64_t", private, "", private ] }, { symbol: [ "off_t", private, "", public ] }, { symbol: [ "off_t", private, "", public ] }, { symbol: [ "off_t", private, "", public ] }, { symbol: [ "off_t", private, "", public ] }, { symbol: [ "off_t", private, "", public ] }, { symbol: [ "off_t", private, "", public ] }, { symbol: [ "off_t", private, "", private ] }, { symbol: [ "optarg", private, "", private ] }, { symbol: [ "opterr", private, "", private ] }, { symbol: [ "optind", private, "", private ] }, { symbol: [ "optopt", private, "", private ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", private ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "pid_t", private, "", private ] }, { symbol: [ "pid_t", private, "", public ] }, { symbol: [ "ptrdiff_t", private, "", public ] }, { symbol: [ "regex_t", private, "", public ] }, { symbol: [ "regmatch_t", private, "", public ] }, { symbol: [ "regoff_t", private, "", public ] }, { symbol: [ "sigevent", private, "", public ] }, { symbol: [ "sigevent", private, "", public ] }, { symbol: [ "sigevent", private, "", public ] }, { symbol: [ "sigevent", private, "", public ] }, { symbol: [ "siginfo_t", private, "", public ] }, { symbol: [ "siginfo_t", private, "", public ] }, { symbol: [ "sigset_t", private, "", public ] }, { symbol: [ "sigset_t", private, "", public ] }, { symbol: [ "sigset_t", private, "", public ] }, { symbol: [ "sigval", private, "", public ] }, { symbol: [ "sockaddr", private, "", private ] }, { symbol: [ "socklen_t", private, "", private ] }, { symbol: [ "socklen_t", private, "", private ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", private ] }, { symbol: [ "ssize_t", private, "", public ] }, { symbol: [ "ssize_t", private, "", private ] }, { symbol: [ "stat", private, "", public ] }, { symbol: [ "stat", private, "", public ] }, { symbol: [ "suseconds_t", private, "", public ] }, { symbol: [ "suseconds_t", private, "", public ] }, { symbol: [ "suseconds_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "time_t", private, "", public ] }, { symbol: [ "timer_t", private, "", public ] }, { symbol: [ "timer_t", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timespec", private, "", public ] }, { symbol: [ "timeval", private, "", public ] }, { symbol: [ "timeval", private, "", public ] }, { symbol: [ "timeval", private, "", public ] }, { symbol: [ "timeval", private, "", public ] }, { symbol: [ "tm", private, "", public ] }, { symbol: [ "u_char", private, "", public ] }, { symbol: [ "u_char", private, "", public ] }, { symbol: [ "uid_t", private, "", public ] }, { symbol: [ "uid_t", private, "", public ] }, { symbol: [ "uid_t", private, "", public ] }, { symbol: [ "uid_t", private, "", public ] }, { symbol: [ "uid_t", private, "", public ] }, { symbol: [ "uid_t", private, "", public ] }, { symbol: [ "uid_t", private, "", private ] }, { symbol: [ "useconds_t", private, "", public ] }, { symbol: [ "useconds_t", private, "", private ] }, { symbol: [ "wchar_t", private, "", public ] }, { symbol: [ "wchar_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", private ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", private ] }, { symbol: [ "size_t", private, "", public ] }, { symbol: [ "size_t", private, "", 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, "", public ] }, { symbol: [ "EOF", private, "", public ] }, { symbol: [ "FILE", private, "", public ] }, { symbol: [ "MAP_POPULATE", private, "", public ] }, { symbol: [ "MAP_POPULATE", private, "", public ] }, { symbol: [ "MAP_STACK", private, "", public ] }, { symbol: [ "MAP_STACK", private, "", public ] }, { symbol: [ "MAXHOSTNAMELEN", private, "", public ] }, { symbol: [ "MAXHOSTNAMELEN", private, "", public ] }, { symbol: [ "SIGABRT", private, "", public ] }, { symbol: [ "SIGCHLD", private, "", public ] }, { symbol: [ "SIGCHLD", private, "", public ] }, { symbol: [ "va_list", private, "", public ] }, { symbol: [ "va_list", private, "", public ] }, { symbol: [ "va_list", private, "", 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, "", public ] }, { symbol: [ "calloc", private, "", public ] }, { symbol: [ "realloc", private, "", public ] }, { symbol: [ "free", private, "", public ] }, # Entries for NULL { symbol: [ "NULL", private, "", public ] }, # 'canonical' location for NULL { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", public ] }, { symbol: [ "NULL", private, "", private ] }, { symbol: [ "NULL", private, "", 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, "", public ] }, { symbol: [ "std::allocator", private, "", public ] }, { symbol: [ "std::allocator", private, "", public ] }, { symbol: [ "std::allocator", private, "", public ] }, { symbol: [ "std::allocator", private, "", 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, "", public ] }, { symbol: [ "std::char_traits", private, "", public ] }, { symbol: [ "std::char_traits", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] }, { symbol: [ "std::size_t", private, "", public ] } ] # vim: set ft=toml: