adlint 2.6.14 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (401) hide show
  1. data/AUTHORS +1 -3
  2. data/ChangeLog +511 -0
  3. data/INSTALL +1 -1
  4. data/MANIFEST +57 -37
  5. data/NEWS +36 -7
  6. data/README +2 -2
  7. data/Rakefile +6 -6
  8. data/TODO +1 -1
  9. data/bin/adlint +25 -16
  10. data/bin/adlint_chk +22 -12
  11. data/bin/adlint_cma +17 -12
  12. data/bin/adlint_sma +22 -12
  13. data/bin/adlintize +98 -17
  14. data/etc/conf.d/fallback/cinit.erb +1 -1
  15. data/etc/conf.d/fallback/traits.erb +37 -37
  16. data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
  17. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
  18. data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
  19. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
  20. data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
  21. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
  22. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
  23. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
  24. data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
  25. data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
  26. data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
  27. data/etc/conf.d/noarch/pinit.erb +1 -1
  28. data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
  29. data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
  30. data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
  31. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
  32. data/etc/mesg.d/core/en_US/messages.yml +2 -2
  33. data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
  34. data/features/code_check/W0018.feature +197 -0
  35. data/features/code_check/W0019.feature +79 -0
  36. data/features/code_check/W0021.feature +81 -0
  37. data/features/code_check/W0023.feature +203 -0
  38. data/features/code_check/W0024.feature +226 -0
  39. data/features/code_check/W0025.feature +5 -0
  40. data/features/code_check/W0088.feature +2 -2
  41. data/features/code_check/W0109.feature +2 -2
  42. data/features/code_check/W0477.feature +0 -3
  43. data/features/code_check/W0478.feature +0 -1
  44. data/features/code_check/W0582.feature +3 -3
  45. data/features/code_check/W0583.feature +4 -7
  46. data/features/code_check/W0646.feature +0 -1
  47. data/features/code_check/W0695.feature +0 -1
  48. data/features/code_check/W0705.feature +8 -0
  49. data/features/code_check/W0723.feature +0 -1
  50. data/features/code_check/W0745.feature +1 -0
  51. data/features/code_check/W0781.feature +1 -0
  52. data/features/code_check/W1057.feature +141 -0
  53. data/features/code_check/W1058.feature +93 -0
  54. data/features/code_check/W1059.feature +86 -0
  55. data/features/code_check/W1060.feature +77 -0
  56. data/features/code_check/W1061.feature +143 -0
  57. data/features/code_check/W1062.feature +162 -0
  58. data/features/code_check/W1063.feature +123 -0
  59. data/features/code_check/W1064.feature +83 -0
  60. data/features/code_check/W1065.feature +82 -0
  61. data/features/code_check/W9003.feature +2 -0
  62. data/features/step_definitions/code_check_steps.rb +1 -0
  63. data/features/support/env.rb +16 -13
  64. data/lib/adlint.rb +7 -4
  65. data/lib/adlint/analyzer.rb +131 -157
  66. data/lib/adlint/annot.rb +149 -0
  67. data/lib/adlint/cc1.rb +57 -0
  68. data/lib/adlint/{c → cc1}/branch.rb +74 -62
  69. data/lib/adlint/{c → cc1}/builtin.rb +21 -21
  70. data/lib/adlint/{c → cc1}/const.rb +119 -117
  71. data/lib/adlint/{c → cc1}/conv.rb +76 -78
  72. data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
  73. data/lib/adlint/cc1/domain.rb +8103 -0
  74. data/lib/adlint/{c → cc1}/enum.rb +3 -3
  75. data/lib/adlint/{c → cc1}/environ.rb +21 -21
  76. data/lib/adlint/{c → cc1}/expr.rb +232 -218
  77. data/lib/adlint/{c → cc1}/format.rb +305 -342
  78. data/lib/adlint/{c → cc1}/interp.rb +269 -220
  79. data/lib/adlint/cc1/lexer.rb +246 -0
  80. data/lib/adlint/{c → cc1}/mediator.rb +78 -84
  81. data/lib/adlint/{c → cc1}/object.rb +261 -264
  82. data/lib/adlint/{c → cc1}/operator.rb +7 -7
  83. data/lib/adlint/{c → cc1}/option.rb +4 -3
  84. data/lib/adlint/{c → cc1}/parser.rb +274 -506
  85. data/lib/adlint/{c → cc1}/parser.y +69 -301
  86. data/lib/adlint/cc1/phase.rb +138 -0
  87. data/lib/adlint/{c → cc1}/resolver.rb +66 -78
  88. data/lib/adlint/{c → cc1}/scanner.rb +57 -49
  89. data/lib/adlint/{c → cc1}/scope.rb +3 -3
  90. data/lib/adlint/{c → cc1}/seqp.rb +13 -5
  91. data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
  92. data/lib/adlint/{c → cc1}/type.rb +1498 -1479
  93. data/lib/adlint/{c → cc1}/util.rb +20 -12
  94. data/lib/adlint/{c → cc1}/value.rb +699 -642
  95. data/lib/adlint/code.rb +163 -164
  96. data/lib/adlint/cpp.rb +2 -2
  97. data/lib/adlint/cpp/asm.rb +13 -14
  98. data/lib/adlint/cpp/constexpr.rb +42 -38
  99. data/lib/adlint/cpp/constexpr.y +44 -40
  100. data/lib/adlint/cpp/eval.rb +435 -435
  101. data/lib/adlint/cpp/lexer.rb +343 -340
  102. data/lib/adlint/cpp/macro.rb +188 -190
  103. data/lib/adlint/cpp/phase.rb +66 -45
  104. data/lib/adlint/cpp/scanner.rb +14 -17
  105. data/lib/adlint/cpp/source.rb +49 -55
  106. data/lib/adlint/cpp/subst.rb +65 -65
  107. data/lib/adlint/cpp/syntax.rb +155 -275
  108. data/lib/adlint/cpp/util.rb +22 -19
  109. data/lib/adlint/driver.rb +86 -93
  110. data/lib/adlint/error.rb +33 -52
  111. data/lib/adlint/exam.rb +158 -24
  112. data/lib/adlint/exam/c_builtin.rb +7 -7
  113. data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
  114. data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
  115. data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
  116. data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
  117. data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
  118. data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
  119. data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
  120. data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
  121. data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
  122. data/lib/adlint/lang.rb +25 -25
  123. data/lib/adlint/ld.rb +2 -2
  124. data/lib/adlint/ld/object.rb +220 -188
  125. data/lib/adlint/ld/phase.rb +94 -63
  126. data/lib/adlint/ld/typedef.rb +22 -11
  127. data/lib/adlint/ld/util.rb +43 -35
  128. data/lib/adlint/lexer.rb +59 -56
  129. data/lib/adlint/location.rb +140 -0
  130. data/lib/adlint/memo.rb +157 -0
  131. data/lib/adlint/message.rb +207 -156
  132. data/lib/adlint/metric.rb +139 -217
  133. data/lib/adlint/monitor.rb +45 -43
  134. data/lib/adlint/phase.rb +56 -29
  135. data/lib/adlint/prelude.rb +66 -54
  136. data/lib/adlint/report.rb +253 -332
  137. data/lib/adlint/source.rb +26 -27
  138. data/lib/adlint/supp.rb +131 -0
  139. data/lib/adlint/symbol.rb +14 -16
  140. data/lib/adlint/token.rb +19 -91
  141. data/lib/adlint/traits.rb +242 -226
  142. data/lib/adlint/util.rb +116 -205
  143. data/lib/adlint/version.rb +8 -8
  144. data/share/HEADER +2 -2
  145. data/share/doc/developers_guide_ja.html +148 -19
  146. data/share/doc/developers_guide_ja.texi +141 -11
  147. data/share/doc/samples/GNUmakefile +1 -1
  148. data/share/doc/samples/adlint_traits.yml +45 -36
  149. data/share/doc/users_guide_en.html +1321 -1252
  150. data/share/doc/users_guide_en.texi +475 -408
  151. data/share/doc/users_guide_ja.html +1932 -1878
  152. data/share/doc/users_guide_ja.texi +324 -273
  153. data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
  154. data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
  155. data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
  156. data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
  157. data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
  158. data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
  159. data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
  160. data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
  161. data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
  162. data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
  163. data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
  164. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
  165. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
  166. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
  167. data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
  168. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
  169. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
  170. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
  171. data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
  172. data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
  173. data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
  174. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
  175. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
  176. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
  177. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
  178. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
  179. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
  180. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
  181. data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
  182. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
  183. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
  184. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
  185. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
  186. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
  187. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
  188. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
  189. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
  190. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
  191. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
  192. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
  193. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
  194. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
  195. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
  196. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
  197. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
  198. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
  199. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
  200. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
  201. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
  202. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
  203. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
  204. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
  205. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
  206. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
  207. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
  208. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
  209. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
  210. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
  211. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
  212. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
  213. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
  214. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
  215. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
  216. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
  217. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
  218. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
  219. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
  220. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
  221. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
  222. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
  223. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
  224. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
  225. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
  226. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
  227. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
  228. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
  229. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
  230. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
  231. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
  232. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
  233. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
  234. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
  235. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
  236. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
  237. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
  238. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
  239. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
  240. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
  241. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
  242. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
  243. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
  244. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
  245. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
  246. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
  247. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
  248. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
  249. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
  250. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
  251. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
  252. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
  253. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
  254. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
  255. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
  256. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
  257. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
  258. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
  259. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
  260. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
  261. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
  262. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
  263. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
  264. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
  265. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
  266. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
  267. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
  268. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
  269. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
  270. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
  271. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
  272. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
  273. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
  274. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
  275. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
  276. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
  277. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
  278. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
  279. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
  280. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
  281. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
  282. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
  283. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
  284. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
  285. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
  286. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
  287. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
  288. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
  289. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
  290. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
  291. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
  292. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
  293. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
  294. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
  295. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
  296. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
  297. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
  298. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
  299. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
  300. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
  301. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
  302. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
  303. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
  304. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
  305. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
  306. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
  307. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
  308. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
  309. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
  310. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
  311. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
  312. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
  313. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
  314. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
  315. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
  316. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
  317. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
  318. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
  319. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
  320. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
  321. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
  322. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
  323. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
  324. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
  325. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
  326. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
  327. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
  328. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
  329. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
  330. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
  331. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
  332. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
  333. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
  334. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
  335. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
  336. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
  337. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
  338. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
  339. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
  340. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
  341. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
  342. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
  343. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
  344. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
  345. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
  346. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
  347. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
  348. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
  349. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
  350. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
  351. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
  352. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
  353. data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
  354. data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
  355. data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
  356. data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
  357. data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
  358. data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
  359. data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
  360. data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
  361. data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
  362. data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
  363. data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
  364. data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
  365. data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
  366. data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
  367. data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
  368. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
  369. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
  370. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
  371. data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
  372. data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
  373. data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
  374. data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
  375. data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
  376. data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
  377. data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
  378. data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
  379. data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
  380. data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
  381. data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
  382. data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
  383. data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
  384. data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
  385. data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
  386. data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
  387. data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
  388. data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
  389. data/spec/conf.d/default_traits.yml +38 -37
  390. data/spec/conf.d/empty_cinit.h +1 -1
  391. data/spec/conf.d/empty_pinit.h +1 -1
  392. data/spec/conf.d/project/foo.c +0 -0
  393. data/spec/spec_helper.rb +2 -2
  394. metadata +60 -40
  395. data/lib/adlint/c/domain.rb +0 -7931
  396. data/lib/adlint/c/lexer.rb +0 -252
  397. data/lib/adlint/c/phase.rb +0 -135
  398. data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
  399. data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
  400. data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
  401. data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -1,7 +1,7 @@
1
1
  # Metric measurements (ld-phase) of adlint-exam-c_builtin package.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -40,20 +40,20 @@ module CBuiltin #:nodoc:
40
40
  class FN_CALL < MetricMeasurement
41
41
  def_registrant_phase Ld::PreparePhase
42
42
 
43
- def initialize(context)
43
+ def initialize(phase_ctxt)
44
44
  super
45
- @context = context
46
- @context[:ld_function_traversal].on_definition += method(:measure)
45
+ @phase_ctxt = phase_ctxt
46
+ @phase_ctxt[:ld_function_traversal].on_definition += T(:measure)
47
47
  end
48
48
 
49
49
  private
50
- def do_prepare(context) end
51
- def do_execute(context) end
50
+ def do_prepare(*) end
51
+ def do_execute(*) end
52
52
 
53
- def measure(function)
54
- call_graph = @context[:ld_function_call_graph]
55
- FN_CALL(FunctionIdentifier.new(function.name, function.signature),
56
- function.location, call_graph.all_callers_of(function).size)
53
+ def measure(fun)
54
+ call_graph = @phase_ctxt[:ld_function_call_graph]
55
+ FN_CALL(FunctionId.new(fun.name, fun.signature),
56
+ fun.location, call_graph.all_callers_of(fun).size)
57
57
  end
58
58
  end
59
59
 
data/lib/adlint/lang.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Programming language detection mechanism.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -31,8 +31,8 @@
31
31
 
32
32
  require "adlint/cpp/scanner"
33
33
  require "adlint/cpp/phase"
34
- require "adlint/c/scanner"
35
- require "adlint/c/phase"
34
+ require "adlint/cc1/scanner"
35
+ require "adlint/cc1/phase"
36
36
 
37
37
  module AdLint #:nodoc:
38
38
 
@@ -53,7 +53,7 @@ module AdLint #:nodoc:
53
53
  end
54
54
 
55
55
  class Cpp
56
- extend AdLint::Cpp::Scanner
56
+ extend ::AdLint::Cpp::Scanner
57
57
 
58
58
  class << self
59
59
  def single_module_phases; [] end
@@ -62,35 +62,35 @@ module AdLint #:nodoc:
62
62
  end
63
63
 
64
64
  class C
65
- include AdLint::C::ScannerConstants
66
- extend AdLint::C::Scanner
65
+ include Cc1::ScannerConstants
66
+ extend Cc1::Scanner
67
67
 
68
68
  class << self
69
69
  def single_module_phases
70
70
  [
71
- AdLint::Cpp::Prepare1Phase,
72
- AdLint::Cpp::Prepare2Phase,
73
- AdLint::Cpp::EvalPhase,
74
- AdLint::Cpp::SubstPhase,
75
- AdLint::C::Prepare1Phase,
76
- AdLint::C::ParsePhase,
77
- AdLint::C::ResolvePhase,
78
- AdLint::C::Prepare2Phase,
79
- AdLint::C::InterpPhase,
80
- AdLint::Cpp::ReviewPhase,
81
- AdLint::C::ReviewPhase,
82
- AdLint::Cpp::ExaminationPhase,
83
- AdLint::C::ExaminationPhase
71
+ ::AdLint::Cpp::Prepare1Phase,
72
+ ::AdLint::Cpp::Prepare2Phase,
73
+ ::AdLint::Cpp::EvalPhase,
74
+ ::AdLint::Cpp::SubstPhase,
75
+ ::AdLint::Cc1::Prepare1Phase,
76
+ ::AdLint::Cc1::ParsePhase,
77
+ ::AdLint::Cc1::ResolvePhase,
78
+ ::AdLint::Cc1::Prepare2Phase,
79
+ ::AdLint::Cc1::InterpPhase,
80
+ ::AdLint::Cpp::ReviewPhase,
81
+ ::AdLint::Cc1::ReviewPhase,
82
+ ::AdLint::Cpp::ExaminationPhase,
83
+ ::AdLint::Cc1::ExaminationPhase
84
84
  ].freeze
85
85
  end
86
86
 
87
87
  def check_phases
88
88
  [
89
- AdLint::Cpp::Prepare1Phase,
90
- AdLint::Cpp::EvalPhase,
91
- AdLint::Cpp::SubstPhase,
92
- AdLint::C::Prepare1Phase,
93
- AdLint::C::ParsePhase
89
+ ::AdLint::Cpp::Prepare1Phase,
90
+ ::AdLint::Cpp::EvalPhase,
91
+ ::AdLint::Cpp::SubstPhase,
92
+ ::AdLint::Cc1::Prepare1Phase,
93
+ ::AdLint::Cc1::ParsePhase
94
94
  ].freeze
95
95
  end
96
96
  end
data/lib/adlint/ld.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # AdLint::Ld 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
  #
@@ -1,7 +1,7 @@
1
1
  # C runtime object models for cross module analysis.
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,6 +29,7 @@
29
29
  #
30
30
  #++
31
31
 
32
+ require "adlint/location"
32
33
  require "adlint/metric"
33
34
  require "adlint/util"
34
35
 
@@ -36,24 +37,26 @@ module AdLint #:nodoc:
36
37
  module Ld #:nodoc:
37
38
 
38
39
  class Variable
39
- def initialize(variable_definition_record)
40
- @metric_record = variable_definition_record
40
+ include LocationHolder
41
+
42
+ def initialize(var_def_rec)
43
+ @met_record = var_def_rec
41
44
  end
42
45
 
43
46
  def location
44
- @metric_record.location
47
+ @met_record.location
45
48
  end
46
49
 
47
50
  def name
48
- @metric_record.variable_name
51
+ @met_record.variable_name
49
52
  end
50
53
 
51
54
  def type
52
- @metric_record.type_rep
55
+ @met_record.type_rep
53
56
  end
54
57
 
55
58
  def extern?
56
- @metric_record.var_linkage_type == "X"
59
+ @met_record.variable_linkage_type == "X"
57
60
  end
58
61
 
59
62
  def eql?(rhs)
@@ -68,20 +71,22 @@ module Ld #:nodoc:
68
71
  end
69
72
 
70
73
  class VariableDeclaration
71
- def initialize(global_variable_declaration_record)
72
- @metric_record = global_variable_declaration_record
74
+ include LocationHolder
75
+
76
+ def initialize(gvar_dcl_rec)
77
+ @met_record = gvar_dcl_rec
73
78
  end
74
79
 
75
80
  def location
76
- @metric_record.location
81
+ @met_record.location
77
82
  end
78
83
 
79
84
  def name
80
- @metric_record.variable_name
85
+ @met_record.variable_name
81
86
  end
82
87
 
83
88
  def type
84
- @metric_record.type_rep
89
+ @met_record.type_rep
85
90
  end
86
91
 
87
92
  def extern?
@@ -101,36 +106,37 @@ module Ld #:nodoc:
101
106
 
102
107
  class VariableMapping
103
108
  def initialize
104
- @variable_index = Hash.new { |hash, key| hash[key] = Set.new }
105
- @declaration_index = Hash.new { |hash, key| hash[key] = Set.new }
109
+ @def_index = Hash.new { |hash, key| hash[key] = Set.new }
110
+ @dcl_index = Hash.new { |hash, key| hash[key] = Set.new }
111
+ @composing_fpaths = Set.new
106
112
  end
107
113
 
108
- def add_variable(variable)
109
- @variable_index[variable.name].add(variable)
114
+ attr_reader :composing_fpaths
115
+
116
+ def add_variable(var)
117
+ @def_index[var.name].add(var)
118
+ @composing_fpaths.add(var.location.fpath)
110
119
  end
111
120
 
112
- def add_variable_declaration(variable_declaration)
113
- @declaration_index[variable_declaration.name].add(variable_declaration)
121
+ def add_variable_declaration(var_dcl)
122
+ @dcl_index[var_dcl.name].add(var_dcl)
123
+ @composing_fpaths.add(var_dcl.location.fpath)
114
124
  end
115
125
 
116
126
  def all_variables
117
- @variable_index.values.reduce(Set.new) { |all, variables|
118
- all + variables
119
- }.to_a
127
+ @def_index.values.reduce(Set.new) { |all, vars| all + vars }.to_a
120
128
  end
121
129
 
122
130
  def all_variable_declarations
123
- @declaration_index.values.reduce(Set.new) { |all, declarations|
124
- all + declarations
125
- }.to_a
131
+ @dcl_index.values.reduce(Set.new) { |all, dcls| all + dcls }.to_a
126
132
  end
127
133
 
128
- def lookup_variables(variable_name)
129
- @variable_index[variable_name].to_a
134
+ def lookup_variables(var_name)
135
+ @def_index[var_name].to_a
130
136
  end
131
137
 
132
- def lookup_variable_declarations(variable_name)
133
- @declaration_index[variable_name].to_a
138
+ def lookup_variable_declarations(var_name)
139
+ @dcl_index[var_name].to_a
134
140
  end
135
141
  end
136
142
 
@@ -141,26 +147,31 @@ module Ld #:nodoc:
141
147
 
142
148
  attr_reader :result
143
149
 
144
- def execute(metric_fpath)
145
- CSV.foreach(metric_fpath) do |row|
146
- record = MetricRecord.of(row)
150
+ def execute(met_fpath)
151
+ sma_wd = Pathname.pwd
152
+ CSV.foreach(met_fpath) do |csv_row|
153
+ rec = MetricRecord.of(csv_row, sma_wd)
147
154
  case
148
- when record.variable_definition?
149
- if record.var_linkage_type == "X"
150
- @result.add_variable(Variable.new(record))
155
+ when rec.version?
156
+ sma_wd = Pathname.new(rec.exec_working_directory)
157
+ when rec.variable_definition?
158
+ if rec.variable_linkage_type == "X"
159
+ @result.add_variable(Variable.new(rec))
151
160
  end
152
- when record.global_variable_declaration?
153
- @result.add_variable_declaration(VariableDeclaration.new(record))
161
+ when rec.global_variable_declaration?
162
+ @result.add_variable_declaration(VariableDeclaration.new(rec))
154
163
  end
155
164
  end
156
165
  end
157
166
  end
158
167
 
159
168
  class VariableReference
160
- def initialize(function, variable, location)
161
- @function = function
162
- @variable = variable
163
- @location = location
169
+ include LocationHolder
170
+
171
+ def initialize(fun, var, loc)
172
+ @function = fun
173
+ @variable = var
174
+ @location = loc
164
175
  end
165
176
 
166
177
  attr_reader :function
@@ -168,70 +179,71 @@ module Ld #:nodoc:
168
179
  attr_reader :location
169
180
 
170
181
  def eql?(rhs)
171
- @function == rhs.function && @variable == rhs.variable &&
172
- @location == rhs.location
182
+ to_a == rhs.to_a
173
183
  end
174
184
 
175
185
  alias :== :eql?
176
186
 
177
187
  def hash
178
- [@function, @variable, @location].hash
188
+ to_a.hash
189
+ end
190
+
191
+ def to_a
192
+ [@function, @variable, @location]
179
193
  end
180
194
  end
181
195
 
182
196
  class VariableReferenceGraph
183
- extend Memoizable
184
-
185
- def initialize(function_call_graph)
186
- @function_call_graph = function_call_graph
187
- @referrer_index = Hash.new { |hash, key| hash[key] = Set.new }
188
- @variable_index = Hash.new { |hash, key| hash[key] = Set.new }
197
+ def initialize(funcall_graph)
198
+ @funcall_graph = funcall_graph
199
+ @ref_index = Hash.new { |hash, key| hash[key] = Set.new }
200
+ @var_index = Hash.new { |hash, key| hash[key] = Set.new }
189
201
  end
190
202
 
191
- def add(variable_reference)
192
- @referrer_index[variable_reference.function].add(variable_reference)
193
- @variable_index[variable_reference.variable].add(variable_reference)
203
+ def add(var_ref)
204
+ @ref_index[var_ref.function].add(var_ref)
205
+ @var_index[var_ref.variable].add(var_ref)
194
206
  end
195
207
 
196
- def all_referrers_of(variable)
197
- direct_referrers_of(variable) + indirect_referrers_of(variable)
208
+ def all_referrers_of(var)
209
+ direct_referrers_of(var) + indirect_referrers_of(var)
198
210
  end
199
211
 
200
- def direct_referrers_of(variable)
201
- @variable_index[variable].map { |varref| varref.function }.to_set
212
+ def direct_referrers_of(var)
213
+ @var_index[var].map { |var_ref| var_ref.function }.to_set
202
214
  end
203
215
 
204
- def indirect_referrers_of(variable)
205
- direct_referrers = direct_referrers_of(variable)
206
- direct_referrers.reduce(Set.new) do |result, function|
207
- result + @function_call_graph.all_callers_of(function)
216
+ def indirect_referrers_of(var)
217
+ direct_referrers = direct_referrers_of(var)
218
+ direct_referrers.reduce(Set.new) do |result, fun|
219
+ result + @funcall_graph.all_callers_of(fun)
208
220
  end
209
221
  end
210
222
  end
211
223
 
212
224
  class VariableReferenceGraphBuilder
213
- def initialize(variable_mapping, function_mapping, function_call_graph)
214
- @variable_mapping = variable_mapping
215
- @function_mapping = function_mapping
216
- @result = VariableReferenceGraph.new(function_call_graph)
225
+ def initialize(var_mapping, fun_mapping, funcall_graph)
226
+ @variable_mapping = var_mapping
227
+ @function_mapping = fun_mapping
228
+ @result = VariableReferenceGraph.new(funcall_graph)
217
229
  end
218
230
 
219
231
  attr_reader :result
220
232
 
221
- def execute(metric_fpath)
222
- CSV.foreach(metric_fpath) do |row|
223
- record = MetricRecord.of(row)
233
+ def execute(met_fpath)
234
+ sma_wd = Pathname.pwd
235
+ CSV.foreach(met_fpath) do |csv_row|
236
+ rec = MetricRecord.of(csv_row, sma_wd)
224
237
  case
225
- when record.variable_xref?
226
- function = @function_mapping.lookup_functions(
227
- record.accessor_function.name).first
228
-
229
- variable = @variable_mapping.lookup_variables(
230
- record.accessee_variable).first
231
-
232
- if function && variable
233
- @result.add(VariableReference.new(
234
- function, variable, record.location))
238
+ when rec.version?
239
+ sma_wd = Pathname.new(rec.exec_working_directory)
240
+ when rec.variable_xref?
241
+ fun = @function_mapping.lookup_functions(
242
+ rec.accessor_function.name).first
243
+ var = @variable_mapping.lookup_variables(rec.accessee_variable).first
244
+
245
+ if fun && var
246
+ @result.add(VariableReference.new(fun, var, rec.location))
235
247
  end
236
248
  end
237
249
  end
@@ -239,8 +251,8 @@ module Ld #:nodoc:
239
251
  end
240
252
 
241
253
  class VariableTraversal
242
- def initialize(variable_mapping)
243
- @variable_mapping = variable_mapping
254
+ def initialize(var_mapping)
255
+ @variable_mapping = var_mapping
244
256
  end
245
257
 
246
258
  extend Pluggable
@@ -249,35 +261,37 @@ module Ld #:nodoc:
249
261
  def_plugin :on_definition
250
262
 
251
263
  def execute
252
- @variable_mapping.all_variable_declarations.each do |declaration|
253
- on_declaration.invoke(declaration)
264
+ @variable_mapping.all_variable_declarations.each do |var_dcl|
265
+ on_declaration.invoke(var_dcl)
254
266
  end
255
267
 
256
- @variable_mapping.all_variables.each do |definition|
257
- on_definition.invoke(definition)
268
+ @variable_mapping.all_variables.each do |var_def|
269
+ on_definition.invoke(var_def)
258
270
  end
259
271
  end
260
272
  end
261
273
 
262
274
  class Function
263
- def initialize(function_definition_record)
264
- @metric_record = function_definition_record
275
+ include LocationHolder
276
+
277
+ def initialize(fun_def_rec)
278
+ @met_record = fun_def_rec
265
279
  end
266
280
 
267
281
  def location
268
- @metric_record.location
282
+ @met_record.location
269
283
  end
270
284
 
271
285
  def signature
272
- @metric_record.function_identifier.signature
286
+ @met_record.function_id.signature
273
287
  end
274
288
 
275
289
  def name
276
- @metric_record.function_identifier.name
290
+ @met_record.function_id.name
277
291
  end
278
292
 
279
293
  def extern?
280
- @metric_record.function_linkage_type == "X"
294
+ @met_record.function_linkage_type == "X"
281
295
  end
282
296
 
283
297
  def eql?(rhs)
@@ -292,24 +306,34 @@ module Ld #:nodoc:
292
306
  end
293
307
 
294
308
  class FunctionDeclaration
295
- def initialize(function_declaration_record)
296
- @metric_record = function_declaration_record
309
+ include LocationHolder
310
+
311
+ def initialize(fun_dcl_rec)
312
+ @met_record = fun_dcl_rec
297
313
  end
298
314
 
299
315
  def location
300
- @metric_record.location
316
+ @met_record.location
301
317
  end
302
318
 
303
319
  def signature
304
- @metric_record.function_identifier.signature
320
+ @met_record.function_id.signature
305
321
  end
306
322
 
307
323
  def name
308
- @metric_record.function_identifier.name
324
+ @met_record.function_id.name
309
325
  end
310
326
 
311
327
  def extern?
312
- @metric_record.function_linkage_type == "X"
328
+ @met_record.function_linkage_type == "X"
329
+ end
330
+
331
+ def explicit?
332
+ @met_record.function_declaration_type == "E"
333
+ end
334
+
335
+ def implicit?
336
+ @met_record.function_declaration_type == "I"
313
337
  end
314
338
 
315
339
  def eql?(rhs)
@@ -325,36 +349,37 @@ module Ld #:nodoc:
325
349
 
326
350
  class FunctionMapping
327
351
  def initialize
328
- @function_index = Hash.new { |hash, key| hash[key] = Set.new }
329
- @declaration_index = Hash.new { |hash, key| hash[key] = Set.new }
352
+ @def_index = Hash.new { |hash, key| hash[key] = Set.new }
353
+ @dcl_index = Hash.new { |hash, key| hash[key] = Set.new }
354
+ @composing_fpaths = Set.new
330
355
  end
331
356
 
332
- def add_function(function)
333
- @function_index[function.name].add(function)
357
+ attr_reader :composing_fpaths
358
+
359
+ def add_function(fun)
360
+ @def_index[fun.name].add(fun)
361
+ @composing_fpaths.add(fun.location.fpath)
334
362
  end
335
363
 
336
- def add_function_declaration(function_declaration)
337
- @declaration_index[function_declaration.name].add(function_declaration)
364
+ def add_function_declaration(fun_dcl)
365
+ @dcl_index[fun_dcl.name].add(fun_dcl)
366
+ @composing_fpaths.add(fun_dcl.location.fpath)
338
367
  end
339
368
 
340
369
  def all_functions
341
- @function_index.values.reduce(Set.new) { |all, functions|
342
- all + functions
343
- }.to_a
370
+ @def_index.values.reduce(Set.new) { |all, funs| all + funs }.to_a
344
371
  end
345
372
 
346
373
  def all_function_declarations
347
- @declaration_index.values.reduce(Set.new) { |all, declarations|
348
- all + declarations
349
- }.to_a
374
+ @dcl_index.values.reduce(Set.new) { |all, dcls| all + dcls }.to_a
350
375
  end
351
376
 
352
- def lookup_functions(function_name)
353
- @function_index[function_name].to_a
377
+ def lookup_functions(fun_name)
378
+ @def_index[fun_name].to_a
354
379
  end
355
380
 
356
- def lookup_function_declarations(function_name)
357
- @declaration_index[function_name].to_a
381
+ def lookup_function_declarations(fun_name)
382
+ @dcl_index[fun_name].to_a
358
383
  end
359
384
  end
360
385
 
@@ -365,83 +390,87 @@ module Ld #:nodoc:
365
390
 
366
391
  attr_reader :result
367
392
 
368
- def execute(metric_fpath)
369
- CSV.foreach(metric_fpath) do |row|
370
- record = MetricRecord.of(row)
393
+ def execute(met_fpath)
394
+ sma_wd = Pathname.pwd
395
+ CSV.foreach(met_fpath) do |csv_row|
396
+ rec = MetricRecord.of(csv_row, sma_wd)
371
397
  case
372
- when record.function_definition?
373
- @result.add_function(Function.new(record))
374
- when record.function_declaration?
375
- @result.add_function_declaration(FunctionDeclaration.new(record))
398
+ when rec.version?
399
+ sma_wd = Pathname.new(rec.exec_working_directory)
400
+ when rec.function_definition?
401
+ @result.add_function(Function.new(rec))
402
+ when rec.function_declaration?
403
+ @result.add_function_declaration(FunctionDeclaration.new(rec))
376
404
  end
377
405
  end
378
406
  end
379
407
  end
380
408
 
381
409
  class FunctionCall
382
- def initialize(caller_function, callee_function)
383
- @caller_function = caller_function
384
- @callee_function = callee_function
410
+ def initialize(caller_fun, callee_fun)
411
+ @caller_function = caller_fun
412
+ @callee_function = callee_fun
385
413
  end
386
414
 
387
415
  attr_reader :caller_function
388
416
  attr_reader :callee_function
389
417
 
390
418
  def eql?(rhs)
391
- @caller_function == rhs.caller_function &&
392
- @callee_function == rhs.callee_function
419
+ to_a == rhs.to_a
393
420
  end
394
421
 
395
422
  alias :== :eql?
396
423
 
397
424
  def hash
398
- [@caller_function, @callee_function].hash
425
+ to_a.hash
426
+ end
427
+
428
+ def to_a
429
+ [@caller_function, @callee_function]
399
430
  end
400
431
  end
401
432
 
402
433
  class FunctionCallGraph
403
- extend Memoizable
404
-
405
434
  def initialize
406
435
  @caller_index = Hash.new { |hash, key| hash[key] = Set.new }
407
436
  @callee_index = Hash.new { |hash, key| hash[key] = Set.new }
408
437
  end
409
438
 
410
- def add(function_call)
411
- @caller_index[function_call.caller_function].add(function_call)
412
- @callee_index[function_call.callee_function].add(function_call)
439
+ def add(funcall)
440
+ @caller_index[funcall.caller_function].add(funcall)
441
+ @callee_index[funcall.callee_function].add(funcall)
413
442
  end
414
443
 
415
- def all_callers_of(callee_function)
416
- direct_callers_of(callee_function) + indirect_callers_of(callee_function)
444
+ def all_callers_of(callee_fun)
445
+ direct_callers_of(callee_fun) + indirect_callers_of(callee_fun)
417
446
  end
418
447
  memoize :all_callers_of
419
448
 
420
- def direct_callers_of(callee_function)
421
- @callee_index[callee_function].map { |funcall|
449
+ def direct_callers_of(callee_fun)
450
+ @callee_index[callee_fun].map { |funcall|
422
451
  funcall.caller_function
423
452
  }.to_set
424
453
  end
425
454
  memoize :direct_callers_of
426
455
 
427
- def indirect_callers_of(callee_function)
428
- direct_callers = direct_callers_of(callee_function)
429
- direct_callers.reduce(Set.new) do |all_callers, function|
430
- all_callers + collect_callers_of(function, all_callers)
456
+ def indirect_callers_of(callee_fun)
457
+ direct_callers = direct_callers_of(callee_fun)
458
+ direct_callers.reduce(Set.new) do |all_callers, fun|
459
+ all_callers + collect_callers_of(fun, all_callers)
431
460
  end
432
461
  end
433
462
  memoize :indirect_callers_of
434
463
 
435
464
  private
436
- def collect_callers_of(callee_function, exclusion_list)
437
- direct_callers = direct_callers_of(callee_function)
465
+ def collect_callers_of(callee_fun, exclusion_list)
466
+ direct_callers = direct_callers_of(callee_fun)
438
467
 
439
- direct_callers.reduce(Set.new) do |all_callers, function|
440
- if exclusion_list.include?(function)
441
- all_callers.add(function)
468
+ direct_callers.reduce(Set.new) do |all_callers, fun|
469
+ if exclusion_list.include?(fun)
470
+ all_callers.add(fun)
442
471
  else
443
- all_callers.add(function) +
444
- collect_callers_of(function, exclusion_list + all_callers)
472
+ all_callers.add(fun) +
473
+ collect_callers_of(fun, exclusion_list + all_callers)
445
474
  end
446
475
  end
447
476
  end
@@ -449,77 +478,80 @@ module Ld #:nodoc:
449
478
  end
450
479
 
451
480
  class FunctionCallGraphBuilder
452
- def initialize(function_mapping)
453
- @function_mapping = function_mapping
481
+ def initialize(fun_mapping)
482
+ @function_mapping = fun_mapping
454
483
  @result = FunctionCallGraph.new
455
484
  end
456
485
 
457
486
  attr_reader :result
458
487
 
459
- def execute(metric_fpath)
460
- CSV.foreach(metric_fpath) do |row|
461
- record = MetricRecord.of(row)
488
+ def execute(met_fpath)
489
+ sma_wd = Pathname.pwd
490
+ CSV.foreach(met_fpath) do |csv_row|
491
+ rec = MetricRecord.of(csv_row, sma_wd)
462
492
  case
463
- when record.function_call?
464
- caller_function, callee_function = lookup_functions_by_call(record)
465
- if caller_function && callee_function
466
- @result.add(FunctionCall.new(caller_function, callee_function))
493
+ when rec.version?
494
+ sma_wd = Pathname.new(rec.exec_working_directory)
495
+ when rec.function_call?
496
+ caller_fun, callee_fun = lookup_functions_by_call(rec)
497
+ if caller_fun && callee_fun
498
+ @result.add(FunctionCall.new(caller_fun, callee_fun))
467
499
  end
468
- when record.function_xref?
469
- caller_function, callee_function = lookup_functions_by_xref(record)
470
- if caller_function && callee_function
471
- @result.add(FunctionCall.new(caller_function, callee_function))
500
+ when rec.function_xref?
501
+ caller_fun, callee_fun = lookup_functions_by_xref(rec)
502
+ if caller_fun && callee_fun
503
+ @result.add(FunctionCall.new(caller_fun, callee_fun))
472
504
  end
473
505
  end
474
506
  end
475
507
  end
476
508
 
477
- def lookup_functions_by_call(function_call_record)
478
- caller_function = @function_mapping.lookup_functions(
479
- function_call_record.caller_function.name).find { |function|
480
- function.location.fpath == function_call_record.location.fpath
509
+ def lookup_functions_by_call(funcall_rec)
510
+ caller_fun = @function_mapping.lookup_functions(
511
+ funcall_rec.caller_function.name).find { |fun|
512
+ fun.location.fpath == funcall_rec.location.fpath
481
513
  }
482
- return nil, nil unless caller_function
514
+ return nil, nil unless caller_fun
483
515
 
484
- callee_functions = @function_mapping.lookup_functions(
485
- function_call_record.callee_function.name)
516
+ callee_funs = @function_mapping.lookup_functions(
517
+ funcall_rec.callee_function.name)
486
518
 
487
- callee_function = callee_functions.first
488
- callee_functions.each do |function|
489
- if function.location.fpath == caller_function.location.fpath
490
- callee_function = function
519
+ callee_fun = callee_funs.first
520
+ callee_funs.each do |fun|
521
+ if fun.location.fpath == caller_fun.location.fpath
522
+ callee_fun = fun
491
523
  break
492
524
  end
493
525
  end
494
526
 
495
- return caller_function, callee_function
527
+ return caller_fun, callee_fun
496
528
  end
497
529
 
498
- def lookup_functions_by_xref(function_xref_record)
499
- caller_function = @function_mapping.lookup_functions(
500
- function_xref_record.accessor_function.name).find { |function|
501
- function.location.fpath == function_xref_record.location.fpath
530
+ def lookup_functions_by_xref(fun_xref_rec)
531
+ caller_fun = @function_mapping.lookup_functions(
532
+ fun_xref_rec.accessor_function.name).find { |fun|
533
+ fun.location.fpath == fun_xref_rec.location.fpath
502
534
  }
503
- return nil, nil unless caller_function
535
+ return nil, nil unless caller_fun
504
536
 
505
- callee_functions = @function_mapping.lookup_functions(
506
- function_xref_record.accessee_function.name)
537
+ callee_funs = @function_mapping.lookup_functions(
538
+ fun_xref_rec.accessee_function.name)
507
539
 
508
- callee_function = callee_functions.first
509
- callee_functions.each do |function|
510
- if function.location.fpath == caller_function.location.fpath
511
- callee_function = function
540
+ callee_fun = callee_funs.first
541
+ callee_funs.each do |fun|
542
+ if fun.location.fpath == caller_fun.location.fpath
543
+ callee_fun = fun
512
544
  break
513
545
  end
514
546
  end
515
547
 
516
- return caller_function, callee_function
548
+ return caller_fun, callee_fun
517
549
  end
518
550
  end
519
551
 
520
552
  class FunctionTraversal
521
- def initialize(function_mapping)
522
- @function_mapping = function_mapping
553
+ def initialize(fun_mapping)
554
+ @function_mapping = fun_mapping
523
555
  end
524
556
 
525
557
  extend Pluggable
@@ -528,12 +560,12 @@ module Ld #:nodoc:
528
560
  def_plugin :on_definition
529
561
 
530
562
  def execute
531
- @function_mapping.all_function_declarations.each do |declaration|
532
- on_declaration.invoke(declaration)
563
+ @function_mapping.all_function_declarations.each do |fun_dcl|
564
+ on_declaration.invoke(fun_dcl)
533
565
  end
534
566
 
535
- @function_mapping.all_functions.each do |definition|
536
- on_definition.invoke(definition)
567
+ @function_mapping.all_functions.each do |fun_def|
568
+ on_definition.invoke(fun_def)
537
569
  end
538
570
  end
539
571
  end