adlint 2.6.14 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (401) hide show
  1. data/AUTHORS +1 -3
  2. data/ChangeLog +511 -0
  3. data/INSTALL +1 -1
  4. data/MANIFEST +57 -37
  5. data/NEWS +36 -7
  6. data/README +2 -2
  7. data/Rakefile +6 -6
  8. data/TODO +1 -1
  9. data/bin/adlint +25 -16
  10. data/bin/adlint_chk +22 -12
  11. data/bin/adlint_cma +17 -12
  12. data/bin/adlint_sma +22 -12
  13. data/bin/adlintize +98 -17
  14. data/etc/conf.d/fallback/cinit.erb +1 -1
  15. data/etc/conf.d/fallback/traits.erb +37 -37
  16. data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
  17. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
  18. data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
  19. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
  20. data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
  21. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
  22. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
  23. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
  24. data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
  25. data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
  26. data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
  27. data/etc/conf.d/noarch/pinit.erb +1 -1
  28. data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
  29. data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
  30. data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
  31. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
  32. data/etc/mesg.d/core/en_US/messages.yml +2 -2
  33. data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
  34. data/features/code_check/W0018.feature +197 -0
  35. data/features/code_check/W0019.feature +79 -0
  36. data/features/code_check/W0021.feature +81 -0
  37. data/features/code_check/W0023.feature +203 -0
  38. data/features/code_check/W0024.feature +226 -0
  39. data/features/code_check/W0025.feature +5 -0
  40. data/features/code_check/W0088.feature +2 -2
  41. data/features/code_check/W0109.feature +2 -2
  42. data/features/code_check/W0477.feature +0 -3
  43. data/features/code_check/W0478.feature +0 -1
  44. data/features/code_check/W0582.feature +3 -3
  45. data/features/code_check/W0583.feature +4 -7
  46. data/features/code_check/W0646.feature +0 -1
  47. data/features/code_check/W0695.feature +0 -1
  48. data/features/code_check/W0705.feature +8 -0
  49. data/features/code_check/W0723.feature +0 -1
  50. data/features/code_check/W0745.feature +1 -0
  51. data/features/code_check/W0781.feature +1 -0
  52. data/features/code_check/W1057.feature +141 -0
  53. data/features/code_check/W1058.feature +93 -0
  54. data/features/code_check/W1059.feature +86 -0
  55. data/features/code_check/W1060.feature +77 -0
  56. data/features/code_check/W1061.feature +143 -0
  57. data/features/code_check/W1062.feature +162 -0
  58. data/features/code_check/W1063.feature +123 -0
  59. data/features/code_check/W1064.feature +83 -0
  60. data/features/code_check/W1065.feature +82 -0
  61. data/features/code_check/W9003.feature +2 -0
  62. data/features/step_definitions/code_check_steps.rb +1 -0
  63. data/features/support/env.rb +16 -13
  64. data/lib/adlint.rb +7 -4
  65. data/lib/adlint/analyzer.rb +131 -157
  66. data/lib/adlint/annot.rb +149 -0
  67. data/lib/adlint/cc1.rb +57 -0
  68. data/lib/adlint/{c → cc1}/branch.rb +74 -62
  69. data/lib/adlint/{c → cc1}/builtin.rb +21 -21
  70. data/lib/adlint/{c → cc1}/const.rb +119 -117
  71. data/lib/adlint/{c → cc1}/conv.rb +76 -78
  72. data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
  73. data/lib/adlint/cc1/domain.rb +8103 -0
  74. data/lib/adlint/{c → cc1}/enum.rb +3 -3
  75. data/lib/adlint/{c → cc1}/environ.rb +21 -21
  76. data/lib/adlint/{c → cc1}/expr.rb +232 -218
  77. data/lib/adlint/{c → cc1}/format.rb +305 -342
  78. data/lib/adlint/{c → cc1}/interp.rb +269 -220
  79. data/lib/adlint/cc1/lexer.rb +246 -0
  80. data/lib/adlint/{c → cc1}/mediator.rb +78 -84
  81. data/lib/adlint/{c → cc1}/object.rb +261 -264
  82. data/lib/adlint/{c → cc1}/operator.rb +7 -7
  83. data/lib/adlint/{c → cc1}/option.rb +4 -3
  84. data/lib/adlint/{c → cc1}/parser.rb +274 -506
  85. data/lib/adlint/{c → cc1}/parser.y +69 -301
  86. data/lib/adlint/cc1/phase.rb +138 -0
  87. data/lib/adlint/{c → cc1}/resolver.rb +66 -78
  88. data/lib/adlint/{c → cc1}/scanner.rb +57 -49
  89. data/lib/adlint/{c → cc1}/scope.rb +3 -3
  90. data/lib/adlint/{c → cc1}/seqp.rb +13 -5
  91. data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
  92. data/lib/adlint/{c → cc1}/type.rb +1498 -1479
  93. data/lib/adlint/{c → cc1}/util.rb +20 -12
  94. data/lib/adlint/{c → cc1}/value.rb +699 -642
  95. data/lib/adlint/code.rb +163 -164
  96. data/lib/adlint/cpp.rb +2 -2
  97. data/lib/adlint/cpp/asm.rb +13 -14
  98. data/lib/adlint/cpp/constexpr.rb +42 -38
  99. data/lib/adlint/cpp/constexpr.y +44 -40
  100. data/lib/adlint/cpp/eval.rb +435 -435
  101. data/lib/adlint/cpp/lexer.rb +343 -340
  102. data/lib/adlint/cpp/macro.rb +188 -190
  103. data/lib/adlint/cpp/phase.rb +66 -45
  104. data/lib/adlint/cpp/scanner.rb +14 -17
  105. data/lib/adlint/cpp/source.rb +49 -55
  106. data/lib/adlint/cpp/subst.rb +65 -65
  107. data/lib/adlint/cpp/syntax.rb +155 -275
  108. data/lib/adlint/cpp/util.rb +22 -19
  109. data/lib/adlint/driver.rb +86 -93
  110. data/lib/adlint/error.rb +33 -52
  111. data/lib/adlint/exam.rb +158 -24
  112. data/lib/adlint/exam/c_builtin.rb +7 -7
  113. data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
  114. data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
  115. data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
  116. data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
  117. data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
  118. data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
  119. data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
  120. data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
  121. data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
  122. data/lib/adlint/lang.rb +25 -25
  123. data/lib/adlint/ld.rb +2 -2
  124. data/lib/adlint/ld/object.rb +220 -188
  125. data/lib/adlint/ld/phase.rb +94 -63
  126. data/lib/adlint/ld/typedef.rb +22 -11
  127. data/lib/adlint/ld/util.rb +43 -35
  128. data/lib/adlint/lexer.rb +59 -56
  129. data/lib/adlint/location.rb +140 -0
  130. data/lib/adlint/memo.rb +157 -0
  131. data/lib/adlint/message.rb +207 -156
  132. data/lib/adlint/metric.rb +139 -217
  133. data/lib/adlint/monitor.rb +45 -43
  134. data/lib/adlint/phase.rb +56 -29
  135. data/lib/adlint/prelude.rb +66 -54
  136. data/lib/adlint/report.rb +253 -332
  137. data/lib/adlint/source.rb +26 -27
  138. data/lib/adlint/supp.rb +131 -0
  139. data/lib/adlint/symbol.rb +14 -16
  140. data/lib/adlint/token.rb +19 -91
  141. data/lib/adlint/traits.rb +242 -226
  142. data/lib/adlint/util.rb +116 -205
  143. data/lib/adlint/version.rb +8 -8
  144. data/share/HEADER +2 -2
  145. data/share/doc/developers_guide_ja.html +148 -19
  146. data/share/doc/developers_guide_ja.texi +141 -11
  147. data/share/doc/samples/GNUmakefile +1 -1
  148. data/share/doc/samples/adlint_traits.yml +45 -36
  149. data/share/doc/users_guide_en.html +1321 -1252
  150. data/share/doc/users_guide_en.texi +475 -408
  151. data/share/doc/users_guide_ja.html +1932 -1878
  152. data/share/doc/users_guide_ja.texi +324 -273
  153. data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
  154. data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
  155. data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
  156. data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
  157. data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
  158. data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
  159. data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
  160. data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
  161. data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
  162. data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
  163. data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
  164. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
  165. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
  166. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
  167. data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
  168. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
  169. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
  170. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
  171. data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
  172. data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
  173. data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
  174. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
  175. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
  176. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
  177. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
  178. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
  179. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
  180. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
  181. data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
  182. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
  183. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
  184. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
  185. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
  186. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
  187. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
  188. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
  189. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
  190. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
  191. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
  192. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
  193. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
  194. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
  195. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
  196. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
  197. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
  198. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
  199. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
  200. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
  201. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
  202. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
  203. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
  204. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
  205. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
  206. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
  207. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
  208. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
  209. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
  210. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
  211. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
  212. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
  213. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
  214. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
  215. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
  216. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
  217. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
  218. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
  219. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
  220. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
  221. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
  222. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
  223. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
  224. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
  225. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
  226. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
  227. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
  228. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
  229. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
  230. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
  231. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
  232. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
  233. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
  234. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
  235. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
  236. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
  237. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
  238. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
  239. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
  240. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
  241. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
  242. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
  243. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
  244. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
  245. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
  246. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
  247. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
  248. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
  249. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
  250. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
  251. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
  252. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
  253. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
  254. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
  255. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
  256. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
  257. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
  258. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
  259. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
  260. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
  261. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
  262. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
  263. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
  264. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
  265. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
  266. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
  267. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
  268. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
  269. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
  270. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
  271. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
  272. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
  273. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
  274. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
  275. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
  276. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
  277. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
  278. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
  279. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
  280. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
  281. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
  282. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
  283. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
  284. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
  285. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
  286. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
  287. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
  288. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
  289. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
  290. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
  291. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
  292. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
  293. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
  294. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
  295. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
  296. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
  297. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
  298. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
  299. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
  300. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
  301. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
  302. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
  303. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
  304. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
  305. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
  306. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
  307. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
  308. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
  309. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
  310. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
  311. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
  312. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
  313. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
  314. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
  315. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
  316. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
  317. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
  318. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
  319. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
  320. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
  321. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
  322. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
  323. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
  324. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
  325. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
  326. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
  327. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
  328. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
  329. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
  330. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
  331. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
  332. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
  333. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
  334. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
  335. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
  336. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
  337. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
  338. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
  339. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
  340. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
  341. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
  342. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
  343. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
  344. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
  345. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
  346. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
  347. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
  348. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
  349. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
  350. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
  351. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
  352. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
  353. data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
  354. data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
  355. data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
  356. data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
  357. data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
  358. data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
  359. data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
  360. data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
  361. data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
  362. data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
  363. data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
  364. data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
  365. data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
  366. data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
  367. data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
  368. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
  369. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
  370. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
  371. data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
  372. data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
  373. data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
  374. data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
  375. data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
  376. data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
  377. data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
  378. data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
  379. data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
  380. data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
  381. data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
  382. data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
  383. data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
  384. data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
  385. data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
  386. data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
  387. data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
  388. data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
  389. data/spec/conf.d/default_traits.yml +38 -37
  390. data/spec/conf.d/empty_cinit.h +1 -1
  391. data/spec/conf.d/empty_pinit.h +1 -1
  392. data/spec/conf.d/project/foo.c +0 -0
  393. data/spec/spec_helper.rb +2 -2
  394. metadata +60 -40
  395. data/lib/adlint/c/domain.rb +0 -7931
  396. data/lib/adlint/c/lexer.rb +0 -252
  397. data/lib/adlint/c/phase.rb +0 -135
  398. data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
  399. data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
  400. data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
  401. data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -1,7 +1,7 @@
1
1
  # Code checkings (cpp-phase) of adlint-exam-c_builtin package.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -31,6 +31,7 @@
31
31
 
32
32
  require "adlint/exam"
33
33
  require "adlint/report"
34
+ require "adlint/traits"
34
35
  require "adlint/cpp/phase"
35
36
  require "adlint/cpp/util"
36
37
 
@@ -43,20 +44,20 @@ module CBuiltin #:nodoc:
43
44
 
44
45
  # NOTE: W0001 may be duplicative when the same header which has the deeply
45
46
  # grouped expression is included twice or more.
46
- ensure_uniqueness_of :W0001
47
+ mark_as_unique
47
48
 
48
- def initialize(context)
49
+ def initialize(phase_ctxt)
49
50
  super
50
- visitor = context[:cpp_visitor]
51
- visitor.enter_grouped_expression += method(:enter_grouped_expression)
52
- visitor.leave_grouped_expression += method(:leave_grouped_expression)
51
+ visitor = phase_ctxt[:cpp_visitor]
52
+ visitor.enter_grouped_expression += T(:enter_grouped_expression)
53
+ visitor.leave_grouped_expression += T(:leave_grouped_expression)
53
54
  @group_depth = 0
54
55
  end
55
56
 
56
57
  private
57
58
  def enter_grouped_expression(node)
58
59
  @group_depth += 1
59
- W(:W0001, node.location) if @group_depth == 32
60
+ W(node.location) if @group_depth == 32
60
61
  end
61
62
 
62
63
  def leave_grouped_expression(node)
@@ -67,32 +68,32 @@ module CBuiltin #:nodoc:
67
68
  class W0025 < PassiveCodeCheck
68
69
  def_registrant_phase Cpp::Prepare2Phase
69
70
 
70
- def initialize(context)
71
+ def initialize(phase_ctxt)
71
72
  super
72
- interp = context[:cpp_interpreter]
73
- interp.on_user_header_included += method(:check_user_include)
74
- interp.on_system_header_included += method(:check_system_include)
75
- @user_header_fpaths = Set.new
76
- @system_header_fpaths = Set.new
73
+ interp = phase_ctxt[:cpp_interpreter]
74
+ interp.on_user_header_included += T(:check_user_include)
75
+ interp.on_system_header_included += T(:check_system_include)
76
+ @usr_header_fpaths = Set.new
77
+ @sys_header_fpaths = Set.new
77
78
  end
78
79
 
79
80
  private
80
- def check_user_include(user_include_line, user_header)
81
- if @user_header_fpaths.include?(user_header.fpath)
82
- W(:W0025, user_include_line.location, user_include_line.fpath)
81
+ def check_user_include(usr_include_line, usr_header)
82
+ if @usr_header_fpaths.include?(usr_header.fpath)
83
+ W(usr_include_line.location, usr_include_line.fpath)
83
84
  else
84
- if user_include_line.include_depth == 1
85
- @user_header_fpaths.add(user_header.fpath)
85
+ if usr_include_line.include_depth == 1
86
+ @usr_header_fpaths.add(usr_header.fpath)
86
87
  end
87
88
  end
88
89
  end
89
90
 
90
- def check_system_include(system_include_line, system_header)
91
- if @system_header_fpaths.include?(system_header.fpath)
92
- W(:W0025, system_include_line.location, system_include_line.fpath)
91
+ def check_system_include(sys_include_line, sys_header)
92
+ if @sys_header_fpaths.include?(sys_header.fpath)
93
+ W(sys_include_line.location, sys_include_line.fpath)
93
94
  else
94
- if system_include_line.include_depth == 1
95
- @system_header_fpaths.add(system_header.fpath)
95
+ if sys_include_line.include_depth == 1
96
+ @sys_header_fpaths.add(sys_header.fpath)
96
97
  end
97
98
  end
98
99
  end
@@ -101,32 +102,32 @@ module CBuiltin #:nodoc:
101
102
  class W0026 < PassiveCodeCheck
102
103
  def_registrant_phase Cpp::Prepare2Phase
103
104
 
104
- def initialize(context)
105
+ def initialize(phase_ctxt)
105
106
  super
106
- interp = context[:cpp_interpreter]
107
- interp.on_user_header_included += method(:check_user_include)
108
- interp.on_system_header_included += method(:check_system_include)
109
- @user_header_fpaths = Set.new
110
- @system_header_fpaths = Set.new
107
+ interp = phase_ctxt[:cpp_interpreter]
108
+ interp.on_user_header_included += T(:check_user_include)
109
+ interp.on_system_header_included += T(:check_system_include)
110
+ @usr_header_fpaths = Set.new
111
+ @sys_header_fpaths = Set.new
111
112
  end
112
113
 
113
114
  private
114
- def check_user_include(user_include_line, user_header)
115
- if @user_header_fpaths.include?(user_header.fpath)
116
- W(:W0026, user_include_line.location, user_include_line.fpath)
115
+ def check_user_include(usr_include_line, usr_header)
116
+ if @usr_header_fpaths.include?(usr_header.fpath)
117
+ W(usr_include_line.location, usr_include_line.fpath)
117
118
  else
118
- if user_include_line.include_depth > 1
119
- @user_header_fpaths.add(user_header.fpath)
119
+ if usr_include_line.include_depth > 1
120
+ @usr_header_fpaths.add(usr_header.fpath)
120
121
  end
121
122
  end
122
123
  end
123
124
 
124
- def check_system_include(system_include_line, system_header)
125
- if @system_header_fpaths.include?(system_header.fpath)
126
- W(:W0026, system_include_line.location, system_include_line.fpath)
125
+ def check_system_include(sys_include_line, sys_header)
126
+ if @sys_header_fpaths.include?(sys_header.fpath)
127
+ W(sys_include_line.location, sys_include_line.fpath)
127
128
  else
128
- if system_include_line.include_depth > 1
129
- @system_header_fpaths.add(system_header.fpath)
129
+ if sys_include_line.include_depth > 1
130
+ @sys_header_fpaths.add(sys_header.fpath)
130
131
  end
131
132
  end
132
133
  end
@@ -135,16 +136,16 @@ module CBuiltin #:nodoc:
135
136
  class W0053 < PassiveCodeCheck
136
137
  def_registrant_phase Cpp::Prepare2Phase
137
138
 
138
- def initialize(context)
139
+ def initialize(phase_ctxt)
139
140
  super
140
- interp = context[:cpp_interpreter]
141
- interp.on_user_header_included += method(:check_user_include)
141
+ interp = phase_ctxt[:cpp_interpreter]
142
+ interp.on_user_header_included += T(:check_user_include)
142
143
  end
143
144
 
144
145
  private
145
- def check_user_include(user_include_line, user_header)
146
- if user_include_line.include_depth == 7
147
- W(:W0053, user_include_line.location, user_header.fpath)
146
+ def check_user_include(usr_include_line, usr_header)
147
+ if usr_include_line.include_depth == 7
148
+ W(usr_include_line.location, usr_header.fpath)
148
149
  end
149
150
  end
150
151
  end
@@ -152,21 +153,21 @@ module CBuiltin #:nodoc:
152
153
  class W0054 < PassiveCodeCheck
153
154
  def_registrant_phase Cpp::Prepare2Phase
154
155
 
155
- def initialize(context)
156
+ def initialize(phase_ctxt)
156
157
  super
157
- visitor = context[:cpp_visitor]
158
- visitor.enter_if_section += method(:enter_if_section)
159
- visitor.leave_if_section += method(:leave_if_section)
158
+ visitor = phase_ctxt[:cpp_visitor]
159
+ visitor.enter_if_section += T(:enter_if_section)
160
+ visitor.leave_if_section += T(:leave_if_section)
160
161
  @if_depth = 0
161
162
  end
162
163
 
163
164
  private
164
165
  def enter_if_section(node)
165
166
  @if_depth += 1
166
- W(:W0054, node.location) if @if_depth == 9
167
+ W(node.location) if @if_depth == 9
167
168
  end
168
169
 
169
- def leave_if_section(node)
170
+ def leave_if_section(*)
170
171
  @if_depth -= 1
171
172
  end
172
173
  end
@@ -174,33 +175,45 @@ module CBuiltin #:nodoc:
174
175
  class W0055 < PassiveCodeCheck
175
176
  def_registrant_phase Cpp::Prepare2Phase
176
177
 
177
- def initialize(context)
178
+ def initialize(phase_ctxt)
178
179
  super
179
- interp = context[:cpp_interpreter]
180
- interp.on_object_like_macro_defined += method(:check)
181
- interp.on_function_like_macro_defined += method(:check)
182
- interp.on_va_function_like_macro_defined += method(:check)
180
+ interp = phase_ctxt[:cpp_interpreter]
181
+ interp.on_object_like_macro_defined += T(:check)
182
+ interp.on_function_like_macro_defined += T(:check)
183
+ interp.on_va_function_like_macro_defined += T(:check)
183
184
  @macro_num = 0
184
185
  end
185
186
 
186
187
  private
187
- def check(define_line, macro)
188
+ def check(define_line, *)
188
189
  unless in_initial_header?(define_line)
189
190
  @macro_num += 1
190
- W(:W0055, define_line.location) if @macro_num == 1025
191
+ W(define_line.location) if @macro_num == 1025
191
192
  end
192
193
  end
193
194
 
194
195
  def in_initial_header?(node)
195
- case
196
- when pinit_fpath = Traits.instance.of_project.initial_header
197
- File.identical?(node.location.fpath, pinit_fpath)
198
- when cinit_fpath = Traits.instance.of_compiler.initial_header
199
- File.identical?(node.location.fpath, cinit_fpath)
196
+ node.location.fpath.identical?(pinit_fpath) ||
197
+ node.location.fpath.identical?(cinit_fpath)
198
+ end
199
+
200
+ def pinit_fpath
201
+ if fpath = traits.of_project.initial_header
202
+ Pathname.new(fpath)
200
203
  else
201
- false
204
+ nil
202
205
  end
203
206
  end
207
+ memoize :pinit_fpath
208
+
209
+ def cinit_fpath
210
+ if fpath = traits.of_compiler.initial_header
211
+ Pathname.new(fpath)
212
+ else
213
+ nil
214
+ end
215
+ end
216
+ memoize :cinit_fpath
204
217
  end
205
218
 
206
219
  class W0056 < PassiveCodeCheck
@@ -208,20 +221,18 @@ module CBuiltin #:nodoc:
208
221
 
209
222
  # NOTE: W0056 may be duplicative when the same header which has macro
210
223
  # definition with too many parameters is included twice or more.
211
- ensure_uniqueness_of :W0056
224
+ mark_as_unique
212
225
 
213
- def initialize(context)
226
+ def initialize(phase_ctxt)
214
227
  super
215
- interp = context[:cpp_interpreter]
216
- interp.on_function_like_macro_defined += method(:check)
217
- interp.on_va_function_like_macro_defined += method(:check)
228
+ interp = phase_ctxt[:cpp_interpreter]
229
+ interp.on_function_like_macro_defined += T(:check)
230
+ interp.on_va_function_like_macro_defined += T(:check)
218
231
  end
219
232
 
220
233
  private
221
234
  def check(define_line, macro)
222
- if macro.parameter_names.size > 31
223
- W(:W0056, define_line.location)
224
- end
235
+ W(define_line.location) if macro.parameter_names.size > 31
225
236
  end
226
237
  end
227
238
 
@@ -230,19 +241,17 @@ module CBuiltin #:nodoc:
230
241
 
231
242
  # NOTE: W0057 may be duplicative when the same header which has macro call
232
243
  # with too many arguments is included twice or more.
233
- ensure_uniqueness_of :W0057
244
+ mark_as_unique
234
245
 
235
- def initialize(context)
246
+ def initialize(phase_ctxt)
236
247
  super
237
- macro_table = context[:cpp_macro_table]
238
- macro_table.on_function_like_macro_replacement += method(:check)
248
+ macro_table = phase_ctxt[:cpp_macro_table]
249
+ macro_table.on_function_like_macro_replacement += T(:check)
239
250
  end
240
251
 
241
252
  private
242
- def check(macro, replacing_tokens, *)
243
- if macro.parameter_names.size > 31
244
- W(:W0057, replacing_tokens.first.location)
245
- end
253
+ def check(macro, repl_toks, *)
254
+ W(repl_toks.first.location) if macro.parameter_names.size > 31
246
255
  end
247
256
  end
248
257
 
@@ -251,12 +260,20 @@ module CBuiltin #:nodoc:
251
260
 
252
261
  # NOTE: W0059 may be duplicative when the same header which has carriage
253
262
  # return at end of lines is included twice or more.
254
- ensure_uniqueness_of :W0059
263
+ mark_as_unique
264
+
265
+ # NOTE: W0059 may be detected before evaluating the annotation for message
266
+ # suppression.
267
+ mark_as_deferred
255
268
 
256
- def initialize(context)
269
+ def initialize(phase_ctxt)
257
270
  super
258
- context[:cpp_interpreter].on_cr_at_eol_found +=
259
- lambda { |location| W(:W0059, location) }
271
+ phase_ctxt[:cpp_interpreter].on_cr_at_eol_found += M(:check)
272
+ end
273
+
274
+ private
275
+ def check(loc)
276
+ W(loc) if loc.in_analysis_target?(traits)
260
277
  end
261
278
  end
262
279
 
@@ -265,12 +282,20 @@ module CBuiltin #:nodoc:
265
282
 
266
283
  # NOTE: W0060 may be duplicative when the same header which has the
267
284
  # end-of-file mark is included twice or more.
268
- ensure_uniqueness_of :W0060
285
+ mark_as_unique
269
286
 
270
- def initialize(context)
287
+ # NOTE: W0060 may be detected before evaluating the annotation for message
288
+ # suppression.
289
+ mark_as_deferred
290
+
291
+ def initialize(phase_ctxt)
271
292
  super
272
- context[:cpp_interpreter].on_eof_mark_at_eof_found +=
273
- lambda { |location| W(:W0060, location) }
293
+ phase_ctxt[:cpp_interpreter].on_eof_mark_at_eof_found += M(:check)
294
+ end
295
+
296
+ private
297
+ def check(loc)
298
+ W(loc) if loc.in_analysis_target?(traits)
274
299
  end
275
300
  end
276
301
 
@@ -280,21 +305,24 @@ module CBuiltin #:nodoc:
280
305
  # NOTE: W0061 may be duplicative when the same header which has the token
281
306
  # sequence of the compiler specific extension is included twice or
282
307
  # more.
283
- ensure_uniqueness_of :W0061
308
+ mark_as_unique
284
309
 
285
- def initialize(context)
310
+ def initialize(phase_ctxt)
286
311
  super
287
- context[:c_source].on_language_extension += method(:check)
312
+ phase_ctxt[:cc1_source].on_language_extension += M(:check)
288
313
  end
289
314
 
290
315
  private
291
- def check(matched_tokens)
292
- W(:W0061, matched_tokens.first.location, tokens_to_str(matched_tokens))
316
+ def check(matched_toks)
317
+ head_loc = matched_toks.first.location
318
+ if head_loc.in_analysis_target?(traits)
319
+ W(head_loc, tokens_to_str(matched_toks))
320
+ end
293
321
  end
294
322
 
295
- def tokens_to_str(tokens)
296
- tokens.map { |token|
297
- token.type == :NEW_LINE ? nil : token.value
323
+ def tokens_to_str(toks)
324
+ toks.map { |tok|
325
+ tok.type == :NEW_LINE ? nil : tok.value
298
326
  }.compact.join(" ")
299
327
  end
300
328
  end
@@ -304,12 +332,16 @@ module CBuiltin #:nodoc:
304
332
 
305
333
  # NOTE: W0069 may be duplicative when the same header which has the nested
306
334
  # block comment is included twice or more.
307
- ensure_uniqueness_of :W0069
335
+ mark_as_unique
308
336
 
309
- def initialize(context)
337
+ def initialize(phase_ctxt)
310
338
  super
311
- context[:cpp_interpreter].on_nested_block_comment_found +=
312
- lambda { |location| W(:W0069, location) }
339
+ phase_ctxt[:cpp_interpreter].on_nested_block_comment_found += M(:check)
340
+ end
341
+
342
+ private
343
+ def check(loc)
344
+ W(loc) if loc.in_analysis_target?(traits)
313
345
  end
314
346
  end
315
347
 
@@ -319,25 +351,25 @@ module CBuiltin #:nodoc:
319
351
  # NOTE: W0072 may be duplicative when the same header which has non
320
352
  # basic-source-character in the #include directive is included twice
321
353
  # or more.
322
- ensure_uniqueness_of :W0072
354
+ mark_as_unique
323
355
 
324
- def initialize(context)
356
+ def initialize(phase_ctxt)
325
357
  super
326
- visitor = context[:cpp_visitor]
327
- visitor.enter_user_include_line += method(:check_user_include_line)
328
- visitor.enter_system_include_line += method(:check_system_include_line)
358
+ visitor = phase_ctxt[:cpp_visitor]
359
+ visitor.enter_user_include_line += T(:check_user_include_line)
360
+ visitor.enter_system_include_line += T(:check_system_include_line)
329
361
  end
330
362
 
331
363
  private
332
364
  def check_user_include_line(node)
333
365
  unless Cpp::BasicSourceCharacterSet.include?(node.header_name.value)
334
- W(:W0072, node.header_name.location)
366
+ W(node.header_name.location)
335
367
  end
336
368
  end
337
369
 
338
370
  def check_system_include_line(node)
339
371
  unless Cpp::BasicSourceCharacterSet.include?(node.header_name.value)
340
- W(:W0072, node.header_name.location)
372
+ W(node.header_name.location)
341
373
  end
342
374
  end
343
375
  end
@@ -347,16 +379,16 @@ module CBuiltin #:nodoc:
347
379
 
348
380
  # NOTE: W0073 may be duplicative when the same header without the
349
381
  # include-guard is included twice or more.
350
- ensure_uniqueness_of :W0073
382
+ mark_as_unique
351
383
 
352
- def initialize(context)
384
+ def initialize(phase_ctxt)
353
385
  super
354
- visitor = context[:cpp_visitor]
355
- visitor.enter_user_include_line += method(:enter_include_line)
356
- visitor.enter_system_include_line += method(:enter_include_line)
357
- visitor.enter_text_line += method(:enter_text_line)
358
- visitor.enter_if_section += method(:enter_if_section)
359
- @main_fpath = context[:sources].first.fpath
386
+ visitor = phase_ctxt[:cpp_visitor]
387
+ visitor.enter_user_include_line += T(:enter_include_line)
388
+ visitor.enter_system_include_line += T(:enter_include_line)
389
+ visitor.enter_text_line += T(:enter_text_line)
390
+ visitor.enter_if_section += T(:enter_if_section)
391
+ @main_fpath = phase_ctxt[:sources].first.fpath
360
392
  @last_fpath = nil
361
393
  @enclosed_by_if_section = false
362
394
  @warned_files = Set.new
@@ -372,7 +404,7 @@ module CBuiltin #:nodoc:
372
404
  return if in_initial_header?(node) || in_main_file?(node)
373
405
 
374
406
  unless @enclosed_by_if_section || in_warned_file?(node)
375
- W(:W0073, node.location)
407
+ W(node.location)
376
408
  @warned_files.add(node.location.fpath)
377
409
  end
378
410
  end
@@ -388,7 +420,7 @@ module CBuiltin #:nodoc:
388
420
  end
389
421
 
390
422
  unless @enclosed_by_if_section || in_warned_file?(node)
391
- W(:W0073, node.location)
423
+ W(node.location)
392
424
  @warned_files.add(node.location.fpath)
393
425
  end
394
426
  end
@@ -403,23 +435,35 @@ module CBuiltin #:nodoc:
403
435
  end
404
436
 
405
437
  def in_main_file?(node)
406
- File.identical?(node.location.fpath, @main_fpath)
438
+ node.location.fpath == @main_fpath
407
439
  end
408
440
 
409
441
  def in_initial_header?(node)
410
- case
411
- when pinit_fpath = Traits.instance.of_project.initial_header
412
- File.identical?(node.location.fpath, pinit_fpath)
413
- when cinit_fpath = Traits.instance.of_compiler.initial_header
414
- File.identical?(node.location.fpath, cinit_fpath)
415
- else
416
- false
417
- end
442
+ node.location.fpath.identical?(pinit_fpath) ||
443
+ node.location.fpath.identical?(cinit_fpath)
418
444
  end
419
445
 
420
446
  def in_warned_file?(node)
421
447
  @warned_files.include?(node.location.fpath)
422
448
  end
449
+
450
+ def pinit_fpath
451
+ if fpath = traits.of_project.initial_header
452
+ Pathname.new(fpath)
453
+ else
454
+ nil
455
+ end
456
+ end
457
+ memoize :pinit_fpath
458
+
459
+ def cinit_fpath
460
+ if fpath = traits.of_compiler.initial_header
461
+ Pathname.new(fpath)
462
+ else
463
+ nil
464
+ end
465
+ end
466
+ memoize :cinit_fpath
423
467
  end
424
468
 
425
469
  class W0442 < PassiveCodeCheck
@@ -427,29 +471,18 @@ module CBuiltin #:nodoc:
427
471
 
428
472
  # NOTE: W0442 may be duplicative when the same header which has
429
473
  # function-like macro definitions is included twice or more.
430
- ensure_uniqueness_of :W0442
474
+ mark_as_unique
431
475
 
432
- def initialize(context)
476
+ def initialize(phase_ctxt)
433
477
  super
434
- interp = context[:cpp_interpreter]
435
- interp.on_function_like_macro_defined += method(:check)
436
- interp.on_va_function_like_macro_defined += method(:check)
478
+ interp = phase_ctxt[:cpp_interpreter]
479
+ interp.on_function_like_macro_defined += T(:check)
480
+ interp.on_va_function_like_macro_defined += T(:check)
437
481
  end
438
482
 
439
483
  private
440
- def check(define_line, macro)
441
- W(:W0442, define_line.location) unless in_initial_header?(define_line)
442
- end
443
-
444
- def in_initial_header?(node)
445
- case
446
- when pinit_fpath = Traits.instance.of_project.initial_header
447
- File.identical?(node.location.fpath, pinit_fpath)
448
- when cinit_fpath = Traits.instance.of_compiler.initial_header
449
- File.identical?(node.location.fpath, cinit_fpath)
450
- else
451
- false
452
- end
484
+ def check(define_line, *)
485
+ W(define_line.location)
453
486
  end
454
487
  end
455
488
 
@@ -459,42 +492,30 @@ module CBuiltin #:nodoc:
459
492
  # NOTE: W0443 may be duplicative when the same header which has
460
493
  # functionizable function-like macro definitions is included twice or
461
494
  # more.
462
- ensure_uniqueness_of :W0443
495
+ mark_as_unique
463
496
 
464
- def initialize(context)
497
+ def initialize(phase_ctxt)
465
498
  super
466
- visitor = context[:cpp_visitor]
467
- visitor.enter_function_like_define_line += method(:check)
468
- visitor.enter_va_function_like_define_line += method(:check)
499
+ visitor = phase_ctxt[:cpp_visitor]
500
+ visitor.enter_function_like_define_line += T(:check)
501
+ visitor.enter_va_function_like_define_line += T(:check)
469
502
  end
470
503
 
471
504
  private
472
505
  def check(node)
473
- return if in_initial_header?(node)
474
506
  return unless node.identifier_list
475
507
 
476
- if replacement_list = node.replacement_list
477
- should_be_function = replacement_list.tokens.all? { |pp_token|
478
- if keyword_or_punctuator?(pp_token)
508
+ if repl_lsit = node.replacement_list
509
+ should_be_function = repl_lsit.tokens.all? { |pp_tok|
510
+ if keyword_or_punctuator?(pp_tok)
479
511
  false
480
- elsif type_specifier_or_type_qualifier?(pp_token)
512
+ elsif type_specifier_or_type_qualifier?(pp_tok)
481
513
  false
482
514
  else
483
515
  true
484
516
  end
485
517
  }
486
- W(:W0443, node.location) if should_be_function
487
- end
488
- end
489
-
490
- def in_initial_header?(node)
491
- case
492
- when pinit_fpath = Traits.instance.of_project.initial_header
493
- File.identical?(node.location.fpath, pinit_fpath)
494
- when cinit_fpath = Traits.instance.of_compiler.initial_header
495
- File.identical?(node.location.fpath, cinit_fpath)
496
- else
497
- false
518
+ W(node.location) if should_be_function
498
519
  end
499
520
  end
500
521
 
@@ -508,16 +529,16 @@ module CBuiltin #:nodoc:
508
529
  ].to_set.freeze
509
530
  private_constant :KEYWORDS
510
531
 
511
- def keyword_or_punctuator?(pp_token)
512
- pp_token.value == "#" || pp_token.value == "##" ||
513
- pp_token.value == "{" || pp_token.value == "}" ||
514
- pp_token.value == ";" || KEYWORDS.include?(pp_token.value)
532
+ def keyword_or_punctuator?(pp_tok)
533
+ pp_tok.value == "#" || pp_tok.value == "##" ||
534
+ pp_tok.value == "{" || pp_tok.value == "}" ||
535
+ pp_tok.value == ";" || KEYWORDS.include?(pp_tok.value)
515
536
  end
516
537
 
517
- def type_specifier_or_type_qualifier?(pp_token)
518
- pp_token.value == "const" || pp_token.value == "volatile" ||
519
- pp_token.value == "restrict" ||
520
- @context[:c_type_table].all_type_names.include?(pp_token.value)
538
+ def type_specifier_or_type_qualifier?(pp_tok)
539
+ pp_tok.value == "const" || pp_tok.value == "volatile" ||
540
+ pp_tok.value == "restrict" ||
541
+ @phase_ctxt[:cc1_type_table].all_type_names.include?(pp_tok.value)
521
542
  end
522
543
  end
523
544
 
@@ -527,23 +548,23 @@ module CBuiltin #:nodoc:
527
548
  # NOTE: W0444 may be duplicative when the same header which has the
528
549
  # function-like macro definition with `#' and `##' operators is
529
550
  # included twice or more.
530
- ensure_uniqueness_of :W0444
551
+ mark_as_unique
531
552
 
532
- def initialize(context)
553
+ def initialize(phase_ctxt)
533
554
  super
534
- interp = context[:cpp_interpreter]
535
- interp.on_function_like_macro_defined += method(:check)
536
- interp.on_va_function_like_macro_defined += method(:check)
555
+ interp = phase_ctxt[:cpp_interpreter]
556
+ interp.on_function_like_macro_defined += T(:check)
557
+ interp.on_va_function_like_macro_defined += T(:check)
537
558
  end
538
559
 
539
560
  private
540
561
  def check(define_line, macro)
541
- if replacement_list = macro.replacement_list
562
+ if repl_list = macro.replacement_list
542
563
  sharp_op_num = 0
543
564
  sharpsharp_op_num = 0
544
565
 
545
- replacement_list.tokens.each do |pp_token|
546
- case pp_token.value
566
+ repl_list.tokens.each do |pp_tok|
567
+ case pp_tok.value
547
568
  when "#"
548
569
  sharp_op_num += 1
549
570
  when "##"
@@ -551,9 +572,7 @@ module CBuiltin #:nodoc:
551
572
  end
552
573
  end
553
574
 
554
- if sharp_op_num > 0 && sharpsharp_op_num > 0
555
- W(:W0444, define_line.location)
556
- end
575
+ W(define_line.location) if sharp_op_num > 0 && sharpsharp_op_num > 0
557
576
  end
558
577
  end
559
578
  end
@@ -564,29 +583,27 @@ module CBuiltin #:nodoc:
564
583
  # NOTE: W0445 may be duplicative when the same header which has the
565
584
  # function-like macro definition with two or more `##' operators is
566
585
  # included twice or more.
567
- ensure_uniqueness_of :W0445
586
+ mark_as_unique
568
587
 
569
- def initialize(context)
588
+ def initialize(phase_ctxt)
570
589
  super
571
- interp = context[:cpp_interpreter]
572
- interp.on_function_like_macro_defined += method(:check)
573
- interp.on_va_function_like_macro_defined += method(:check)
590
+ interp = phase_ctxt[:cpp_interpreter]
591
+ interp.on_function_like_macro_defined += T(:check)
592
+ interp.on_va_function_like_macro_defined += T(:check)
574
593
  end
575
594
 
576
595
  private
577
596
  def check(define_line, macro)
578
- if replacement_list = macro.replacement_list
597
+ if repl_list = macro.replacement_list
579
598
  sharpsharp_op_num = 0
580
599
 
581
- replacement_list.tokens.each do |pp_token|
582
- if pp_token.value == "##"
600
+ repl_list.tokens.each do |pp_tok|
601
+ if pp_tok.value == "##"
583
602
  sharpsharp_op_num += 1
584
603
  end
585
604
  end
586
605
 
587
- if sharpsharp_op_num > 1
588
- W(:W0445, define_line.location)
589
- end
606
+ W(define_line.location) if sharpsharp_op_num > 1
590
607
  end
591
608
  end
592
609
  end
@@ -597,24 +614,24 @@ module CBuiltin #:nodoc:
597
614
  # NOTE: W0477 may be duplicative when the same header which has the macro
598
615
  # definition with unbalanced grouping tokens is included twice or
599
616
  # more.
600
- ensure_uniqueness_of :W0477
617
+ mark_as_unique
601
618
 
602
- def initialize(context)
619
+ def initialize(phase_ctxt)
603
620
  super
604
- interp = context[:cpp_interpreter]
605
- interp.on_object_like_macro_defined += method(:check)
606
- interp.on_function_like_macro_defined += method(:check)
607
- interp.on_va_function_like_macro_defined += method(:check)
621
+ interp = phase_ctxt[:cpp_interpreter]
622
+ interp.on_object_like_macro_defined += T(:check)
623
+ interp.on_function_like_macro_defined += T(:check)
624
+ interp.on_va_function_like_macro_defined += T(:check)
608
625
  end
609
626
 
610
627
  private
611
628
  def check(define_line, macro)
612
- if replacement_list = macro.replacement_list
629
+ if repl_list = macro.replacement_list
613
630
  paren_count = 0
614
631
  brace_count = 0
615
632
  bracket_count = 0
616
- replacement_list.tokens.each do |pp_token|
617
- case pp_token.value
633
+ repl_list.tokens.each do |pp_tok|
634
+ case pp_tok.value
618
635
  when "("
619
636
  paren_count += 1
620
637
  when ")"
@@ -631,7 +648,7 @@ module CBuiltin #:nodoc:
631
648
  end
632
649
 
633
650
  unless paren_count == 0 && brace_count == 0 && bracket_count == 0
634
- W(:W0477, define_line.location)
651
+ W(define_line.location)
635
652
  end
636
653
  end
637
654
  end
@@ -642,27 +659,26 @@ module CBuiltin #:nodoc:
642
659
 
643
660
  # NOTE: W0478 may be duplicative when the same header which causes this
644
661
  # warning is included twice or more.
645
- ensure_uniqueness_of :W0478
662
+ mark_as_unique
646
663
 
647
- def initialize(context)
664
+ def initialize(phase_ctxt)
648
665
  super
649
- visitor = context[:cpp_visitor]
650
- visitor.enter_object_like_define_line += method(:check)
651
- visitor.enter_function_like_define_line += method(:check)
652
- visitor.enter_va_function_like_define_line += method(:check)
666
+ visitor = phase_ctxt[:cpp_visitor]
667
+ visitor.enter_object_like_define_line += T(:check)
668
+ visitor.enter_function_like_define_line += T(:check)
669
+ visitor.enter_va_function_like_define_line += T(:check)
653
670
  end
654
671
 
655
672
  private
656
673
  def check(node)
657
- replacement_list = node.replacement_list
658
- if replacement_list && replacement_list.tokens.size > 1
659
- unless replacement_list.may_represent_expression? ||
660
- replacement_list.may_represent_initializer? ||
661
- replacement_list.may_represent_block? ||
662
- replacement_list.may_represent_do_while_zero_idiom? ||
663
- replacement_list.may_represent_specifier_qualifier_list? ||
664
- replacement_list.may_represent_declaration_specifiers_head?
665
- W(:W0478, node.location)
674
+ if repl_list = node.replacement_list and repl_list.tokens.size > 1
675
+ unless repl_list.may_represent_expression? ||
676
+ repl_list.may_represent_initializer? ||
677
+ repl_list.may_represent_block? ||
678
+ repl_list.may_represent_do_while_zero_idiom? ||
679
+ repl_list.may_represent_specifier_qualifier_list? ||
680
+ repl_list.may_represent_declaration_specifiers_head?
681
+ W(node.location)
666
682
  end
667
683
  end
668
684
  end
@@ -673,19 +689,19 @@ module CBuiltin #:nodoc:
673
689
 
674
690
  # NOTE: W0479 may be duplicative when the same header which has
675
691
  # typedef-able macro definition is included twice or more.
676
- ensure_uniqueness_of :W0479
692
+ mark_as_unique
677
693
 
678
- def initialize(context)
694
+ def initialize(phase_ctxt)
679
695
  super
680
- visitor = context[:cpp_visitor]
681
- visitor.enter_object_like_define_line += method(:check)
696
+ visitor = phase_ctxt[:cpp_visitor]
697
+ visitor.enter_object_like_define_line += T(:check)
682
698
  end
683
699
 
684
700
  private
685
701
  def check(node)
686
- if replacement_list = node.replacement_list
687
- if replacement_list.may_represent_specifier_qualifier_list?
688
- W(:W0479, node.location)
702
+ if repl_list = node.replacement_list
703
+ if repl_list.may_represent_specifier_qualifier_list?
704
+ W(node.location)
689
705
  end
690
706
  end
691
707
  end
@@ -696,23 +712,22 @@ module CBuiltin #:nodoc:
696
712
 
697
713
  # NOTE: W0480 may be duplicative when the same header which causes this
698
714
  # warning is included twice or more.
699
- ensure_uniqueness_of :W0480
715
+ mark_as_unique
700
716
 
701
- def initialize(context)
717
+ def initialize(phase_ctxt)
702
718
  super
703
- visitor = context[:cpp_visitor]
704
- visitor.enter_object_like_define_line += method(:check)
705
- visitor.enter_function_like_define_line += method(:check)
706
- visitor.enter_va_function_like_define_line += method(:check)
719
+ visitor = phase_ctxt[:cpp_visitor]
720
+ visitor.enter_object_like_define_line += T(:check)
721
+ visitor.enter_function_like_define_line += T(:check)
722
+ visitor.enter_va_function_like_define_line += T(:check)
707
723
  end
708
724
 
709
725
  private
710
726
  def check(node)
711
- replacement_list = node.replacement_list
712
- if replacement_list and
713
- replacement_list.may_represent_punctuator? ||
714
- replacement_list.may_represent_controlling_keyword?
715
- W(:W0480, node.location)
727
+ if repl_list = node.replacement_list and
728
+ repl_list.may_represent_punctuator? ||
729
+ repl_list.may_represent_controlling_keyword?
730
+ W(node.location)
716
731
  end
717
732
  end
718
733
  end
@@ -722,21 +737,20 @@ module CBuiltin #:nodoc:
722
737
 
723
738
  # NOTE: W0481 may be duplicative when the same header which causes this
724
739
  # warning is included twice or more.
725
- ensure_uniqueness_of :W0481
740
+ mark_as_unique
726
741
 
727
- def initialize(context)
742
+ def initialize(phase_ctxt)
728
743
  super
729
- visitor = context[:cpp_visitor]
730
- visitor.enter_object_like_define_line += method(:check)
731
- visitor.enter_function_like_define_line += method(:check)
732
- visitor.enter_va_function_like_define_line += method(:check)
744
+ visitor = phase_ctxt[:cpp_visitor]
745
+ visitor.enter_object_like_define_line += T(:check)
746
+ visitor.enter_function_like_define_line += T(:check)
747
+ visitor.enter_va_function_like_define_line += T(:check)
733
748
  end
734
749
 
735
750
  private
736
751
  def check(node)
737
- replacement_list = node.replacement_list
738
- if replacement_list && replacement_list.may_represent_block?
739
- W(:W0481, node.location)
752
+ if repl_list = node.replacement_list and repl_list.may_represent_block?
753
+ W(node.location)
740
754
  end
741
755
  end
742
756
  end
@@ -746,26 +760,26 @@ module CBuiltin #:nodoc:
746
760
 
747
761
  # NOTE: W0482 may be duplicative when the same header which causes this
748
762
  # warning is included twice or more.
749
- ensure_uniqueness_of :W0482
763
+ mark_as_unique
750
764
 
751
- def initialize(context)
765
+ def initialize(phase_ctxt)
752
766
  super
753
- visitor = context[:cpp_visitor]
754
- visitor.enter_object_like_define_line += method(:check)
767
+ visitor = phase_ctxt[:cpp_visitor]
768
+ visitor.enter_object_like_define_line += T(:check)
755
769
  end
756
770
 
757
771
  private
758
772
  def check(node)
759
- if replacement_list = node.replacement_list
760
- return unless replacement_list.tokens.size == 1
761
- if type_specifier?(replacement_list.tokens.first)
762
- W(:W0482, node.location)
773
+ if repl_list = node.replacement_list
774
+ return unless repl_list.tokens.size == 1
775
+ if type_specifier?(repl_list.tokens.first)
776
+ W(node.location)
763
777
  end
764
778
  end
765
779
  end
766
780
 
767
- def type_specifier?(pp_token)
768
- case pp_token.value
781
+ def type_specifier?(pp_tok)
782
+ case pp_tok.value
769
783
  when "void", "char", "short", "int", "long", "float", "double"
770
784
  true
771
785
  when "signed", "unsigned"
@@ -783,19 +797,19 @@ module CBuiltin #:nodoc:
783
797
 
784
798
  # NOTE: W0483 may be duplicative when the same header which causes this
785
799
  # warning is included twice or more.
786
- ensure_uniqueness_of :W0483
800
+ mark_as_unique
787
801
 
788
- def initialize(context)
802
+ def initialize(phase_ctxt)
789
803
  super
790
- visitor = context[:cpp_visitor]
791
- visitor.enter_object_like_define_line += method(:check)
804
+ visitor = phase_ctxt[:cpp_visitor]
805
+ visitor.enter_object_like_define_line += T(:check)
792
806
  end
793
807
 
794
808
  private
795
809
  def check(node)
796
- if replacement_list = node.replacement_list
797
- if replacement_list.may_represent_declaration_specifiers_head?
798
- W(:W0483, node.location)
810
+ if repl_list = node.replacement_list
811
+ if repl_list.may_represent_declaration_specifiers_head?
812
+ W(node.location)
799
813
  end
800
814
  end
801
815
  end
@@ -806,12 +820,16 @@ module CBuiltin #:nodoc:
806
820
 
807
821
  # NOTE: W0511 may be duplicative when the same header which causes this
808
822
  # warning is included twice or more.
809
- ensure_uniqueness_of :W0511
823
+ mark_as_unique
810
824
 
811
- def initialize(context)
825
+ def initialize(phase_ctxt)
812
826
  super
813
- context[:cpp_interpreter].on_line_comment_found +=
814
- lambda { |comment, location| W(:W0511, location) }
827
+ phase_ctxt[:cpp_interpreter].on_line_comment_found += M(:check)
828
+ end
829
+
830
+ private
831
+ def check(*, loc)
832
+ W(loc) if loc.in_analysis_target?(traits)
815
833
  end
816
834
  end
817
835
 
@@ -820,21 +838,21 @@ module CBuiltin #:nodoc:
820
838
 
821
839
  # NOTE: W0528 may be duplicative when the same header which causes this
822
840
  # warning is included twice or more.
823
- ensure_uniqueness_of :W0528
841
+ mark_as_unique
824
842
 
825
- def initialize(context)
843
+ def initialize(phase_ctxt)
826
844
  super
827
- interp = context[:cpp_interpreter]
828
- interp.on_object_like_macro_defined += method(:check)
845
+ interp = phase_ctxt[:cpp_interpreter]
846
+ interp.on_object_like_macro_defined += T(:check)
829
847
  end
830
848
 
831
849
  private
832
- def check(define_line, macro)
833
- if replacement_list = macro.replacement_list
834
- octal_token = replacement_list.tokens.find { |pp_token|
835
- pp_token.value =~ /\A0[0-9]+[UL]*\z/i
850
+ def check(*, macro)
851
+ if repl_list = macro.replacement_list
852
+ octal_tok = repl_list.tokens.find { |pp_tok|
853
+ pp_tok.value =~ /\A0[0-9]+[UL]*\z/i
836
854
  }
837
- W(:W0528, octal_token.location) if octal_token
855
+ W(octal_tok.location) if octal_tok
838
856
  end
839
857
  end
840
858
  end
@@ -844,17 +862,18 @@ module CBuiltin #:nodoc:
844
862
 
845
863
  # NOTE: W0541 may be duplicative when the same header which causes this
846
864
  # warning is included twice or more.
847
- ensure_uniqueness_of :W0541
865
+ mark_as_unique
848
866
 
849
- def initialize(context)
867
+ def initialize(phase_ctxt)
850
868
  super
851
- context[:c_source].on_inline_assembly += method(:check)
869
+ phase_ctxt[:cc1_source].on_inline_assembly += M(:check)
852
870
  end
853
871
 
854
872
  private
855
- def check(asm_tokens)
856
- unless asm_tokens.any? { |token| token.replaced? }
857
- W(:W0541, asm_tokens.first.location)
873
+ def check(asm_toks)
874
+ head_loc = asm_toks.first.location
875
+ if head_loc.in_analysis_target?(traits)
876
+ W(head_loc) unless asm_toks.any? { |tok| tok.replaced? }
858
877
  end
859
878
  end
860
879
  end
@@ -864,36 +883,36 @@ module CBuiltin #:nodoc:
864
883
 
865
884
  # NOTE: W0549 may be duplicative when the same header which causes this
866
885
  # warning is included twice or more.
867
- ensure_uniqueness_of :W0549
886
+ mark_as_unique
868
887
 
869
- def initialize(context)
888
+ def initialize(phase_ctxt)
870
889
  super
871
- interp = context[:cpp_interpreter]
872
- interp.on_function_like_macro_defined += method(:check)
873
- interp.on_va_function_like_macro_defined += method(:check)
890
+ interp = phase_ctxt[:cpp_interpreter]
891
+ interp.on_function_like_macro_defined += T(:check)
892
+ interp.on_va_function_like_macro_defined += T(:check)
874
893
  end
875
894
 
876
895
  private
877
- def check(define_line, macro)
896
+ def check(*, macro)
878
897
  return unless macro.replacement_list
879
898
 
880
899
  macro.parameter_names.each do |name|
881
- macro.replacement_list.tokens.each_with_index do |pp_token, index|
882
- next unless pp_token.value == name
900
+ macro.replacement_list.tokens.each_with_index do |pp_tok, idx|
901
+ next unless pp_tok.value == name
883
902
 
884
- prev_token = macro.replacement_list.tokens[[index - 1, 0].max]
885
- next_token = macro.replacement_list.tokens[index + 1]
903
+ prv_tok = macro.replacement_list.tokens[[idx - 1, 0].max]
904
+ nxt_tok = macro.replacement_list.tokens[idx + 1]
886
905
 
887
- next if prev_token && prev_token.value =~ /\A##?\z/
888
- next if next_token && next_token.value == "##"
906
+ next if prv_tok && prv_tok.value =~ /\A##?\z/
907
+ next if nxt_tok && nxt_tok.value == "##"
889
908
 
890
- unless prev_token && prev_token.value == "("
891
- W(:W0549, pp_token.location)
909
+ unless prv_tok && prv_tok.value == "("
910
+ W(pp_tok.location)
892
911
  next
893
912
  end
894
913
 
895
- unless next_token && next_token.value == ")"
896
- W(:W0549, pp_token.location)
914
+ unless nxt_tok && nxt_tok.value == ")"
915
+ W(pp_tok.location)
897
916
  next
898
917
  end
899
918
  end
@@ -906,17 +925,17 @@ module CBuiltin #:nodoc:
906
925
 
907
926
  # NOTE: W0554 may be duplicative when the same header which causes this
908
927
  # warning is included twice or more.
909
- ensure_uniqueness_of :W0554
928
+ mark_as_unique
910
929
 
911
- def initialize(context)
930
+ def initialize(phase_ctxt)
912
931
  super
913
- interp = context[:cpp_interpreter]
914
- interp.on_unknown_pragma_evaled += method(:check)
932
+ interp = phase_ctxt[:cpp_interpreter]
933
+ interp.on_unknown_pragma_evaled += T(:check)
915
934
  end
916
935
 
917
936
  private
918
937
  def check(pragma_line)
919
- W(:W0554, pragma_line.location,
938
+ W(pragma_line.location,
920
939
  pragma_line.pp_tokens ? pragma_line.pp_tokens.to_s : "")
921
940
  end
922
941
  end
@@ -926,29 +945,29 @@ module CBuiltin #:nodoc:
926
945
 
927
946
  # NOTE: W0574 may be duplicative when the same header which causes this
928
947
  # warning is included twice or more.
929
- ensure_uniqueness_of :W0574
948
+ mark_as_unique
930
949
 
931
- def initialize(context)
950
+ def initialize(phase_ctxt)
932
951
  super
933
- interp = context[:cpp_interpreter]
934
- interp.on_pp_token_extracted += method(:check_pp_token)
935
- interp.on_object_like_macro_defined += method(:check_macro)
936
- interp.on_function_like_macro_defined += method(:check_macro)
937
- interp.on_va_function_like_macro_defined += method(:check_macro)
952
+ interp = phase_ctxt[:cpp_interpreter]
953
+ interp.on_pp_token_extracted += T(:check_pp_token)
954
+ interp.on_object_like_macro_defined += T(:check_macro)
955
+ interp.on_function_like_macro_defined += T(:check_macro)
956
+ interp.on_va_function_like_macro_defined += T(:check_macro)
938
957
  end
939
958
 
940
959
  private
941
- def check_pp_token(pp_token)
942
- if pp_token.value =~ /\AL?'(.*)'\z/
960
+ def check_pp_token(pp_tok)
961
+ if pp_tok.value =~ /\AL?'(.*)'\z/
943
962
  unless Cpp::BasicSourceCharacterSet.include?($1)
944
- W(:W0574, pp_token.location)
963
+ W(pp_tok.location)
945
964
  end
946
965
  end
947
966
  end
948
967
 
949
- def check_macro(define_line, macro)
950
- if replacement_list = macro.replacement_list
951
- replacement_list.tokens.each { |pp_token| check_pp_token(pp_token) }
968
+ def check_macro(*, macro)
969
+ if repl_lsit = macro.replacement_list
970
+ repl_lsit.tokens.each { |pp_tok| check_pp_token(pp_tok) }
952
971
  end
953
972
  end
954
973
  end
@@ -958,29 +977,29 @@ module CBuiltin #:nodoc:
958
977
 
959
978
  # NOTE: W0575 may be duplicative when the same header which causes this
960
979
  # warning is included twice or more.
961
- ensure_uniqueness_of :W0575
980
+ mark_as_unique
962
981
 
963
- def initialize(context)
982
+ def initialize(phase_ctxt)
964
983
  super
965
- interp = context[:cpp_interpreter]
966
- interp.on_pp_token_extracted += method(:check_pp_token)
967
- interp.on_object_like_macro_defined += method(:check_macro)
968
- interp.on_function_like_macro_defined += method(:check_macro)
969
- interp.on_va_function_like_macro_defined += method(:check_macro)
984
+ interp = phase_ctxt[:cpp_interpreter]
985
+ interp.on_pp_token_extracted += T(:check_pp_token)
986
+ interp.on_object_like_macro_defined += T(:check_macro)
987
+ interp.on_function_like_macro_defined += T(:check_macro)
988
+ interp.on_va_function_like_macro_defined += T(:check_macro)
970
989
  end
971
990
 
972
991
  private
973
- def check_pp_token(pp_token)
974
- if pp_token.value =~ /\AL?"(.*)"\z/
992
+ def check_pp_token(pp_tok)
993
+ if pp_tok.value =~ /\AL?"(.*)"\z/
975
994
  unless Cpp::BasicSourceCharacterSet.include?($1)
976
- W(:W0575, pp_token.location)
995
+ W(pp_tok.location)
977
996
  end
978
997
  end
979
998
  end
980
999
 
981
- def check_macro(define_line, macro)
982
- if replacement_list = macro.replacement_list
983
- replacement_list.tokens.each { |pp_token| check_pp_token(pp_token) }
1000
+ def check_macro(*, macro)
1001
+ if repl_list = macro.replacement_list
1002
+ repl_list.tokens.each { |pp_tok| check_pp_token(pp_tok) }
984
1003
  end
985
1004
  end
986
1005
  end
@@ -990,25 +1009,25 @@ module CBuiltin #:nodoc:
990
1009
 
991
1010
  # NOTE: W0576 may be duplicative when the same header which causes this
992
1011
  # warning is included twice or more.
993
- ensure_uniqueness_of :W0576
1012
+ mark_as_unique
994
1013
 
995
- def initialize(context)
1014
+ def initialize(phase_ctxt)
996
1015
  super
997
- interp = context[:cpp_interpreter]
998
- interp.on_block_comment_found += method(:check)
999
- interp.on_line_comment_found += method(:check)
1016
+ interp = phase_ctxt[:cpp_interpreter]
1017
+ interp.on_block_comment_found += M(:check)
1018
+ interp.on_line_comment_found += M(:check)
1000
1019
  @warned_chars = Set.new
1001
1020
  end
1002
1021
 
1003
1022
  private
1004
- def check(comment, location)
1005
- not_adapted = Cpp::BasicSourceCharacterSet.select_not_adapted(comment)
1006
-
1007
- new_chars = not_adapted.to_set - @warned_chars
1008
-
1009
- unless new_chars.empty?
1010
- W(:W0576, location, location.fpath)
1011
- @warned_chars.merge(new_chars)
1023
+ def check(comment, loc)
1024
+ if loc.in_analysis_target?(traits)
1025
+ not_adapted = Cpp::BasicSourceCharacterSet.select_not_adapted(comment)
1026
+ new_chars = not_adapted.to_set - @warned_chars
1027
+ unless new_chars.empty?
1028
+ W(loc, loc.fpath)
1029
+ @warned_chars.merge(new_chars)
1030
+ end
1012
1031
  end
1013
1032
  end
1014
1033
  end
@@ -1018,20 +1037,22 @@ module CBuiltin #:nodoc:
1018
1037
 
1019
1038
  # NOTE: W0577 may be duplicative when the same header which causes this
1020
1039
  # warning is included twice or more.
1021
- ensure_uniqueness_of :W0577
1040
+ mark_as_unique
1022
1041
 
1023
- def initialize(context)
1042
+ def initialize(phase_ctxt)
1024
1043
  super
1025
- interp = context[:cpp_interpreter]
1026
- interp.on_unlexable_char_found += method(:check)
1044
+ interp = phase_ctxt[:cpp_interpreter]
1045
+ interp.on_unlexable_char_found += M(:check)
1027
1046
  @warned = false
1028
1047
  end
1029
1048
 
1030
1049
  private
1031
- def check(char, location)
1032
- unless @warned
1033
- W(:W0577, location, location.fpath)
1034
- @warned = true
1050
+ def check(*, loc)
1051
+ if loc.in_analysis_target?(traits)
1052
+ unless @warned
1053
+ W(loc, loc.fpath)
1054
+ @warned = true
1055
+ end
1035
1056
  end
1036
1057
  end
1037
1058
  end
@@ -1041,19 +1062,19 @@ module CBuiltin #:nodoc:
1041
1062
 
1042
1063
  # NOTE: W0632 may be duplicative when the same header which has references
1043
1064
  # to the undefined macro is included twice or more.
1044
- ensure_uniqueness_of :W0632
1065
+ mark_as_unique
1045
1066
 
1046
- def initialize(context)
1067
+ def initialize(phase_ctxt)
1047
1068
  super
1048
- visitor = context[:cpp_visitor]
1049
- visitor.enter_system_include_line += method(:check)
1050
- visitor.enter_system_include_next_line += method(:check)
1069
+ visitor = phase_ctxt[:cpp_visitor]
1070
+ visitor.enter_system_include_line += T(:check)
1071
+ visitor.enter_system_include_next_line += T(:check)
1051
1072
  end
1052
1073
 
1053
1074
  private
1054
1075
  def check(include_line)
1055
1076
  if include_line.header_name.value =~ /['"]/
1056
- W(:W0632, include_line.location, include_line.header_name.value)
1077
+ W(include_line.location, include_line.header_name.value)
1057
1078
  end
1058
1079
  end
1059
1080
  end
@@ -1063,19 +1084,19 @@ module CBuiltin #:nodoc:
1063
1084
 
1064
1085
  # NOTE: W0633 may be duplicative when the same header which has references
1065
1086
  # to the undefined macro is included twice or more.
1066
- ensure_uniqueness_of :W0633
1087
+ mark_as_unique
1067
1088
 
1068
- def initialize(context)
1089
+ def initialize(phase_ctxt)
1069
1090
  super
1070
- visitor = context[:cpp_visitor]
1071
- visitor.enter_user_include_line += method(:check)
1072
- visitor.enter_user_include_next_line += method(:check)
1091
+ visitor = phase_ctxt[:cpp_visitor]
1092
+ visitor.enter_user_include_line += T(:check)
1093
+ visitor.enter_user_include_next_line += T(:check)
1073
1094
  end
1074
1095
 
1075
1096
  private
1076
1097
  def check(include_line)
1077
1098
  if include_line.header_name.value =~ /'/
1078
- W(:W0633, include_line.location, include_line.header_name.value)
1099
+ W(include_line.location, include_line.header_name.value)
1079
1100
  end
1080
1101
  end
1081
1102
  end
@@ -1085,21 +1106,21 @@ module CBuiltin #:nodoc:
1085
1106
 
1086
1107
  # NOTE: W0634 may be duplicative when the same header which has references
1087
1108
  # to the undefined macro is included twice or more.
1088
- ensure_uniqueness_of :W0634
1109
+ mark_as_unique
1089
1110
 
1090
- def initialize(context)
1111
+ def initialize(phase_ctxt)
1091
1112
  super
1092
- visitor = context[:cpp_visitor]
1093
- visitor.enter_user_include_line += method(:check)
1094
- visitor.enter_user_include_next_line += method(:check)
1095
- visitor.enter_system_include_line += method(:check)
1096
- visitor.enter_system_include_next_line += method(:check)
1113
+ visitor = phase_ctxt[:cpp_visitor]
1114
+ visitor.enter_user_include_line += T(:check)
1115
+ visitor.enter_user_include_next_line += T(:check)
1116
+ visitor.enter_system_include_line += T(:check)
1117
+ visitor.enter_system_include_next_line += T(:check)
1097
1118
  end
1098
1119
 
1099
1120
  private
1100
1121
  def check(include_line)
1101
1122
  if include_line.header_name.value.include?("\\")
1102
- W(:W0634, include_line.location)
1123
+ W(include_line.location)
1103
1124
  end
1104
1125
  end
1105
1126
  end
@@ -1109,13 +1130,17 @@ module CBuiltin #:nodoc:
1109
1130
 
1110
1131
  # NOTE: W0643 may be duplicative when the same header which has references
1111
1132
  # to the undefined macro is included twice or more.
1112
- ensure_uniqueness_of :W0643
1133
+ mark_as_unique
1113
1134
 
1114
- def initialize(context)
1135
+ def initialize(phase_ctxt)
1115
1136
  super
1116
- macro_table = context[:cpp_macro_table]
1117
- macro_table.on_last_backslash_ignored +=
1118
- lambda { |token| W(:W0643, token.location) }
1137
+ macro_table = phase_ctxt[:cpp_macro_table]
1138
+ macro_table.on_last_backslash_ignored += T(:check)
1139
+ end
1140
+
1141
+ private
1142
+ def check(tok)
1143
+ W(tok.location)
1119
1144
  end
1120
1145
  end
1121
1146
 
@@ -1124,17 +1149,17 @@ module CBuiltin #:nodoc:
1124
1149
 
1125
1150
  # NOTE: W0691 may be duplicative when the same header which has references
1126
1151
  # to the undefined macro is included twice or more.
1127
- ensure_uniqueness_of :W0691
1152
+ mark_as_unique
1128
1153
 
1129
- def initialize(context)
1154
+ def initialize(phase_ctxt)
1130
1155
  super
1131
- macro_table = context[:cpp_macro_table]
1132
- macro_table.on_sharpsharp_operator_evaled += method(:check)
1156
+ macro_table = phase_ctxt[:cpp_macro_table]
1157
+ macro_table.on_sharpsharp_operator_evaled += T(:check)
1133
1158
  end
1134
1159
 
1135
1160
  private
1136
- def check(lhs_token, rhs_token, new_tokens)
1137
- W(:W0691, new_tokens.first.location) if new_tokens.size > 1
1161
+ def check(*, new_toks)
1162
+ W(new_toks.first.location) if new_toks.size > 1
1138
1163
  end
1139
1164
  end
1140
1165
 
@@ -1143,19 +1168,19 @@ module CBuiltin #:nodoc:
1143
1168
 
1144
1169
  # NOTE: W0692 may be duplicative when the same header which has references
1145
1170
  # to the undefined macro is included twice or more.
1146
- ensure_uniqueness_of :W0692
1171
+ mark_as_unique
1147
1172
 
1148
- def initialize(context)
1173
+ def initialize(phase_ctxt)
1149
1174
  super
1150
- macro_table = context[:cpp_macro_table]
1151
- macro_table.on_function_like_macro_replacement += method(:check)
1175
+ macro_table = phase_ctxt[:cpp_macro_table]
1176
+ macro_table.on_function_like_macro_replacement += T(:check)
1152
1177
  end
1153
1178
 
1154
1179
  private
1155
- def check(macro, replacing_tokens, args, *)
1180
+ def check(macro, repl_toks, args, *)
1156
1181
  unless macro.parameter_names.empty?
1157
1182
  if args.any? { |arg| arg.empty? }
1158
- W(:W0692, replacing_tokens.first.location, macro.name.value)
1183
+ W(repl_toks.first.location, macro.name.value)
1159
1184
  end
1160
1185
  end
1161
1186
  end
@@ -1166,13 +1191,17 @@ module CBuiltin #:nodoc:
1166
1191
 
1167
1192
  # NOTE: W0696 may be duplicative when the same header which has references
1168
1193
  # to the undefined macro is included twice or more.
1169
- ensure_uniqueness_of :W0696
1194
+ mark_as_unique
1170
1195
 
1171
- def initialize(context)
1196
+ def initialize(phase_ctxt)
1172
1197
  super
1173
- interp = context[:cpp_interpreter]
1174
- interp.on_undefined_macro_referred +=
1175
- lambda { |token| W(:W0696, token.location, token.value) }
1198
+ interp = phase_ctxt[:cpp_interpreter]
1199
+ interp.on_undefined_macro_referred += T(:check)
1200
+ end
1201
+
1202
+ private
1203
+ def check(tok)
1204
+ W(tok.location, tok.value)
1176
1205
  end
1177
1206
  end
1178
1207
 
@@ -1181,16 +1210,16 @@ module CBuiltin #:nodoc:
1181
1210
 
1182
1211
  # NOTE: W0804 may be duplicative when the same header which causes this
1183
1212
  # warning is included twice or more.
1184
- ensure_uniqueness_of :W0804
1213
+ mark_as_unique
1185
1214
 
1186
- def initialize(context)
1215
+ def initialize(phase_ctxt)
1187
1216
  super
1188
- context[:cpp_interpreter].on_illformed_defined_op_found += method(:check)
1217
+ phase_ctxt[:cpp_interpreter].on_illformed_defined_op_found += M(:check)
1189
1218
  end
1190
1219
 
1191
1220
  private
1192
- def check(location, *)
1193
- W(:W0804, location)
1221
+ def check(loc, *)
1222
+ W(loc) if loc.in_analysis_target?(traits)
1194
1223
  end
1195
1224
  end
1196
1225
 
@@ -1199,11 +1228,13 @@ module CBuiltin #:nodoc:
1199
1228
 
1200
1229
  # NOTE: W0805 may be duplicative when the same header which causes this
1201
1230
  # warning is included twice or more.
1202
- ensure_uniqueness_of :W0805
1231
+ mark_as_unique
1203
1232
 
1204
1233
  private
1205
- def check(location, no_args)
1206
- W(:W0805, location) unless no_args
1234
+ def check(loc, no_args)
1235
+ if loc.in_analysis_target?(traits)
1236
+ W(loc) unless no_args
1237
+ end
1207
1238
  end
1208
1239
  end
1209
1240
 
@@ -1212,19 +1243,19 @@ module CBuiltin #:nodoc:
1212
1243
 
1213
1244
  # NOTE: W0811 may be duplicative when the same header which causes this
1214
1245
  # warning is included twice or more.
1215
- ensure_uniqueness_of :W0811
1246
+ mark_as_unique
1216
1247
 
1217
- def initialize(context)
1248
+ def initialize(phase_ctxt)
1218
1249
  super
1219
- macro_table = context[:cpp_macro_table]
1220
- macro_table.on_object_like_macro_replacement += method(:check)
1221
- macro_table.on_function_like_macro_replacement += method(:check)
1250
+ macro_table = phase_ctxt[:cpp_macro_table]
1251
+ macro_table.on_object_like_macro_replacement += T(:check)
1252
+ macro_table.on_function_like_macro_replacement += T(:check)
1222
1253
  end
1223
1254
 
1224
1255
  private
1225
- def check(*, result_tokens)
1226
- if defined_token = result_tokens.find { |t| t.value == "defined" }
1227
- W(:W0811, defined_token.location)
1256
+ def check(*, res_toks)
1257
+ if defined_tok = res_toks.find { |tok| tok.value == "defined" }
1258
+ W(defined_tok.location)
1228
1259
  end
1229
1260
  end
1230
1261
  end
@@ -1234,17 +1265,17 @@ module CBuiltin #:nodoc:
1234
1265
 
1235
1266
  # NOTE: W0831 may be duplicative when the same header which causes this
1236
1267
  # warning is included twice or more.
1237
- ensure_uniqueness_of :W0831
1268
+ mark_as_unique
1238
1269
 
1239
- def initialize(context)
1270
+ def initialize(phase_ctxt)
1240
1271
  super
1241
- interp = context[:cpp_interpreter]
1242
- interp.on_asm_section_evaled += method(:check)
1272
+ interp = phase_ctxt[:cpp_interpreter]
1273
+ interp.on_asm_section_evaled += T(:check)
1243
1274
  end
1244
1275
 
1245
1276
  private
1246
1277
  def check(asm_section)
1247
- W(:W0831, asm_section.location)
1278
+ W(asm_section.location)
1248
1279
  end
1249
1280
  end
1250
1281
 
@@ -1253,16 +1284,17 @@ module CBuiltin #:nodoc:
1253
1284
 
1254
1285
  # NOTE: W0832 may be duplicative when the same header which causes this
1255
1286
  # warning is included twice or more.
1256
- ensure_uniqueness_of :W0832
1287
+ mark_as_unique
1257
1288
 
1258
- def initialize(context)
1289
+ def initialize(phase_ctxt)
1259
1290
  super
1260
- context[:c_source].on_inline_assembly += method(:check)
1291
+ phase_ctxt[:cc1_source].on_inline_assembly += M(:check)
1261
1292
  end
1262
1293
 
1263
1294
  private
1264
- def check(asm_tokens)
1265
- W(:W0832, asm_tokens.first.location)
1295
+ def check(asm_toks)
1296
+ head_loc = asm_toks.first.location
1297
+ W(head_loc) if head_loc.in_analysis_target?(traits)
1266
1298
  end
1267
1299
  end
1268
1300
 
@@ -1271,17 +1303,18 @@ module CBuiltin #:nodoc:
1271
1303
 
1272
1304
  # NOTE: W1040 may be duplicative when the same header which causes this
1273
1305
  # warning is included twice or more.
1274
- ensure_uniqueness_of :W1040
1306
+ mark_as_unique
1275
1307
 
1276
- def initialize(context)
1308
+ def initialize(phase_ctxt)
1277
1309
  super
1278
- interp = context[:cpp_interpreter]
1279
- interp.on_extra_tokens_found += method(:check)
1310
+ interp = phase_ctxt[:cpp_interpreter]
1311
+ interp.on_extra_tokens_found += M(:check)
1280
1312
  end
1281
1313
 
1282
1314
  private
1283
- def check(extra_tokens)
1284
- W(:W1040, extra_tokens.first.location)
1315
+ def check(extra_toks)
1316
+ head_loc = extra_toks.first.location
1317
+ W(head_loc) if head_loc.in_analysis_target?(traits)
1285
1318
  end
1286
1319
  end
1287
1320
 
@@ -1290,17 +1323,17 @@ module CBuiltin #:nodoc:
1290
1323
 
1291
1324
  # NOTE: W1041 may be duplicative when the same header which causes this
1292
1325
  # warning is included twice or more.
1293
- ensure_uniqueness_of :W1041
1326
+ mark_as_unique
1294
1327
 
1295
- def initialize(context)
1328
+ def initialize(phase_ctxt)
1296
1329
  super
1297
- visitor = context[:cpp_visitor]
1298
- visitor.enter_unknown_directive += method(:check)
1330
+ visitor = phase_ctxt[:cpp_visitor]
1331
+ visitor.enter_unknown_directive += T(:check)
1299
1332
  end
1300
1333
 
1301
1334
  private
1302
1335
  def check(node)
1303
- W(:W1041, node.location, node.token.value.chomp.strip)
1336
+ W(node.location, node.token.value.chomp.strip)
1304
1337
  end
1305
1338
  end
1306
1339
 
@@ -1309,13 +1342,17 @@ module CBuiltin #:nodoc:
1309
1342
 
1310
1343
  # NOTE: W1046 may be duplicative when the same header which causes this
1311
1344
  # warning is included twice or more.
1312
- ensure_uniqueness_of :W1046
1345
+ mark_as_unique
1313
1346
 
1314
- def initialize(context)
1347
+ def initialize(phase_ctxt)
1315
1348
  super
1316
- interp = context[:cpp_interpreter]
1317
- interp.on_illformed_newline_escape_found +=
1318
- lambda { |location| W(:W1046, location) }
1349
+ interp = phase_ctxt[:cpp_interpreter]
1350
+ interp.on_illformed_newline_escape_found += M(:check)
1351
+ end
1352
+
1353
+ private
1354
+ def check(loc)
1355
+ W(loc) if loc.in_analysis_target?(traits)
1319
1356
  end
1320
1357
  end
1321
1358
 
@@ -1324,12 +1361,20 @@ module CBuiltin #:nodoc:
1324
1361
 
1325
1362
  # NOTE: W9002 may be duplicative when the same header which has no newline
1326
1363
  # at end of the file is included twice or more.
1327
- ensure_uniqueness_of :W9002
1364
+ mark_as_unique
1328
1365
 
1329
- def initialize(context)
1366
+ # NOTE: W9002 may be detected before evaluating the annotation for message
1367
+ # suppression.
1368
+ mark_as_deferred
1369
+
1370
+ def initialize(phase_ctxt)
1330
1371
  super
1331
- context[:cpp_interpreter].on_eof_newline_not_found +=
1332
- lambda { |location| W(:W9002, location) }
1372
+ phase_ctxt[:cpp_interpreter].on_eof_newline_not_found += M(:check)
1373
+ end
1374
+
1375
+ private
1376
+ def check(loc)
1377
+ W(loc) if loc.in_analysis_target?(traits)
1333
1378
  end
1334
1379
  end
1335
1380