adlint 2.6.14 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -163,6 +163,7 @@ Feature: W9003
163
163
  | W0286 | 5 | 5 |
164
164
  | W0031 | 3 | 13 |
165
165
  | W0104 | 3 | 13 |
166
+ | W0070 | 1 | 1 |
166
167
  | W0628 | 3 | 5 |
167
168
 
168
169
  Scenario: explicit conversion of size_t value
@@ -181,6 +182,7 @@ Feature: W9003
181
182
  | W0117 | 3 | 5 |
182
183
  | W0031 | 3 | 13 |
183
184
  | W0104 | 3 | 13 |
185
+ | W0070 | 1 | 1 |
184
186
  | W0628 | 3 | 5 |
185
187
 
186
188
  Scenario: implicit conversion to void pointer
@@ -8,6 +8,7 @@ When /^I successfully run `(.*)` on noarch$/ do |abbrev_cmd|
8
8
  end
9
9
 
10
10
  Then /^the output should exactly match with:$/ do |mesg_table|
11
+ $all_output.lines.to_a.size.should == mesg_table.hashes.size
11
12
  $all_output.each_line.zip(mesg_table.hashes).each do |line, row|
12
13
  if row
13
14
  line.should =~ /#{row[:line]}:#{row[:column]}:.*:.*:#{row[:mesg]}/
@@ -1,5 +1,5 @@
1
1
  NOARCH_TRAITS = <<EOF
2
- version: "2.4.0"
2
+ version: "3.0.0"
3
3
 
4
4
  exam_packages:
5
5
  - "c_builtin"
@@ -7,8 +7,12 @@ exam_packages:
7
7
  project_traits:
8
8
  project_name: "features"
9
9
  project_root: "."
10
- include_path:
10
+ target_files:
11
+ inclusion_paths:
12
+ - "."
13
+ exclusion_paths:
11
14
  initial_header: "empty_pinit.h"
15
+ file_search_paths:
12
16
  coding_style:
13
17
  indent_style: "K&R"
14
18
  tab_width: 8
@@ -17,7 +21,9 @@ project_traits:
17
21
 
18
22
  compiler_traits:
19
23
  initial_header: "empty_cinit.h"
20
- standard_type:
24
+ file_search_paths:
25
+ - "."
26
+ standard_types:
21
27
  char_size: 8
22
28
  char_alignment: 8
23
29
  short_size: 16
@@ -39,11 +45,10 @@ compiler_traits:
39
45
  data_ptr_size: 32
40
46
  data_ptr_alignment: 32
41
47
  char_as_unsigned_char: true
42
- include_path:
43
- - "."
44
48
  arithmetic:
45
49
  logical_right_shift: true
46
- extension_substitution:
50
+ identifier_max: 128
51
+ extension_substitutions:
47
52
  "pascal": ""
48
53
  "__pascal": ""
49
54
  "fortran": ""
@@ -58,12 +63,11 @@ compiler_traits:
58
63
  "__huge": ""
59
64
  "__extension__": ""
60
65
  "__attribute__(__adlint__any)": ""
61
- arbitrary_substitution:
66
+ arbitrary_substitutions:
62
67
  "typeof": "__typeof__"
63
68
  "__typeof": "__typeof__"
64
69
  "alignof": "__alignof__"
65
70
  "__alignof": "__alignof__"
66
- identifier_max: 128
67
71
 
68
72
  linker_traits:
69
73
  identifier_max: 128
@@ -71,10 +75,7 @@ linker_traits:
71
75
 
72
76
  message_traits:
73
77
  language: "ja_JP"
74
- message_with_class: false
75
- warn_files_in:
76
- warn_files_not_in:
77
- individual_selection: true
78
+ individual_suppression: true
78
79
  exclusion:
79
80
  inclusion:
80
81
  change_list:
@@ -137,11 +138,13 @@ module Kernel
137
138
  end
138
139
  end
139
140
 
141
+ EXCL_FILES = /_pinit\.h|_cinit\.h|stdio\.h|math\.h|assert\.h|stddef\.h/
142
+
140
143
  def run_adlint(cmd, *args)
141
144
  create_adlint_files
142
145
  cd_to_tmpdir do
143
146
  $all_output = exec(cmd, *args).each_line.map { |line|
144
- if line =~ /_pinit\.h|_cinit\.h|stdio\.h|math\.h|assert\.h|stddef\.h/
147
+ if line =~ /#{EXCL_FILES}.*:warning/
145
148
  nil
146
149
  else
147
150
  line.chomp
data/lib/adlint.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # AdLint package loader.
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
  #
@@ -38,12 +38,13 @@ require "psych"
38
38
  require "yaml"
39
39
  require "strscan"
40
40
  require "stringio"
41
- require "singleton"
42
41
  require "forwardable"
43
42
  require "logger"
44
43
 
44
+ require "adlint/memo"
45
45
  require "adlint/prelude"
46
46
  require "adlint/analyzer"
47
+ require "adlint/annot"
47
48
  require "adlint/code"
48
49
  require "adlint/exam"
49
50
  require "adlint/traits"
@@ -57,13 +58,15 @@ require "adlint/monitor"
57
58
  require "adlint/phase"
58
59
  require "adlint/report"
59
60
  require "adlint/source"
61
+ require "adlint/supp"
60
62
  require "adlint/symbol"
63
+ require "adlint/location"
61
64
  require "adlint/token"
62
65
  require "adlint/util"
63
66
  require "adlint/version"
64
67
 
65
68
  require "adlint/cpp"
66
- require "adlint/c"
69
+ require "adlint/cc1"
67
70
  require "adlint/ld"
68
71
 
69
72
  module AdLint #:nodoc:
@@ -1,7 +1,7 @@
1
1
  # Analyzer classes.
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
  #
@@ -36,274 +36,248 @@ require "adlint/metric"
36
36
  require "adlint/phase"
37
37
  require "adlint/lang"
38
38
  require "adlint/source"
39
+ require "adlint/supp"
39
40
  require "adlint/symbol"
40
41
  require "adlint/monitor"
42
+ require "adlint/util"
41
43
  require "adlint/ld/phase"
42
44
 
43
45
  module AdLint #:nodoc:
44
46
 
45
47
  class Analyzer
46
- def self.current
47
- @@current
48
+ def initialize(name, traits, msg_catalog, target_name, output_dpath,
49
+ log_basename, verbose)
50
+ @name = name
51
+ @traits = traits
52
+ @message_catalog = msg_catalog
53
+ @target_name = target_name
54
+ @output_dpath = output_dpath
55
+ @log_basename = log_basename
56
+ @verbose = verbose
57
+ @logger = nil
48
58
  end
49
59
 
50
- def self.current=(analyzer)
51
- @@current = analyzer
52
- end
53
-
54
- def initialize(name, log_base_fpath, output_dpath = nil)
55
- @name = name
56
- @log_base_fpath = log_base_fpath
57
- @output_dpath = output_dpath
58
- end
60
+ attr_reader :traits
61
+ attr_reader :message_catalog
62
+ attr_reader :logger
59
63
 
60
64
  def run
61
65
  File.open(log_fpath, "w") do |log_io|
62
- @logger = Logger.new(log_io)
63
- @logger.progname = @name
64
- @logger.datetime_format = "%F %T "
66
+ @logger = Logger.new(log_io).tap { |logger|
67
+ logger.progname = @name
68
+ logger.datetime_format = "%F %T "
69
+ }
65
70
  begin
66
- Analyzer.current = self
67
71
  log_start_analysis
68
- execute
72
+ execute(ProgressMonitor.new(@target_name, phases.size, @verbose))
69
73
  rescue => ex
70
- fatal(ex)
74
+ @logger.fatal(ex)
71
75
  return false
72
- ensure
73
- Analyzer.current = nil
74
76
  end
75
77
  end
76
78
  true
77
79
  end
78
80
 
79
- extend Forwardable
80
-
81
- def_delegator :@logger, :fatal
82
- def_delegator :@logger, :error
83
- def_delegator :@logger, :warn
84
- def_delegator :@logger, :info
85
- def_delegator :@logger, :debug
86
-
87
81
  private
88
- def execute
82
+ def execute(monitor)
83
+ subclass_responsibility
84
+ end
85
+
86
+ def phases
89
87
  subclass_responsibility
90
88
  end
91
89
 
92
90
  def log_fpath
93
- if @output_dpath
94
- @output_dpath.join(@log_base_fpath).add_ext(".log")
95
- else
96
- @log_base_fpath.add_ext(".log")
97
- end
91
+ log_fname = @log_basename.add_ext(".log")
92
+ @output_dpath ? @output_dpath.join(log_fname) : log_fname
98
93
  end
99
94
 
100
95
  def log_start_analysis
101
- exam_versions = Traits.instance.exam_packages.map { |exam_package|
102
- exam_package.catalog
103
- }.map { |catalog| "#{catalog.name}-#{catalog.short_version}" }
96
+ exam_vers = @traits.exam_packages.map { |exam_pkg|
97
+ exam_pkg.catalog
98
+ }.map { |exam_cat| "#{exam_cat.name}-#{exam_cat.short_version}" }
104
99
 
105
- mesg = "start analysis by adlint-#{SHORT_VERSION} with "
106
- if exam_versions.size < 3
107
- mesg += exam_versions.join(" and ")
100
+ msg = "start analysis by adlint-#{SHORT_VERSION} with "
101
+ if exam_vers.size < 3
102
+ msg += exam_vers.join(" and ")
108
103
  else
109
- mesg += exam_versions[0..-2].join(", ") + " and " + exam_versions.last
104
+ msg += exam_vers[0..-2].join(", ") + " and " + exam_vers.last
110
105
  end
111
106
 
112
- info("#{mesg}.")
107
+ @logger.info("#{msg}.")
113
108
  end
114
109
  end
115
110
 
116
111
  # == Single module analysis driver.
117
112
  class SingleModuleAnalyzer < Analyzer
118
- def initialize(fpath, strip_num = 0, output_dpath = nil)
119
- super("SMA-#{SHORT_VERSION}", fpath.strip(strip_num), output_dpath)
120
-
121
- @fpath = fpath
113
+ def initialize(traits, msg_catalog, src_fpath, strip_num, output_dpath,
114
+ verbose)
115
+ super("SMA-#{SHORT_VERSION}", traits, msg_catalog, src_fpath.to_s,
116
+ output_dpath, src_fpath.strip(strip_num), verbose)
117
+ @src_fpath = src_fpath
122
118
  @strip_num = strip_num
123
119
  end
124
120
 
125
121
  private
126
- def execute
127
- lang = Language.of(@fpath)
128
- return unless lang
129
-
130
- ProgressMonitor.instance.reset(@fpath, lang.single_module_phases.size)
131
-
132
- Report.new(msg_fpath, met_fpath) do |report|
133
- context = PhaseContext.new(report, log_fpath)
122
+ def execute(monitor)
123
+ Report.new(msg_fpath, met_fpath, log_fpath, @verbose) do |report|
124
+ src = Source.new(@src_fpath, @traits.of_project.file_encoding)
134
125
 
135
- context[:sources] = [Source.new(@fpath)]
136
- context[:symbol_table] = SymbolTable.new
126
+ phase_ctxt = PhaseContext.new(self, report, monitor)
127
+ phase_ctxt[:sources] = [src]
128
+ phase_ctxt[:annotations] = []
129
+ phase_ctxt[:suppressors] = MessageSuppressorSet.new
130
+ phase_ctxt[:symbol_table] = SymbolTable.new
137
131
 
138
132
  begin
139
- lang.single_module_phases.each do |phase_class|
140
- phase_class.new(context).execute
141
- end
133
+ phases.each { |phase| phase.new(phase_ctxt).execute }
134
+ phase_ctxt.flush_deferred_report!
142
135
  ensure
143
136
  File.open(i_fpath, "w") do |io|
144
137
  io.set_encoding(Encoding.default_external)
145
- io.puts(context[:c_source].to_s)
138
+ io.puts(phase_ctxt[:cc1_source].to_s)
146
139
  end
147
140
  end
148
141
  end
149
142
  rescue
150
- if verbose?
151
- $stderr.puts "An error was occurred while processing `#{@fpath}'."
143
+ if @verbose
144
+ $stderr.puts "An error was occurred while processing `#{@src_fpath}'."
152
145
  $stderr.puts "See `#{msg_fpath}' and `#{log_fpath}' for more details."
153
146
  end
154
147
  raise
155
148
  end
156
149
 
150
+ def phases
151
+ (lang = Language.of(@src_fpath)) ? lang.single_module_phases : []
152
+ end
153
+
157
154
  def msg_fpath
158
- if @output_dpath
159
- @output_dpath.join(@fpath.strip(@strip_num)).add_ext(".msg.csv")
160
- else
161
- @fpath.strip(@strip_num).add_ext(".msg.csv")
162
- end
155
+ msg_fname = @src_fpath.strip(@strip_num).add_ext(".msg.csv")
156
+ @output_dpath ? @output_dpath.join(msg_fname) : msg_fname
163
157
  end
164
158
 
165
159
  def met_fpath
166
- if @output_dpath
167
- @output_dpath.join(@fpath.strip(@strip_num)).add_ext(".met.csv")
168
- else
169
- @fpath.strip(@strip_num).add_ext(".met.csv")
170
- end
160
+ met_fname = @src_fpath.strip(@strip_num).add_ext(".met.csv")
161
+ @output_dpath ? @output_dpath.join(met_fname) : met_fname
171
162
  end
172
163
 
173
164
  def i_fpath
174
- if @output_dpath
175
- @output_dpath.join(@fpath.strip(@strip_num)).sub_ext(".i")
176
- else
177
- @fpath.strip(@strip_num).sub_ext(".i")
178
- end
165
+ i_fname = @src_fpath.strip(@strip_num).sub_ext(".i")
166
+ @output_dpath ? @output_dpath.join(i_fname) : i_fname
179
167
  end
180
168
  end
181
169
 
182
170
  class CrossModuleAnalyzer < Analyzer
183
- def initialize(fpaths, output_dpath = nil)
184
- @project_name = Traits.instance.of_project.project_name
185
- super("CMA-#{SHORT_VERSION}", Pathname.new(@project_name), output_dpath)
186
-
187
- @fpaths = fpaths
171
+ def initialize(traits, msg_catalog, met_fpaths, output_dpath, verbose)
172
+ proj_name = traits.of_project.project_name
173
+ super("CMA-#{SHORT_VERSION}", traits, msg_catalog, proj_name,
174
+ output_dpath, Pathname.new(proj_name), verbose)
175
+ @met_fpaths = met_fpaths
188
176
  end
189
177
 
190
178
  private
191
- PHASE_CLASSES = [
192
- AdLint::Ld::MapTypedefPhase,
193
- AdLint::Ld::MapFunctionPhase,
194
- AdLint::Ld::MapVariablePhase,
195
- AdLint::Ld::LinkFunctionPhase,
196
- AdLint::Ld::LinkVariablePhase,
197
- AdLint::Ld::PreparePhase,
198
- AdLint::Ld::TypedefReviewPhase,
199
- AdLint::Ld::FunctionReviewPhase,
200
- AdLint::Ld::VariableReviewPhase,
201
- AdLint::Ld::ExaminationPhase
202
- ].freeze
203
- private_constant :PHASE_CLASSES
204
-
205
- def execute
206
- ProgressMonitor.instance.reset(@project_name, PHASE_CLASSES.size)
207
-
208
- Report.new(msg_fpath, met_fpath) do |report|
209
- context = PhaseContext.new(report, log_fpath)
210
-
211
- context[:project_name] = @project_name
212
- context[:metric_fpaths] = @fpaths
213
-
214
- PHASE_CLASSES.each do |phase_class|
215
- phase_class.new(context).execute
216
- end
179
+ def execute(monitor)
180
+ Report.new(msg_fpath, met_fpath, log_fpath, @verbose) do |report|
181
+ phase_ctxt = PhaseContext.new(self, report, monitor)
182
+ phase_ctxt[:metric_fpaths] = @met_fpaths
183
+ phase_ctxt[:annotations] = []
184
+ phase_ctxt[:suppressors] = MessageSuppressorSet.new
185
+
186
+ phases.each { |phase| phase.new(phase_ctxt).execute }
187
+ phase_ctxt.flush_deferred_report!
217
188
  end
218
189
  rescue
219
- if verbose?
220
- $stderr.puts "An error was occurred while executing " +
221
- "cross module analysis."
190
+ if @verbose
191
+ $stderr.puts "Error was occurred in cross module analysis."
222
192
  $stderr.puts "See `#{log_fpath}' for more details."
223
193
  end
224
194
  raise
225
195
  end
226
196
 
197
+ def phases
198
+ [
199
+ Ld::MapTypedefPhase,
200
+ Ld::MapFunctionPhase,
201
+ Ld::MapVariablePhase,
202
+ Ld::LinkFunctionPhase,
203
+ Ld::LinkVariablePhase,
204
+ Ld::PreparePhase,
205
+ Ld::TypedefReviewPhase,
206
+ Ld::FunctionReviewPhase,
207
+ Ld::VariableReviewPhase,
208
+ Ld::ExaminationPhase
209
+ ]
210
+ end
211
+
227
212
  def msg_fpath
228
- if @output_dpath
229
- @output_dpath.join(Pathname.new(@project_name)).add_ext(".msg.csv")
230
- else
231
- Pathname.new(@project_name).add_ext(".msg.csv")
232
- end
213
+ proj_name = @traits.of_project.project_name
214
+ msg_fname = Pathname.new(proj_name).add_ext(".msg.csv")
215
+ @output_dpath ? @output_dpath.join(msg_fname) : msg_fname
233
216
  end
234
217
 
235
218
  def met_fpath
236
- if @output_dpath
237
- @output_dpath.join(Pathname.new(@project_name)).add_ext(".met.csv")
238
- else
239
- Pathname.new(@project_name).add_ext(".met.csv")
240
- end
219
+ proj_name = @traits.of_project.project_name
220
+ met_fname = Pathname.new(proj_name).add_ext(".met.csv")
221
+ @output_dpath ? @output_dpath.join(met_fname) : met_fname
241
222
  end
242
223
  end
243
224
 
244
225
  # == Configuration files validator.
245
226
  class ConfigurationValidator < Analyzer
246
- def initialize(fpath, strip_num = 0, output_dpath = nil)
247
- super("CHK-#{SHORT_VERSION}", fpath.strip(strip_num), output_dpath)
248
-
249
- @fpath = fpath
227
+ def initialize(traits, msg_catalog, src_fpath, strip_num, output_dpath,
228
+ verbose)
229
+ super("CHK-#{SHORT_VERSION}", traits, msg_catalog, src_fpath.to_s,
230
+ output_dpath, src_fpath.strip(strip_num), verbose)
231
+ @src_fpath = src_fpath
250
232
  @strip_num = strip_num
251
233
  end
252
234
 
253
235
  private
254
- def execute
255
- lang = Language.of(@fpath)
256
- return unless lang
257
-
258
- ProgressMonitor.instance.reset(@fpath, lang.check_phases.size)
236
+ def execute(monitor)
237
+ Report.new(msg_fpath, met_fpath, log_fpath, @verbose) do |report|
238
+ src = Source.new(@src_fpath, @traits.of_project.file_encoding)
259
239
 
260
- Report.new(msg_fpath, met_fpath) do |report|
261
- context = PhaseContext.new(report, log_fpath)
262
-
263
- context[:sources] = [Source.new(@fpath)]
264
- context[:symbol_table] = SymbolTable.new
240
+ phase_ctxt = PhaseContext.new(self, report, monitor)
241
+ phase_ctxt[:sources] = [src]
242
+ phase_ctxt[:annotations] = []
243
+ phase_ctxt[:suppressors] = MessageSuppressorSet.new
244
+ phase_ctxt[:symbol_table] = SymbolTable.new
265
245
 
266
246
  begin
267
- lang.check_phases.each do |phase_class|
268
- phase_class.new(context).execute
269
- end
247
+ phases.each { |phase| phase.new(phase_ctxt).execute }
248
+ phase_ctxt.flush_deferred_report!
270
249
  ensure
271
250
  File.open(i_fpath, "w") do |io|
272
251
  io.set_encoding(Encoding.default_external)
273
- io.puts(context[:c_source].to_s)
252
+ io.puts(phase_ctxt[:cc1_source].to_s)
274
253
  end
275
254
  end
276
255
  end
277
256
  rescue
278
- if verbose?
279
- $stderr.puts "An error was occurred while processing `#{@fpath}'."
257
+ if @verbose
258
+ $stderr.puts "An error was occurred while processing `#{@src_fpath}'."
280
259
  $stderr.puts "See `#{msg_fpath}' and `#{log_fpath}' for more details."
281
260
  end
282
261
  raise
283
262
  end
284
263
 
264
+ def phases
265
+ (lang = Language.of(@src_fpath)) ? lang.check_phases : []
266
+ end
267
+
285
268
  def msg_fpath
286
- if @output_dpath
287
- @output_dpath.join(@fpath.strip(@strip_num)).add_ext(".msg.csv")
288
- else
289
- @fpath.strip(@strip_num).add_ext(".msg.csv")
290
- end
269
+ msg_fname = @src_fpath.strip(@strip_num).add_ext(".msg.csv")
270
+ @output_dpath ? @output_dpath.join(msg_fname) : msg_fname
291
271
  end
292
272
 
293
273
  def met_fpath
294
- if @output_dpath
295
- @output_dpath.join(@fpath.strip(@strip_num)).add_ext(".met.csv")
296
- else
297
- @fpath.strip(@strip_num).add_ext(".met.csv")
298
- end
274
+ met_fname = @fpath.strip(@strip_num).add_ext(".met.csv")
275
+ @output_dpath ? @output_dpath.join(met_fname) : met_fname
299
276
  end
300
277
 
301
278
  def i_fpath
302
- if @output_dpath
303
- @output_dpath.join(@fpath.strip(@strip_num)).sub_ext(".i")
304
- else
305
- @fpath.strip(@strip_num).sub_ext(".i")
306
- end
279
+ i_fname = @fpath.strip(@strip_num).sub_ext(".i")
280
+ @output_dpath ? @output_dpath.join(i_fname) : i_fname
307
281
  end
308
282
  end
309
283