gcc.symbols.imp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. # This was initially taken from the IWYU repository:
  2. # github.com/include-what-you-use/include-what-you-use/blob/164b8fe7597805ae55f029ecf6580dc46a74c7ed/gcc.symbols.imp
  3. # It has useful mappings that are normally enabled by default, but there are
  4. # other default mappings that conflict with our builds. The best solution seems
  5. # to be to disable all defaults, import the defaults from the IWYU repo and
  6. # modify the rules that conflict with our build.
  7. #
  8. # TODO(dundargoc): Check if there is a way to disable specific builtin maps as
  9. # to avoid this file entirely.
  10. # For library symbols that can be defined in more than one header
  11. # file, maps from symbol-name to legitimate header files.
  12. # This list was generated via
  13. # grep -R '__.*_defined' /usr/include | perl -nle 'm,/usr/include/([^:]*):#\s*\S+ __(.*)_defined, and print qq@ { symbol: [ "$2", public, "<$1>", public ] },@' | sort -u
  14. # I ignored all entries that only appeared once on the list (eg uint32_t).
  15. # I then added in NULL, which according to [diff.null] C.2.2.3, can
  16. # be defined in <clocale>, <cstddef>, <cstdio>, <cstdlib>,
  17. # <cstring>, <ctime>, or <cwchar>. We also allow their C
  18. # equivalents.
  19. # In each case, I ordered them so <sys/types.h> was first, if it was
  20. # an option for this type. That's the preferred #include all else
  21. # equal. The same goes for <stdint.h>. The visibility on the
  22. # symbol-name is ignored; by convention we always set it to private.
  23. [
  24. { symbol: [ "aiocb", private, "<aio.h>", public ] },
  25. { symbol: [ "blkcnt_t", private, "<sys/types.h>", public ] },
  26. { symbol: [ "blkcnt_t", private, "<sys/stat.h>", public ] },
  27. { symbol: [ "blksize_t", private, "<sys/types.h>", public ] },
  28. { symbol: [ "blksize_t", private, "<sys/stat.h>", public ] },
  29. { symbol: [ "cc_t", private, "<termios.h>", private ] },
  30. { symbol: [ "clock_t", private, "<sys/types.h>", public ] },
  31. { symbol: [ "clock_t", private, "<sys/time.h>", public ] },
  32. { symbol: [ "clock_t", private, "<time.h>", public ] },
  33. { symbol: [ "clockid_t", private, "<sys/types.h>", public ] },
  34. { symbol: [ "clockid_t", private, "<time.h>", public ] },
  35. { symbol: [ "daddr_t", private, "<sys/types.h>", public ] },
  36. { symbol: [ "daddr_t", private, "<rpc/types.h>", public ] },
  37. { symbol: [ "dev_t", private, "<sys/types.h>", public ] },
  38. { symbol: [ "dev_t", private, "<sys/stat.h>", public ] },
  39. { symbol: [ "div_t", private, "<stdlib.h>", public ] },
  40. { symbol: [ "double_t", private, "<math.h>", public ] },
  41. { symbol: [ "error_t", private, "<errno.h>", public ] },
  42. { symbol: [ "error_t", private, "<argp.h>", public ] },
  43. { symbol: [ "error_t", private, "<argz.h>", public ] },
  44. { symbol: [ "fd_set", private, "<sys/select.h>", public ] },
  45. { symbol: [ "fd_set", private, "<sys/time.h>", public ] },
  46. { symbol: [ "fenv_t", private, "<fenv.h>", public ] },
  47. { symbol: [ "fexcept_t", private, "<fenv.h>", public ] },
  48. { symbol: [ "FILE", private, "<stdio.h>", public ] },
  49. { symbol: [ "FILE", private, "<wchar.h>", public ] },
  50. { symbol: [ "float_t", private, "<math.h>", public ] },
  51. { symbol: [ "fsblkcnt_t", private, "<sys/types.h>", public ] },
  52. { symbol: [ "fsblkcnt_t", private, "<sys/statvfs.h>", public ] },
  53. { symbol: [ "fsfilcnt_t", private, "<sys/types.h>", public ] },
  54. { symbol: [ "fsfilcnt_t", private, "<sys/statvfs.h>", public ] },
  55. { symbol: [ "getopt", private, "<unistd.h>", private ] },
  56. { symbol: [ "gid_t", private, "<sys/types.h>", public ] },
  57. { symbol: [ "gid_t", private, "<grp.h>", public ] },
  58. { symbol: [ "gid_t", private, "<pwd.h>", public ] },
  59. { symbol: [ "gid_t", private, "<signal.h>", public ] },
  60. { symbol: [ "gid_t", private, "<stropts.h>", public ] },
  61. { symbol: [ "gid_t", private, "<sys/ipc.h>", public ] },
  62. { symbol: [ "gid_t", private, "<sys/stat.h>", public ] },
  63. { symbol: [ "gid_t", private, "<unistd.h>", private ] },
  64. { symbol: [ "htonl", private, "<arpa/inet.h>", private ] },
  65. { symbol: [ "htons", private, "<arpa/inet.h>", private ] },
  66. { symbol: [ "id_t", private, "<sys/types.h>", public ] },
  67. { symbol: [ "id_t", private, "<sys/resource.h>", public ] },
  68. { symbol: [ "imaxdiv_t", private, "<inttypes.h>", public ] },
  69. { symbol: [ "intmax_t", private, "<stdint.h>", public ] },
  70. { symbol: [ "uintmax_t", private, "<stdint.h>", public ] },
  71. { symbol: [ "ino64_t", private, "<sys/types.h>", public ] },
  72. { symbol: [ "ino64_t", private, "<dirent.h>", public ] },
  73. { symbol: [ "ino_t", private, "<sys/types.h>", public ] },
  74. { symbol: [ "ino_t", private, "<dirent.h>", public ] },
  75. { symbol: [ "ino_t", private, "<sys/stat.h>", public ] },
  76. { symbol: [ "int8_t", private, "<stdint.h>", public ] },
  77. { symbol: [ "int16_t", private, "<stdint.h>", public ] },
  78. { symbol: [ "int32_t", private, "<stdint.h>", public ] },
  79. { symbol: [ "int64_t", private, "<stdint.h>", public ] },
  80. { symbol: [ "uint8_t", private, "<stdint.h>", public ] },
  81. { symbol: [ "uint16_t", private, "<stdint.h>", public ] },
  82. { symbol: [ "uint32_t", private, "<stdint.h>", public ] },
  83. { symbol: [ "uint64_t", private, "<stdint.h>", public ] },
  84. { symbol: [ "intptr_t", private, "<stdint.h>", public ] },
  85. { symbol: [ "uintptr_t", private, "<stdint.h>", public ] },
  86. { symbol: [ "iovec", private, "<sys/uio.h>", public ] },
  87. { symbol: [ "iovec", private, "<sys/socket.h>", private ] },
  88. { symbol: [ "itimerspec", private, "<time.h>", public ] },
  89. { symbol: [ "itimerspec", private, "<sys/timerfd.h>", public ] },
  90. { symbol: [ "key_t", private, "<sys/types.h>", public ] },
  91. { symbol: [ "key_t", private, "<sys/ipc.h>", public ] },
  92. { symbol: [ "lconv", private, "<locale.h>", public ] },
  93. { symbol: [ "ldiv_t", private, "<stdlib.h>", public ] },
  94. { symbol: [ "lldiv_t", private, "<stdlib.h>", public ] },
  95. { symbol: [ "max_align_t", private, "<stddef.h>", public ] },
  96. { symbol: [ "mode_t", private, "<sys/types.h>", public ] },
  97. { symbol: [ "mode_t", private, "<fcntl.h>", public ] },
  98. { symbol: [ "mode_t", private, "<ndbm.h>", public ] },
  99. { symbol: [ "mode_t", private, "<spawn.h>", public ] },
  100. { symbol: [ "mode_t", private, "<sys/ipc.h>", public ] },
  101. { symbol: [ "mode_t", private, "<sys/mman.h>", public ] },
  102. { symbol: [ "mode_t", private, "<sys/stat.h>", public ] },
  103. { symbol: [ "nlink_t", private, "<sys/types.h>", public ] },
  104. { symbol: [ "nlink_t", private, "<sys/stat.h>", public ] },
  105. { symbol: [ "ntohl", private, "<arpa/inet.h>", private ] },
  106. { symbol: [ "ntohs", private, "<arpa/inet.h>", private ] },
  107. { symbol: [ "off64_t", private, "<sys/types.h>", public ] },
  108. { symbol: [ "off64_t", private, "<unistd.h>", private ] },
  109. { symbol: [ "off_t", private, "<sys/types.h>", public ] },
  110. { symbol: [ "off_t", private, "<aio.h>", public ] },
  111. { symbol: [ "off_t", private, "<fcntl.h>", public ] },
  112. { symbol: [ "off_t", private, "<stdio.h>", public ] },
  113. { symbol: [ "off_t", private, "<sys/mman.h>", public ] },
  114. { symbol: [ "off_t", private, "<sys/stat.h>", public ] },
  115. { symbol: [ "off_t", private, "<unistd.h>", private ] },
  116. { symbol: [ "optarg", private, "<unistd.h>", private ] },
  117. { symbol: [ "opterr", private, "<unistd.h>", private ] },
  118. { symbol: [ "optind", private, "<unistd.h>", private ] },
  119. { symbol: [ "optopt", private, "<unistd.h>", private ] },
  120. { symbol: [ "pid_t", private, "<sys/types.h>", public ] },
  121. { symbol: [ "pid_t", private, "<fcntl.h>", public ] },
  122. { symbol: [ "pid_t", private, "<sched.h>", public ] },
  123. { symbol: [ "pid_t", private, "<signal.h>", public ] },
  124. { symbol: [ "pid_t", private, "<spawn.h>", public ] },
  125. { symbol: [ "pid_t", private, "<sys/msg.h>", public ] },
  126. { symbol: [ "pid_t", private, "<sys/sem.h>", public ] },
  127. { symbol: [ "pid_t", private, "<sys/shm.h>", public ] },
  128. { symbol: [ "pid_t", private, "<sys/wait.h>", public ] },
  129. { symbol: [ "pid_t", private, "<termios.h>", private ] },
  130. { symbol: [ "pid_t", private, "<time.h>", public ] },
  131. { symbol: [ "pid_t", private, "<unistd.h>", private ] },
  132. { symbol: [ "pid_t", private, "<utmpx.h>", public ] },
  133. { symbol: [ "ptrdiff_t", private, "<stddef.h>", public ] },
  134. { symbol: [ "regex_t", private, "<regex.h>", public ] },
  135. { symbol: [ "regmatch_t", private, "<regex.h>", public ] },
  136. { symbol: [ "regoff_t", private, "<regex.h>", public ] },
  137. { symbol: [ "sigevent", private, "<signal.h>", public ] },
  138. { symbol: [ "sigevent", private, "<aio.h>", public ] },
  139. { symbol: [ "sigevent", private, "<mqueue.h>", public ] },
  140. { symbol: [ "sigevent", private, "<time.h>", public ] },
  141. { symbol: [ "siginfo_t", private, "<signal.h>", public ] },
  142. { symbol: [ "siginfo_t", private, "<sys/wait.h>", public ] },
  143. { symbol: [ "sigset_t", private, "<signal.h>", public ] },
  144. { symbol: [ "sigset_t", private, "<spawn.h>", public ] },
  145. { symbol: [ "sigset_t", private, "<sys/select.h>", public ] },
  146. { symbol: [ "sigval", private, "<signal.h>", public ] },
  147. { symbol: [ "sockaddr", private, "<sys/socket.h>", private ] },
  148. { symbol: [ "socklen_t", private, "<sys/socket.h>", private ] },
  149. { symbol: [ "socklen_t", private, "<netdb.h>", private ] },
  150. { symbol: [ "ssize_t", private, "<sys/types.h>", public ] },
  151. { symbol: [ "ssize_t", private, "<aio.h>", public ] },
  152. { symbol: [ "ssize_t", private, "<monetary.h>", public ] },
  153. { symbol: [ "ssize_t", private, "<mqueue.h>", public ] },
  154. { symbol: [ "ssize_t", private, "<stdio.h>", public ] },
  155. { symbol: [ "ssize_t", private, "<sys/msg.h>", public ] },
  156. { symbol: [ "ssize_t", private, "<sys/socket.h>", private ] },
  157. { symbol: [ "ssize_t", private, "<sys/uio.h>", public ] },
  158. { symbol: [ "ssize_t", private, "<unistd.h>", private ] },
  159. { symbol: [ "stat", private, "<sys/stat.h>", public ] },
  160. { symbol: [ "stat", private, "<ftw.h>", public ] },
  161. { symbol: [ "suseconds_t", private, "<sys/types.h>", public ] },
  162. { symbol: [ "suseconds_t", private, "<sys/select.h>", public ] },
  163. { symbol: [ "suseconds_t", private, "<sys/time.h>", public ] },
  164. { symbol: [ "time_t", private, "<time.h>", public ] },
  165. { symbol: [ "time_t", private, "<sched.h>", public ] },
  166. { symbol: [ "time_t", private, "<sys/msg.h>", public ] },
  167. { symbol: [ "time_t", private, "<sys/select.h>", public ] },
  168. { symbol: [ "time_t", private, "<sys/sem.h>", public ] },
  169. { symbol: [ "time_t", private, "<sys/shm.h>", public ] },
  170. { symbol: [ "time_t", private, "<sys/stat.h>", public ] },
  171. { symbol: [ "time_t", private, "<sys/time.h>", public ] },
  172. { symbol: [ "time_t", private, "<sys/types.h>", public ] },
  173. { symbol: [ "time_t", private, "<utime.h>", public ] },
  174. { symbol: [ "timer_t", private, "<sys/types.h>", public ] },
  175. { symbol: [ "timer_t", private, "<time.h>", public ] },
  176. { symbol: [ "timespec", private, "<time.h>", public ] },
  177. { symbol: [ "timespec", private, "<aio.h>", public ] },
  178. { symbol: [ "timespec", private, "<mqueue.h>", public ] },
  179. { symbol: [ "timespec", private, "<sched.h>", public ] },
  180. { symbol: [ "timespec", private, "<signal.h>", public ] },
  181. { symbol: [ "timespec", private, "<sys/select.h>", public ] },
  182. { symbol: [ "timespec", private, "<sys/stat.h>", public ] },
  183. { symbol: [ "timeval", private, "<sys/time.h>", public ] },
  184. { symbol: [ "timeval", private, "<sys/resource.h>", public ] },
  185. { symbol: [ "timeval", private, "<sys/select.h>", public ] },
  186. { symbol: [ "timeval", private, "<utmpx.h>", public ] },
  187. { symbol: [ "tm", private, "<time.h>", public ] },
  188. { symbol: [ "u_char", private, "<sys/types.h>", public ] },
  189. { symbol: [ "u_char", private, "<rpc/types.h>", public ] },
  190. { symbol: [ "uid_t", private, "<sys/types.h>", public ] },
  191. { symbol: [ "uid_t", private, "<pwd.h>", public ] },
  192. { symbol: [ "uid_t", private, "<signal.h>", public ] },
  193. { symbol: [ "uid_t", private, "<stropts.h>", public ] },
  194. { symbol: [ "uid_t", private, "<sys/ipc.h>", public ] },
  195. { symbol: [ "uid_t", private, "<sys/stat.h>", public ] },
  196. { symbol: [ "uid_t", private, "<unistd.h>", private ] },
  197. { symbol: [ "useconds_t", private, "<sys/types.h>", public ] },
  198. { symbol: [ "useconds_t", private, "<unistd.h>", private ] },
  199. { symbol: [ "wchar_t", private, "<stddef.h>", public ] },
  200. { symbol: [ "wchar_t", private, "<stdlib.h>", public ] },
  201. { symbol: [ "size_t", private, "<stddef.h>", public ] },
  202. { symbol: [ "size_t", private, "<aio.h>", public ] },
  203. { symbol: [ "size_t", private, "<glob.h>", public ] },
  204. { symbol: [ "size_t", private, "<grp.h>", public ] },
  205. { symbol: [ "size_t", private, "<iconv.h>", public ] },
  206. { symbol: [ "size_t", private, "<monetary.h>", public ] },
  207. { symbol: [ "size_t", private, "<mqueue.h>", public ] },
  208. { symbol: [ "size_t", private, "<ndbm.h>", public ] },
  209. { symbol: [ "size_t", private, "<pwd.h>", public ] },
  210. { symbol: [ "size_t", private, "<regex.h>", public ] },
  211. { symbol: [ "size_t", private, "<search.h>", public ] },
  212. { symbol: [ "size_t", private, "<signal.h>", public ] },
  213. { symbol: [ "size_t", private, "<stdio.h>", public ] },
  214. { symbol: [ "size_t", private, "<stdlib.h>", public ] },
  215. { symbol: [ "size_t", private, "<string.h>", public ] },
  216. { symbol: [ "size_t", private, "<strings.h>", public ] },
  217. { symbol: [ "size_t", private, "<sys/mman.h>", public ] },
  218. { symbol: [ "size_t", private, "<sys/msg.h>", public ] },
  219. { symbol: [ "size_t", private, "<sys/sem.h>", public ] },
  220. { symbol: [ "size_t", private, "<sys/shm.h>", public ] },
  221. { symbol: [ "size_t", private, "<sys/socket.h>", private ] },
  222. { symbol: [ "size_t", private, "<sys/types.h>", public ] },
  223. { symbol: [ "size_t", private, "<sys/uio.h>", public ] },
  224. { symbol: [ "size_t", private, "<time.h>", public ] },
  225. { symbol: [ "size_t", private, "<uchar.h>", public ] },
  226. { symbol: [ "size_t", private, "<unistd.h>", private ] },
  227. { symbol: [ "size_t", private, "<wchar.h>", public ] },
  228. { symbol: [ "size_t", private, "<wordexp.h>", public ] },
  229. # Macros that can be defined in more than one file, don't have the
  230. # same __foo_defined guard that other types do, so the grep above
  231. # doesn't discover them. Until I figure out a better way, I just
  232. # add them in by hand as I discover them.
  233. { symbol: [ "EOF", private, "<stdio.h>", public ] },
  234. { symbol: [ "EOF", private, "<libio.h>", public ] },
  235. { symbol: [ "FILE", private, "<stdio.h>", public ] },
  236. { symbol: [ "MAP_POPULATE", private, "<sys/mman.h>", public ] },
  237. { symbol: [ "MAP_POPULATE", private, "<linux/mman.h>", public ] },
  238. { symbol: [ "MAP_STACK", private, "<sys/mman.h>", public ] },
  239. { symbol: [ "MAP_STACK", private, "<linux/mman.h>", public ] },
  240. { symbol: [ "MAXHOSTNAMELEN", private, "<sys/param.h>", public ] },
  241. { symbol: [ "MAXHOSTNAMELEN", private, "<protocols/timed.h>", public ] },
  242. { symbol: [ "SIGABRT", private, "<signal.h>", public ] },
  243. { symbol: [ "SIGCHLD", private, "<signal.h>", public ] },
  244. { symbol: [ "SIGCHLD", private, "<linux/signal.h>", public ] },
  245. { symbol: [ "va_list", private, "<stdarg.h>", public ] },
  246. { symbol: [ "va_list", private, "<stdio.h>", public ] },
  247. { symbol: [ "va_list", private, "<wchar.h>", public ] },
  248. # These are symbols that could be defined in either stdlib.h or
  249. # malloc.h, but we always want the stdlib location.
  250. { symbol: [ "malloc", private, "<stdlib.h>", public ] },
  251. { symbol: [ "calloc", private, "<stdlib.h>", public ] },
  252. { symbol: [ "realloc", private, "<stdlib.h>", public ] },
  253. { symbol: [ "free", private, "<stdlib.h>", public ] },
  254. # Entries for NULL
  255. { symbol: [ "NULL", private, "<stddef.h>", public ] }, # 'canonical' location for NULL
  256. { symbol: [ "NULL", private, "<clocale>", public ] },
  257. { symbol: [ "NULL", private, "<cstddef>", public ] },
  258. { symbol: [ "NULL", private, "<cstdio>", public ] },
  259. { symbol: [ "NULL", private, "<cstdlib>", public ] },
  260. { symbol: [ "NULL", private, "<cstring>", public ] },
  261. { symbol: [ "NULL", private, "<ctime>", public ] },
  262. { symbol: [ "NULL", private, "<cwchar>", public ] },
  263. { symbol: [ "NULL", private, "<locale.h>", public ] },
  264. { symbol: [ "NULL", private, "<stdio.h>", public ] },
  265. { symbol: [ "NULL", private, "<stdlib.h>", public ] },
  266. { symbol: [ "NULL", private, "<string.h>", public ] },
  267. { symbol: [ "NULL", private, "<time.h>", public ] },
  268. { symbol: [ "NULL", private, "<unistd.h>", private ] },
  269. { symbol: [ "NULL", private, "<wchar.h>", public ] },
  270. # Kludge time: almost all STL types take an allocator, but they
  271. # almost always use the default value. Usually we detect that
  272. # and don't try to do IWYU, but sometimes it passes through.
  273. # For instance, when adding two strings, we end up calling
  274. # template<_CharT,_Traits,_Alloc> ... operator+(
  275. # basic_string<_CharT,_Traits,_Alloc>, ...)
  276. # These look like normal template args to us, so we see they're
  277. # used and declare an iwyu dependency, even though we don't need
  278. # to #include the traits or alloc type ourselves. The surest way
  279. # to deal with this is to just say that everyone provides
  280. # std::allocator. We can add more here at need.
  281. { symbol: [ "std::allocator", private, "<memory>", public ] },
  282. { symbol: [ "std::allocator", private, "<string>", public ] },
  283. { symbol: [ "std::allocator", private, "<vector>", public ] },
  284. { symbol: [ "std::allocator", private, "<map>", public ] },
  285. { symbol: [ "std::allocator", private, "<set>", public ] },
  286. # A similar kludge for std::char_traits. basic_string,
  287. # basic_ostream and basic_istream have this as a default template
  288. # argument, and sometimes it bleeds through when clang desugars the
  289. # string/ostream/istream type.
  290. { symbol: [ "std::char_traits", private, "<string>", public ] },
  291. { symbol: [ "std::char_traits", private, "<ostream>", public ] },
  292. { symbol: [ "std::char_traits", private, "<istream>", public ] },
  293. { symbol: [ "std::size_t", private, "<cstddef>", public ] },
  294. { symbol: [ "std::size_t", private, "<cstdio>", public ] },
  295. { symbol: [ "std::size_t", private, "<cstdlib>", public ] },
  296. { symbol: [ "std::size_t", private, "<cstring>", public ] },
  297. { symbol: [ "std::size_t", private, "<ctime>", public ] },
  298. { symbol: [ "std::size_t", private, "<cuchar>", public ] },
  299. { symbol: [ "std::size_t", private, "<cwchar>", public ] }
  300. ]
  301. # vim: set ft=toml: