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
@@ -1,7 +1,7 @@
1
1
  # C conversion semantics.
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
  #
@@ -30,63 +30,64 @@
30
30
  #++
31
31
 
32
32
  module AdLint #:nodoc:
33
- module C #:nodoc:
33
+ module Cc1 #:nodoc:
34
34
 
35
- # Host class of this module must include InterpreterMediator.
36
35
  module Conversion
37
- def do_conversion(original, to_type)
38
- if original.type.coercible?(to_type)
36
+ # NOTE: Host class of this module must include InterpreterMediator.
37
+
38
+ def do_conversion(org_var, to_type)
39
+ if org_var.type.coercible?(to_type)
39
40
  # NOTE: Value will be coerced into the destination type in
40
- # VariableTableMediator#create_tempvar.
41
- create_tempvar(to_type, wrap_around_value(original, to_type))
41
+ # VariableTableMediator#create_tmpvar.
42
+ create_tmpvar(to_type, wrap_around_value(org_var, to_type))
42
43
  else
43
44
  nil
44
45
  end
45
46
  end
46
47
 
47
- def do_integer_promotion(original)
48
- return original unless original.type.integer?
48
+ def do_integer_promotion(org_var)
49
+ return org_var unless org_var.type.integer?
49
50
 
50
- promoted_type = original.type.integer_promoted_type
51
- if original.type.same_as?(promoted_type)
52
- original
51
+ promoted_type = org_var.type.integer_promoted_type
52
+ if org_var.type.same_as?(promoted_type)
53
+ org_var
53
54
  else
54
- do_conversion(original, promoted_type) || original
55
+ do_conversion(org_var, promoted_type) || org_var
55
56
  end
56
57
  end
57
58
 
58
- def do_usual_arithmetic_conversion(lhs_original, rhs_original)
59
- if lhs_original.type.pointer? && rhs_original.type.pointer?
60
- return lhs_original, rhs_original
59
+ def do_usual_arithmetic_conversion(lhs_org, rhs_org)
60
+ if lhs_org.type.pointer? && rhs_org.type.pointer?
61
+ return lhs_org, rhs_org
61
62
  end
62
63
 
63
- arith_type = lhs_original.type.arithmetic_type_with(rhs_original.type)
64
+ arith_type = lhs_org.type.arithmetic_type_with(rhs_org.type)
64
65
 
65
- if lhs_original.type.same_as?(arith_type)
66
- lhs_converted = lhs_original
66
+ if lhs_org.type.same_as?(arith_type)
67
+ lhs_conved = lhs_org
67
68
  else
68
- lhs_converted = do_conversion(lhs_original, arith_type) || lhs_original
69
+ lhs_conved = do_conversion(lhs_org, arith_type) || lhs_org
69
70
  end
70
71
 
71
- if rhs_original.type.same_as?(arith_type)
72
- rhs_converted = rhs_original
72
+ if rhs_org.type.same_as?(arith_type)
73
+ rhs_conved = rhs_org
73
74
  else
74
- rhs_converted = do_conversion(rhs_original, arith_type) || rhs_original
75
+ rhs_conved = do_conversion(rhs_org, arith_type) || rhs_org
75
76
  end
76
77
 
77
- return lhs_converted, rhs_converted
78
+ return lhs_conved, rhs_conved
78
79
  end
79
80
 
80
- def do_default_argument_promotion(original)
81
- promoted_type = original.type.argument_promoted_type
82
- if original.type.same_as?(promoted_type)
83
- original
81
+ def do_default_argument_promotion(org_var)
82
+ promoted_type = org_var.type.argument_promoted_type
83
+ if org_var.type.same_as?(promoted_type)
84
+ org_var
84
85
  else
85
- do_conversion(original, promoted_type) || original
86
+ do_conversion(org_var, promoted_type) || org_var
86
87
  end
87
88
  end
88
89
 
89
- def untyped_pointer_conversion?(from_type, to_type, from_value)
90
+ def untyped_pointer_conversion?(from_type, to_type, from_val)
90
91
  return false unless to_type.pointer?
91
92
 
92
93
  # NOTE: Untyped pointer conversion is defined as below;
@@ -97,8 +98,8 @@ module C #:nodoc:
97
98
  # void pointer | non-void pointer | true
98
99
  # non-void pointer | void pointer | true
99
100
  # non-void pointer | non-void pointer | false
100
- # non-enum integer | void pointer | from_value == 0
101
- # non-enum integer | non-void pointer | from_value == 0
101
+ # non-enum integer | void pointer | from_val == 0
102
+ # non-enum integer | non-void pointer | from_val == 0
102
103
  # enum | void pointer | false
103
104
  # enum | non-void pointer | false
104
105
  # other | void pointer | true
@@ -107,41 +108,41 @@ module C #:nodoc:
107
108
  when from_type.pointer?
108
109
  void_pointer?(from_type) || void_pointer?(to_type)
109
110
  when from_type.integer?
110
- !from_type.enum? && from_value.must_be_equal_to?(ScalarValue.of(0))
111
+ !from_type.enum? && from_val.must_be_equal_to?(scalar_value_of(0))
111
112
  else
112
113
  void_pointer?(to_type)
113
114
  end
114
115
  end
115
116
 
116
117
  private
117
- def wrap_around_value(original, to_type)
118
- return original.value unless original.type.scalar? && to_type.scalar?
118
+ def wrap_around_value(org_var, to_type)
119
+ return org_var.value unless org_var.type.scalar? && to_type.scalar?
119
120
 
120
121
  case
121
- when original.type.signed? && to_type.unsigned?
122
- min = ScalarValue.of(to_type.min_value)
123
- if (original.value < min).may_be_true?
124
- return min - original.value + ScalarValue.of(1)
122
+ when org_var.type.signed? && to_type.unsigned?
123
+ min_val = scalar_value_of(to_type.min)
124
+ if (org_var.value < min_val).may_be_true?
125
+ return min_val - org_var.value + scalar_value_of(1)
125
126
  end
126
- when original.type.unsigned? && to_type.signed?
127
- max = ScalarValue.of(to_type.max_value)
128
- if (original.value > max).may_be_true?
129
- return max - original.value + ScalarValue.of(1)
127
+ when org_var.type.unsigned? && to_type.signed?
128
+ max_val = scalar_value_of(to_type.max)
129
+ if (org_var.value > max_val).may_be_true?
130
+ return max_val - org_var.value + scalar_value_of(1)
130
131
  end
131
132
  end
132
133
 
133
- original.value
134
+ org_var.value
134
135
  end
135
136
 
136
137
  def void_pointer?(type)
137
- unqualified_type = type.unqualify
138
- unqualified_type.pointer? && unqualified_type.base_type.void?
138
+ unqual_type = type.unqualify
139
+ unqual_type.pointer? && unqual_type.base_type.void?
139
140
  end
140
141
  end
141
142
 
142
143
  # Host class of this module must include StandardTypeCatalogAccessor.
143
144
  module UsualArithmeticTypeConversion
144
- def do_usual_arithmetic_type_conversion(lhs_type, rhs_type)
145
+ def do_usual_arithmetic_type_conversion(lhs, rhs)
145
146
  # NOTE: The ISO C99 standard says;
146
147
  #
147
148
  # 6.3.1.8 Usual arithmetic conversions
@@ -194,46 +195,43 @@ module C #:nodoc:
194
195
  # type corresponding to the type of the operand with signed integer
195
196
  # type.
196
197
 
197
- if lhs_type.same_as?(long_double_type) ||
198
- rhs_type.same_as?(long_double_type)
199
- return long_double_type
198
+ if lhs.same_as?(long_double_t) || rhs.same_as?(long_double_t)
199
+ return long_double_t
200
200
  end
201
201
 
202
- if lhs_type.same_as?(double_type) || rhs_type.same_as?(double_type)
203
- return double_type
202
+ if lhs.same_as?(double_t) || rhs.same_as?(double_t)
203
+ return double_t
204
204
  end
205
205
 
206
- if lhs_type.same_as?(float_type) || rhs_type.same_as?(float_type)
207
- return float_type
206
+ if lhs.same_as?(float_t) || rhs.same_as?(float_t)
207
+ return float_t
208
208
  end
209
209
 
210
- lhs_promoted_type = lhs_type.integer_promoted_type
211
- rhs_promoted_type = rhs_type.integer_promoted_type
210
+ lhs_promoted = lhs.integer_promoted_type
211
+ rhs_promoted = rhs.integer_promoted_type
212
212
 
213
- return lhs_promoted_type if lhs_promoted_type.same_as?(rhs_promoted_type)
213
+ return lhs_promoted if lhs_promoted.same_as?(rhs_promoted)
214
214
 
215
- lhs_rank = lhs_promoted_type.integer_conversion_rank
216
- rhs_rank = rhs_promoted_type.integer_conversion_rank
215
+ lhs_rank = lhs_promoted.integer_conversion_rank
216
+ rhs_rank = rhs_promoted.integer_conversion_rank
217
217
 
218
218
  case
219
- when lhs_promoted_type.signed? && rhs_promoted_type.signed?
220
- return lhs_rank < rhs_rank ? rhs_promoted_type : lhs_promoted_type
221
- when lhs_promoted_type.unsigned? && rhs_promoted_type.unsigned?
222
- return lhs_rank < rhs_rank ? rhs_promoted_type : lhs_promoted_type
223
- when lhs_promoted_type.unsigned? && lhs_rank >= rhs_rank
224
- return lhs_promoted_type
225
- when rhs_promoted_type.unsigned? && lhs_rank <= rhs_rank
226
- return rhs_promoted_type
227
- when lhs_promoted_type.signed? &&
228
- rhs_promoted_type.compatible?(lhs_promoted_type)
229
- return lhs_promoted_type
230
- when rhs_promoted_type.signed? &&
231
- lhs_promoted_type.compatible?(rhs_promoted_type)
232
- return rhs_promoted_type
233
- when lhs_promoted_type.signed?
234
- return lhs_promoted_type.corresponding_unsigned_type
235
- when rhs_promoted_type.signed?
236
- return rhs_promoted_type.corresponding_unsigned_type
219
+ when lhs_promoted.signed? && rhs_promoted.signed?
220
+ return lhs_rank < rhs_rank ? rhs_promoted : lhs_promoted
221
+ when lhs_promoted.unsigned? && rhs_promoted.unsigned?
222
+ return lhs_rank < rhs_rank ? rhs_promoted : lhs_promoted
223
+ when lhs_promoted.unsigned? && lhs_rank >= rhs_rank
224
+ return lhs_promoted
225
+ when rhs_promoted.unsigned? && lhs_rank <= rhs_rank
226
+ return rhs_promoted
227
+ when lhs_promoted.signed? && rhs_promoted.compatible?(lhs_promoted)
228
+ return lhs_promoted
229
+ when rhs_promoted.signed? && lhs_promoted.compatible?(rhs_promoted)
230
+ return rhs_promoted
231
+ when lhs_promoted.signed?
232
+ return lhs_promoted.corresponding_unsigned_type
233
+ when rhs_promoted.signed?
234
+ return rhs_promoted.corresponding_unsigned_type
237
235
  end
238
236
 
239
237
  raise TypeError, "cannot do usual arithmetic conversion."
@@ -1,7 +1,7 @@
1
1
  # Controlling expression of selection-statements and iteration-statements.
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
  #
@@ -29,16 +29,16 @@
29
29
  #
30
30
  #++
31
31
 
32
- require "adlint/c/syntax"
33
- require "adlint/c/object"
34
- require "adlint/c/mediator"
35
- require "adlint/c/expr"
36
- require "adlint/c/conv"
37
- require "adlint/c/operator"
38
- require "adlint/c/seqp"
32
+ require "adlint/cc1/syntax"
33
+ require "adlint/cc1/object"
34
+ require "adlint/cc1/mediator"
35
+ require "adlint/cc1/expr"
36
+ require "adlint/cc1/conv"
37
+ require "adlint/cc1/operator"
38
+ require "adlint/cc1/seqp"
39
39
 
40
40
  module AdLint #:nodoc:
41
- module C #:nodoc:
41
+ module Cc1 #:nodoc:
42
42
 
43
43
  # == DESCRIPTION
44
44
  # === Class structure
@@ -59,15 +59,15 @@ module C #:nodoc:
59
59
  class ControllingExpression
60
60
  include SyntaxNodeCollector
61
61
 
62
- def initialize(interpreter, branch, target_expr = nil)
63
- @interpreter = interpreter
62
+ def initialize(interp, branch, target_expr = nil)
63
+ @interpreter = interp
64
64
  @branch = branch
65
65
  @target_expr = target_expr
66
66
  @manipulators = []
67
67
  end
68
68
 
69
69
  def ensure_true_by_narrowing(alt_expr = nil)
70
- target_expr = alt_expr ? alt_expr : @target_expr
70
+ target_expr = alt_expr || @target_expr
71
71
 
72
72
  if target_expr
73
73
  new_manip = ValueDomainNarrower.new(@interpreter, target_expr)
@@ -85,7 +85,7 @@ module C #:nodoc:
85
85
  end
86
86
 
87
87
  def ensure_true_by_widening(alt_expr = nil)
88
- target_expr = alt_expr ? alt_expr : @target_expr
88
+ target_expr = alt_expr || @target_expr
89
89
 
90
90
  if target_expr
91
91
  new_manip = ValueDomainWidener.new(@interpreter, target_expr)
@@ -145,8 +145,8 @@ module C #:nodoc:
145
145
  include ExpressionEvaluator::Impl
146
146
  include MonitorUtil
147
147
 
148
- def initialize(interpreter, target_expr)
149
- @interpreter = interpreter
148
+ def initialize(interp, target_expr)
149
+ @interpreter = interp
150
150
  @target_expr = target_expr
151
151
  @affected_variables = []
152
152
  @narrowing = nil
@@ -165,7 +165,7 @@ module C #:nodoc:
165
165
 
166
166
  def commit!
167
167
  if @narrowing
168
- @narrowing.ensure_result_equal_to(ScalarValue.of_true)
168
+ @narrowing.ensure_result_equal_to(scalar_value_of_true)
169
169
  end
170
170
 
171
171
  commit_changes(@narrowing)
@@ -179,7 +179,7 @@ module C #:nodoc:
179
179
  def rollback!
180
180
  # NOTE: Rollback narrowed version to cut out the value-domain to enter
181
181
  # the current branch.
182
- @affected_variables.each { |variable| variable.value.rollback! }
182
+ @affected_variables.each { |var| var.value.rollback! }
183
183
  end
184
184
 
185
185
  def save!
@@ -213,8 +213,7 @@ module C #:nodoc:
213
213
 
214
214
  def visit_array_subscript_expression(node)
215
215
  checkpoint(node.location)
216
-
217
- obj_manip = node.expression.accept(self)
216
+ obj_manip = node.expression.accept(self)
218
217
  subs_manip = node.array_subscript.accept(self)
219
218
 
220
219
  DelayedObjectDerivation.new(self, node, obj_manip, subs_manip) do
@@ -227,7 +226,6 @@ module C #:nodoc:
227
226
 
228
227
  def visit_function_call_expression(node)
229
228
  checkpoint(node.location)
230
-
231
229
  obj_manip = node.expression.accept(self)
232
230
  arg_manips = node.argument_expressions.map { |expr| expr.accept(self) }
233
231
 
@@ -241,7 +239,6 @@ module C #:nodoc:
241
239
 
242
240
  def visit_member_access_by_value_expression(node)
243
241
  checkpoint(node.location)
244
-
245
242
  obj_manip = node.expression.accept(self)
246
243
 
247
244
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -253,7 +250,6 @@ module C #:nodoc:
253
250
 
254
251
  def visit_member_access_by_pointer_expression(node)
255
252
  checkpoint(node.location)
256
-
257
253
  obj_manip = node.expression.accept(self)
258
254
 
259
255
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -268,7 +264,6 @@ module C #:nodoc:
268
264
 
269
265
  def visit_postfix_increment_expression(node)
270
266
  checkpoint(node.location)
271
-
272
267
  obj_manip = node.operand.accept(self)
273
268
 
274
269
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -280,7 +275,6 @@ module C #:nodoc:
280
275
 
281
276
  def visit_postfix_decrement_expression(node)
282
277
  checkpoint(node.location)
283
-
284
278
  obj_manip = node.operand.accept(self)
285
279
 
286
280
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -294,7 +288,6 @@ module C #:nodoc:
294
288
 
295
289
  def visit_prefix_increment_expression(node)
296
290
  checkpoint(node.location)
297
-
298
291
  obj_manip = node.operand.accept(self)
299
292
 
300
293
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -306,7 +299,6 @@ module C #:nodoc:
306
299
 
307
300
  def visit_prefix_decrement_expression(node)
308
301
  checkpoint(node.location)
309
-
310
302
  obj_manip = node.operand.accept(self)
311
303
 
312
304
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -320,7 +312,6 @@ module C #:nodoc:
320
312
 
321
313
  def visit_indirection_expression(node)
322
314
  checkpoint(node.location)
323
-
324
315
  obj_manip = node.operand.accept(self)
325
316
 
326
317
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -332,7 +323,6 @@ module C #:nodoc:
332
323
 
333
324
  def visit_unary_arithmetic_expression(node)
334
325
  checkpoint(node.location)
335
-
336
326
  obj_manip = node.operand.accept(self)
337
327
 
338
328
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -349,7 +339,6 @@ module C #:nodoc:
349
339
 
350
340
  def visit_cast_expression(node)
351
341
  checkpoint(node.location)
352
-
353
342
  obj_manip = node.operand.accept(self)
354
343
 
355
344
  DelayedObjectDerivation.new(self, node, obj_manip) do
@@ -361,7 +350,6 @@ module C #:nodoc:
361
350
 
362
351
  def visit_multiplicative_expression(node)
363
352
  checkpoint(node.location)
364
-
365
353
  lhs_manip = node.lhs_operand.accept(self)
366
354
  rhs_manip = node.rhs_operand.accept(self)
367
355
 
@@ -375,7 +363,6 @@ module C #:nodoc:
375
363
 
376
364
  def visit_additive_expression(node)
377
365
  checkpoint(node.location)
378
-
379
366
  lhs_manip = node.lhs_operand.accept(self)
380
367
  rhs_manip = node.rhs_operand.accept(self)
381
368
 
@@ -389,7 +376,6 @@ module C #:nodoc:
389
376
 
390
377
  def visit_shift_expression(node)
391
378
  checkpoint(node.location)
392
-
393
379
  lhs_manip = node.lhs_operand.accept(self)
394
380
  rhs_manip = node.rhs_operand.accept(self)
395
381
 
@@ -415,7 +401,6 @@ module C #:nodoc:
415
401
 
416
402
  def visit_and_expression(node)
417
403
  checkpoint(node.location)
418
-
419
404
  lhs_manip = node.lhs_operand.accept(self)
420
405
  rhs_manip = node.rhs_operand.accept(self)
421
406
 
@@ -429,7 +414,6 @@ module C #:nodoc:
429
414
 
430
415
  def visit_exclusive_or_expression(node)
431
416
  checkpoint(node.location)
432
-
433
417
  lhs_manip = node.lhs_operand.accept(self)
434
418
  rhs_manip = node.rhs_operand.accept(self)
435
419
 
@@ -443,7 +427,6 @@ module C #:nodoc:
443
427
 
444
428
  def visit_inclusive_or_expression(node)
445
429
  checkpoint(node.location)
446
-
447
430
  lhs_manip = node.lhs_operand.accept(self)
448
431
  rhs_manip = node.rhs_operand.accept(self)
449
432
 
@@ -471,7 +454,6 @@ module C #:nodoc:
471
454
 
472
455
  def visit_simple_assignment_expression(node)
473
456
  checkpoint(node.location)
474
-
475
457
  lhs_manip = node.lhs_operand.accept(self)
476
458
  rhs_manip = node.rhs_operand.accept(self)
477
459
 
@@ -485,7 +467,6 @@ module C #:nodoc:
485
467
 
486
468
  def visit_compound_assignment_expression(node)
487
469
  checkpoint(node.location)
488
-
489
470
  lhs_manip = node.lhs_operand.accept(self)
490
471
  rhs_manip = node.rhs_operand.accept(self)
491
472
 
@@ -499,7 +480,6 @@ module C #:nodoc:
499
480
 
500
481
  def visit_comma_separated_expression(node)
501
482
  checkpoint(node.location)
502
-
503
483
  obj_manips = node.expressions.map { |expr| expr.accept(self) }
504
484
 
505
485
  DelayedObjectDerivation.new(self, node, *obj_manips) do
@@ -512,6 +492,11 @@ module C #:nodoc:
512
492
  def commit_changes(manip)
513
493
  subclass_responsibility
514
494
  end
495
+
496
+ extend Forwardable
497
+
498
+ def_delegator :@interpreter, :monitor
499
+ private :monitor
515
500
  end
516
501
 
517
502
  class ValueDomainNarrower < ValueDomainManipulator
@@ -533,9 +518,9 @@ module C #:nodoc:
533
518
  end
534
519
 
535
520
  class NilValueDomainNarrower < ValueDomainManipulator
536
- def initialize(interpreter, branch_group)
537
- super(interpreter, nil)
538
- @branch_group = branch_group
521
+ def initialize(interp, br_group)
522
+ super(interp, nil)
523
+ @branch_group = br_group
539
524
  end
540
525
 
541
526
  def prepare!
@@ -552,9 +537,9 @@ module C #:nodoc:
552
537
  end
553
538
 
554
539
  class NilValueDomainWidener < ValueDomainManipulator
555
- def initialize(interpreter, branch_group)
556
- super(interpreter, nil)
557
- @branch_group = branch_group
540
+ def initialize(interp, br_group)
541
+ super(interp, nil)
542
+ @branch_group = br_group
558
543
  end
559
544
 
560
545
  def prepare!
@@ -599,8 +584,8 @@ module C #:nodoc:
599
584
  @narrowed_values = manip.narrowed_values.merge(@narrowed_values)
600
585
  end
601
586
  ensure
602
- if result && result.variable?
603
- notify_variable_value_referred(node, result)
587
+ if @result && @result.variable?
588
+ notify_variable_value_referred(node, @result)
604
589
  end
605
590
  if seqp = node.subsequent_sequence_point
606
591
  notify_sequence_point_reached(seqp)
@@ -663,9 +648,9 @@ module C #:nodoc:
663
648
  rhs_vals = rhs_manip.narrowed_values
664
649
 
665
650
  @narrowed_values = lhs_vals.merge(rhs_vals) { |key, lhs_val, rhs_val|
666
- result = lhs_val.dup
667
- result.narrow_domain!(Operator::EQ, rhs_val)
668
- result
651
+ res_val = lhs_val.dup
652
+ res_val.narrow_domain!(Operator::EQ, rhs_val)
653
+ res_val
669
654
  }
670
655
  end
671
656
 
@@ -674,18 +659,16 @@ module C #:nodoc:
674
659
  rhs_vals = rhs_manip.narrowed_values
675
660
 
676
661
  @narrowed_values = lhs_vals.merge(rhs_vals) { |key, lhs_val, rhs_val|
677
- result = lhs_val.dup
678
- result.widen_domain!(Operator::EQ, rhs_val)
679
- result
662
+ res_val = lhs_val.dup
663
+ res_val.widen_domain!(Operator::EQ, rhs_val)
664
+ res_val
680
665
  }
681
666
  end
682
667
 
683
- def interpreter
684
- # NOTE: This is private attr_reader for InterpreterMediator.
685
- # This attribute is read via a normal method to suppress
686
- # `private attribute?' warning.
687
- @manipulator.interpreter
688
- end
668
+ extend Forwardable
669
+
670
+ def_delegator :@manipulator, :interpreter
671
+ private :interpreter
689
672
  end
690
673
 
691
674
  class ValueComparison < ValueDomainNarrowing
@@ -705,11 +688,11 @@ module C #:nodoc:
705
688
  rhs_var = object_to_variable(@rhs_manip.result)
706
689
 
707
690
  unless lhs_var.type.scalar? && rhs_var.type.scalar?
708
- return create_tempvar(int_type)
691
+ return create_tmpvar(int_t)
709
692
  end
710
693
 
711
694
  unless lhs_var.value.scalar? && rhs_var.value.scalar?
712
- return create_tempvar(int_type)
695
+ return create_tmpvar(int_t)
713
696
  end
714
697
 
715
698
  lhs_conved, rhs_conved =
@@ -720,17 +703,17 @@ module C #:nodoc:
720
703
 
721
704
  case @operator
722
705
  when Operator::EQ
723
- result = create_tempvar(int_type, lhs_val == rhs_val)
706
+ res_var = create_tmpvar(int_t, lhs_val == rhs_val)
724
707
  when Operator::NE
725
- result = create_tempvar(int_type, lhs_val != rhs_val)
708
+ res_var = create_tmpvar(int_t, lhs_val != rhs_val)
726
709
  when Operator::LT
727
- result = create_tempvar(int_type, lhs_val < rhs_val)
710
+ res_var = create_tmpvar(int_t, lhs_val < rhs_val)
728
711
  when Operator::GT
729
- result = create_tempvar(int_type, lhs_val > rhs_val)
712
+ res_var = create_tmpvar(int_t, lhs_val > rhs_val)
730
713
  when Operator::LE
731
- result = create_tempvar(int_type, lhs_val <= rhs_val)
714
+ res_var = create_tmpvar(int_t, lhs_val <= rhs_val)
732
715
  when Operator::GE
733
- result = create_tempvar(int_type, lhs_val >= rhs_val)
716
+ res_var = create_tmpvar(int_t, lhs_val >= rhs_val)
734
717
  else
735
718
  __NOTREACHED__
736
719
  end
@@ -740,9 +723,9 @@ module C #:nodoc:
740
723
 
741
724
  case @operator
742
725
  when Operator::EQ, Operator::NE
743
- notify_equality_expr_evaled(@node, lhs_conved, rhs_conved, result)
726
+ notify_equality_expr_evaled(@node, lhs_conved, rhs_conved, res_var)
744
727
  when Operator::LT, Operator::GT, Operator::LE, Operator::GE
745
- notify_relational_expr_evaled(@node, lhs_conved, rhs_conved, result)
728
+ notify_relational_expr_evaled(@node, lhs_conved, rhs_conved, res_var)
746
729
  else
747
730
  __NOTREACHED__
748
731
  end
@@ -756,7 +739,7 @@ module C #:nodoc:
756
739
  # NOTE: Domain of the rvalue should not be narrowed.
757
740
  end
758
741
 
759
- result
742
+ res_var
760
743
  end
761
744
  end
762
745
 
@@ -770,7 +753,7 @@ module C #:nodoc:
770
753
  private
771
754
  def do_narrowing
772
755
  @lhs_manip.execute!
773
- @lhs_manip.ensure_result_equal_to(ScalarValue.of_true)
756
+ @lhs_manip.ensure_result_equal_to(scalar_value_of_true)
774
757
  lhs_var = object_to_variable(@lhs_manip.result)
775
758
 
776
759
  # NOTE: The ISO C99 standard says;
@@ -788,7 +771,7 @@ module C #:nodoc:
788
771
  # TODO: Must look about the short-circuit evaluation.
789
772
  @rhs_manip.load_original_values!(@lhs_manip)
790
773
  @rhs_manip.execute!
791
- @rhs_manip.ensure_result_equal_to(ScalarValue.of_true)
774
+ @rhs_manip.ensure_result_equal_to(scalar_value_of_true)
792
775
  rhs_var = object_to_variable(@rhs_manip.result)
793
776
 
794
777
  notify_sequence_point_reached(SequencePoint.new(@node.rhs_operand))
@@ -798,11 +781,11 @@ module C #:nodoc:
798
781
  notify_variable_value_referred(@node, rhs_var)
799
782
 
800
783
  unless lhs_var.type.scalar? && rhs_var.type.scalar?
801
- return create_tempvar(int_type)
784
+ return create_tmpvar(int_t)
802
785
  end
803
786
 
804
787
  unless lhs_var.value.scalar? && rhs_var.value.scalar?
805
- return create_tempvar(int_type)
788
+ return create_tmpvar(int_t)
806
789
  end
807
790
 
808
791
  lhs_conved, rhs_conved =
@@ -811,9 +794,9 @@ module C #:nodoc:
811
794
  lhs_val = lhs_conved.value
812
795
  rhs_val = rhs_conved.value
813
796
 
814
- result = create_tempvar(int_type, lhs_val.logical_and(rhs_val))
815
- notify_logical_and_expr_evaled(@node, lhs_conved, rhs_conved, result)
816
- result
797
+ res_var = create_tmpvar(int_t, lhs_val.logical_and(rhs_val))
798
+ notify_logical_and_expr_evaled(@node, lhs_conved, rhs_conved, res_var)
799
+ res_var
817
800
  end
818
801
  end
819
802
 
@@ -827,7 +810,7 @@ module C #:nodoc:
827
810
  private
828
811
  def do_narrowing
829
812
  @lhs_manip.execute!
830
- @lhs_manip.ensure_result_equal_to(ScalarValue.of_true)
813
+ @lhs_manip.ensure_result_equal_to(scalar_value_of_true)
831
814
  lhs_var = object_to_variable(@lhs_manip.result)
832
815
 
833
816
  # NOTE: The ISO C99 standard says;
@@ -846,7 +829,7 @@ module C #:nodoc:
846
829
  # FIXME: Base value of the RHS narrowing should be updated to ensure that
847
830
  # the LHS condition is false.
848
831
  @rhs_manip.execute!
849
- @rhs_manip.ensure_result_equal_to(ScalarValue.of_true)
832
+ @rhs_manip.ensure_result_equal_to(scalar_value_of_true)
850
833
  rhs_var = object_to_variable(@rhs_manip.result)
851
834
 
852
835
  notify_sequence_point_reached(SequencePoint.new(@node.rhs_operand))
@@ -856,11 +839,11 @@ module C #:nodoc:
856
839
  notify_variable_value_referred(@node, rhs_var)
857
840
 
858
841
  unless lhs_var.type.scalar? && rhs_var.type.scalar?
859
- return create_tempvar(int_type)
842
+ return create_tmpvar(int_t)
860
843
  end
861
844
 
862
845
  unless lhs_var.value.scalar? && rhs_var.value.scalar?
863
- return create_tempvar(int_type)
846
+ return create_tmpvar(int_t)
864
847
  end
865
848
 
866
849
  lhs_conved, rhs_conved =
@@ -869,9 +852,9 @@ module C #:nodoc:
869
852
  lhs_val = lhs_conved.value
870
853
  rhs_val = rhs_conved.value
871
854
 
872
- result = create_tempvar(int_type, lhs_val.logical_or(rhs_val))
873
- notify_logical_or_expr_evaled(@node, lhs_conved, rhs_conved, result)
874
- result
855
+ res_var = create_tmpvar(int_t, lhs_val.logical_or(rhs_val))
856
+ notify_logical_or_expr_evaled(@node, lhs_conved, rhs_conved, res_var)
857
+ res_var
875
858
  end
876
859
  end
877
860
 
@@ -884,8 +867,8 @@ module C #:nodoc:
884
867
  private
885
868
  def do_narrowing
886
869
  if @object.variable? && @object.named?
887
- if orig_val = original_value_of(@object)
888
- @object = PhantomVariable.new(@object, orig_val)
870
+ if org_val = original_value_of(@object)
871
+ @object = PhantomVariable.new(@object, org_val)
889
872
  end
890
873
  end
891
874
  @object