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.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
data/lib/adlint/lexer.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Lexical analyzer base classes.
|
|
2
2
|
#
|
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
|
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-
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
15
|
#
|
|
16
16
|
# This file is part of AdLint.
|
|
17
17
|
#
|
|
@@ -33,7 +33,6 @@ require "adlint/token"
|
|
|
33
33
|
require "adlint/source"
|
|
34
34
|
require "adlint/traits"
|
|
35
35
|
require "adlint/error"
|
|
36
|
-
require "adlint/util"
|
|
37
36
|
|
|
38
37
|
module AdLint #:nodoc:
|
|
39
38
|
|
|
@@ -45,18 +44,18 @@ module AdLint #:nodoc:
|
|
|
45
44
|
# token array.
|
|
46
45
|
#
|
|
47
46
|
# === PARAMETER
|
|
48
|
-
#
|
|
49
|
-
def initialize(
|
|
50
|
-
if
|
|
47
|
+
# _token_ary_:: TokenArray -- Array of tokens.
|
|
48
|
+
def initialize(tok_ary = nil)
|
|
49
|
+
if tok_ary
|
|
51
50
|
super
|
|
52
51
|
else
|
|
53
52
|
super()
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
57
|
-
def expect(
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
def expect(tok_type)
|
|
57
|
+
tok = self.first
|
|
58
|
+
tok && tok.type == tok_type ? true : false
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
|
|
@@ -75,9 +74,6 @@ module AdLint #:nodoc:
|
|
|
75
74
|
# == DESCRIPTION
|
|
76
75
|
# Object represents the whole content of the string.
|
|
77
76
|
class StringContent < Content
|
|
78
|
-
include CodingStyleAccessor
|
|
79
|
-
extend Memoizable
|
|
80
|
-
|
|
81
77
|
# === DESCRIPTION
|
|
82
78
|
# Constructs the content object of the string.
|
|
83
79
|
#
|
|
@@ -85,11 +81,10 @@ module AdLint #:nodoc:
|
|
|
85
81
|
# _str_:: String -- Target string.
|
|
86
82
|
# _fpath_:: Pathname -- File path name contains the target string.
|
|
87
83
|
# _line_no_:: Integer -- Initial line-no of the target string.
|
|
88
|
-
def initialize(str, fpath = nil, line_no = 1, column_no = 1)
|
|
84
|
+
def initialize(str, tab_width = 8, fpath = nil, line_no = 1, column_no = 1)
|
|
89
85
|
@scanner = StringScanner.new(str)
|
|
90
|
-
@
|
|
91
|
-
@line_no = line_no
|
|
92
|
-
@column_no = column_no
|
|
86
|
+
@tab_width = tab_width
|
|
87
|
+
@fpath, @line_no, @column_no = fpath, line_no, column_no
|
|
93
88
|
@appearance_column_no = column_no
|
|
94
89
|
end
|
|
95
90
|
|
|
@@ -107,10 +102,10 @@ module AdLint #:nodoc:
|
|
|
107
102
|
# === RETURN VALUE
|
|
108
103
|
# String -- Token string or nil.
|
|
109
104
|
def scan(regexp)
|
|
110
|
-
|
|
111
|
-
if
|
|
112
|
-
update_location(
|
|
113
|
-
|
|
105
|
+
tok = @scanner.scan(regexp)
|
|
106
|
+
if tok
|
|
107
|
+
update_location(tok)
|
|
108
|
+
tok
|
|
114
109
|
else
|
|
115
110
|
nil
|
|
116
111
|
end
|
|
@@ -124,12 +119,12 @@ module AdLint #:nodoc:
|
|
|
124
119
|
# Skips a content.
|
|
125
120
|
#
|
|
126
121
|
# === PARAMETER
|
|
127
|
-
#
|
|
122
|
+
# _len_:: Integer -- Skipping content length.
|
|
128
123
|
#
|
|
129
124
|
# === RETURN VALUE
|
|
130
125
|
# String -- Eaten string.
|
|
131
|
-
def eat!(
|
|
132
|
-
scan(/.{#{
|
|
126
|
+
def eat!(len = 1)
|
|
127
|
+
self.scan(/.{#{len}}/m)
|
|
133
128
|
end
|
|
134
129
|
|
|
135
130
|
# === DESCRIPTION
|
|
@@ -146,17 +141,17 @@ module AdLint #:nodoc:
|
|
|
146
141
|
end
|
|
147
142
|
|
|
148
143
|
private
|
|
149
|
-
def update_location(
|
|
150
|
-
if (
|
|
151
|
-
@line_no +=
|
|
152
|
-
|
|
153
|
-
@column_no =
|
|
154
|
-
@appearance_column_no =
|
|
144
|
+
def update_location(tok)
|
|
145
|
+
if (nl_cnt = tok.count("\n")) > 0
|
|
146
|
+
@line_no += nl_cnt
|
|
147
|
+
lst_line = tok[tok.rindex("\n")..-1]
|
|
148
|
+
@column_no = lst_line.length
|
|
149
|
+
@appearance_column_no = lst_line.gsub(/\t/, " " * @tab_width).length
|
|
155
150
|
else
|
|
156
|
-
@column_no +=
|
|
157
|
-
@appearance_column_no +=
|
|
151
|
+
@column_no += tok.length
|
|
152
|
+
@appearance_column_no += tok.gsub(/\t/, " " * @tab_width).length
|
|
158
153
|
end
|
|
159
|
-
|
|
154
|
+
forget_memo_of__location
|
|
160
155
|
end
|
|
161
156
|
end
|
|
162
157
|
|
|
@@ -167,27 +162,35 @@ module AdLint #:nodoc:
|
|
|
167
162
|
# Constructs the content object of the source file.
|
|
168
163
|
#
|
|
169
164
|
# === PARAMETER
|
|
170
|
-
#
|
|
171
|
-
def initialize(
|
|
172
|
-
super(
|
|
165
|
+
# _src_:: Source -- Target source object.
|
|
166
|
+
def initialize(src, tab_width)
|
|
167
|
+
super(src.open { |io| io.read }, tab_width, src.fpath)
|
|
173
168
|
end
|
|
174
169
|
end
|
|
175
170
|
|
|
176
171
|
class TokensContent < Content
|
|
177
|
-
def initialize(
|
|
178
|
-
@
|
|
172
|
+
def initialize(tok_ary)
|
|
173
|
+
@token_ary = tok_ary
|
|
179
174
|
end
|
|
180
175
|
|
|
181
176
|
def location
|
|
182
|
-
empty?
|
|
177
|
+
if self.empty?
|
|
178
|
+
nil
|
|
179
|
+
else
|
|
180
|
+
@token_ary.first.location
|
|
181
|
+
end
|
|
183
182
|
end
|
|
184
183
|
|
|
185
184
|
def empty?
|
|
186
|
-
@
|
|
185
|
+
@token_ary.empty?
|
|
187
186
|
end
|
|
188
187
|
|
|
189
188
|
def next_token
|
|
190
|
-
empty?
|
|
189
|
+
if empty?
|
|
190
|
+
nil
|
|
191
|
+
else
|
|
192
|
+
@token_ary.shift
|
|
193
|
+
end
|
|
191
194
|
end
|
|
192
195
|
end
|
|
193
196
|
|
|
@@ -198,9 +201,9 @@ module AdLint #:nodoc:
|
|
|
198
201
|
# Constructs a lexical analysis context object.
|
|
199
202
|
#
|
|
200
203
|
# === PARAMETER
|
|
201
|
-
#
|
|
202
|
-
def initialize(
|
|
203
|
-
@content =
|
|
204
|
+
# _cont_:: SourceContent | StringContent -- Target content.
|
|
205
|
+
def initialize(cont)
|
|
206
|
+
@content = cont
|
|
204
207
|
end
|
|
205
208
|
|
|
206
209
|
# === VALUE
|
|
@@ -235,13 +238,13 @@ module AdLint #:nodoc:
|
|
|
235
238
|
# === RETURN VALUE
|
|
236
239
|
# TokenArray -- Scanned tokens.
|
|
237
240
|
def execute
|
|
238
|
-
|
|
239
|
-
tokenize(
|
|
241
|
+
lexer_ctxt = create_lexer_context(@str)
|
|
242
|
+
tokenize(lexer_ctxt)
|
|
240
243
|
rescue Error
|
|
241
244
|
raise
|
|
242
245
|
rescue => ex
|
|
243
|
-
if
|
|
244
|
-
raise InternalError.new(ex,
|
|
246
|
+
if lexer_ctxt
|
|
247
|
+
raise InternalError.new(ex, lexer_ctxt.location)
|
|
245
248
|
else
|
|
246
249
|
raise InternalError.new(ex, nil)
|
|
247
250
|
end
|
|
@@ -255,7 +258,7 @@ module AdLint #:nodoc:
|
|
|
255
258
|
#
|
|
256
259
|
# === PARAMETER
|
|
257
260
|
# _str_:: String -- Target string object.
|
|
258
|
-
def
|
|
261
|
+
def create_lexer_context(str)
|
|
259
262
|
subclass_responsibility
|
|
260
263
|
end
|
|
261
264
|
|
|
@@ -265,31 +268,31 @@ module AdLint #:nodoc:
|
|
|
265
268
|
# Subclasses must implement this method.
|
|
266
269
|
#
|
|
267
270
|
# === PARAMETER
|
|
268
|
-
#
|
|
269
|
-
def tokenize(
|
|
271
|
+
# _lexer_ctxt_:: LexerContext -- Lexical analysis context.
|
|
272
|
+
def tokenize(lexer_ctxt)
|
|
270
273
|
subclass_responsibility
|
|
271
274
|
end
|
|
272
275
|
end
|
|
273
276
|
|
|
274
277
|
class TokensRelexer
|
|
275
|
-
def initialize(
|
|
276
|
-
@
|
|
278
|
+
def initialize(tok_ary)
|
|
279
|
+
@lexer_ctxt = create_lexer_context(tok_ary)
|
|
277
280
|
end
|
|
278
281
|
|
|
279
282
|
def next_token
|
|
280
|
-
tokenize(@
|
|
283
|
+
tokenize(@lexer_ctxt)
|
|
281
284
|
rescue Error
|
|
282
285
|
raise
|
|
283
286
|
rescue => ex
|
|
284
|
-
raise InternalError.new(ex, @
|
|
287
|
+
raise InternalError.new(ex, @lexer_ctxt.location)
|
|
285
288
|
end
|
|
286
289
|
|
|
287
290
|
private
|
|
288
|
-
def
|
|
291
|
+
def create_lexer_context(tok_ary)
|
|
289
292
|
subclass_responsibility
|
|
290
293
|
end
|
|
291
294
|
|
|
292
|
-
def tokenize(
|
|
295
|
+
def tokenize(lexer_ctxt)
|
|
293
296
|
subclass_responsibility
|
|
294
297
|
end
|
|
295
298
|
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Location identifier of tokens.
|
|
2
|
+
#
|
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
|
+
#
|
|
7
|
+
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
8
|
+
|
|
9
|
+
#--
|
|
10
|
+
# ___ ____ __ ___ _________
|
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
|
+
#
|
|
16
|
+
# This file is part of AdLint.
|
|
17
|
+
#
|
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
21
|
+
# version.
|
|
22
|
+
#
|
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
26
|
+
#
|
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
#
|
|
30
|
+
#++
|
|
31
|
+
|
|
32
|
+
module AdLint #:nodoc:
|
|
33
|
+
|
|
34
|
+
# == DESCRIPTION
|
|
35
|
+
# Location identifier of tokens.
|
|
36
|
+
class Location
|
|
37
|
+
# === Constructs a location identifier.
|
|
38
|
+
#
|
|
39
|
+
# Param:: _fpath_ (Pathname) Path name of the file contains the token.
|
|
40
|
+
# Param:: _line_no_ (Integer) Line-no where the token appears.
|
|
41
|
+
# Param:: _column_no_ (Integer) Column-no where the token appears.
|
|
42
|
+
def initialize(fpath = nil, line_no = nil, column_no = nil,
|
|
43
|
+
appearance_column_no = column_no)
|
|
44
|
+
@fpath, @line_no, @column_no = fpath, line_no, column_no
|
|
45
|
+
@appearance_column_no = appearance_column_no
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# === VALUE
|
|
49
|
+
# Pathname -- Path name of the file contains this token.
|
|
50
|
+
attr_reader :fpath
|
|
51
|
+
|
|
52
|
+
# === VALUE
|
|
53
|
+
# Integer -- Line-no where this token appears.
|
|
54
|
+
attr_reader :line_no
|
|
55
|
+
|
|
56
|
+
# === VALUE
|
|
57
|
+
# Integer -- Column-no where this token appears.
|
|
58
|
+
attr_reader :column_no
|
|
59
|
+
|
|
60
|
+
attr_reader :appearance_column_no
|
|
61
|
+
|
|
62
|
+
def in_analysis_target?(traits)
|
|
63
|
+
if @fpath
|
|
64
|
+
under_inclusion_paths?(@fpath, traits) &&
|
|
65
|
+
!under_exclusion_paths?(@fpath, traits) and
|
|
66
|
+
!@fpath.identical?(traits.of_project.initial_header) &&
|
|
67
|
+
!@fpath.identical?(traits.of_compiler.initial_header)
|
|
68
|
+
else
|
|
69
|
+
false
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
memoize :in_analysis_target?
|
|
73
|
+
|
|
74
|
+
def ==(rhs)
|
|
75
|
+
self.to_a == rhs.to_a
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def eql?(rhs)
|
|
79
|
+
self == rhs
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def hash
|
|
83
|
+
to_a.hash
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# === DESCRIPTION
|
|
87
|
+
# Converts this location identifier to an array representation.
|
|
88
|
+
#
|
|
89
|
+
# === RETURN VALUE
|
|
90
|
+
# Array< Object > -- Array representation of this location identifier.
|
|
91
|
+
def to_a
|
|
92
|
+
[@fpath, @line_no, @column_no]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# === DESCRIPTION
|
|
96
|
+
# Converts this location to a human readable string representation.
|
|
97
|
+
#
|
|
98
|
+
# === RETURN VALUE
|
|
99
|
+
# String -- String representation of this location identifier.
|
|
100
|
+
def to_s
|
|
101
|
+
str = ""
|
|
102
|
+
str += "#{@fpath}:" if @fpath
|
|
103
|
+
str += "#{@line_no}:" if @line_no
|
|
104
|
+
str += "#{@column_no}" if @column_no
|
|
105
|
+
str
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# === DESCRIPTION
|
|
109
|
+
# Converts this location to debugging dump representation.
|
|
110
|
+
#
|
|
111
|
+
# === RETURN VALUE
|
|
112
|
+
# String -- String representation of this location identifier.
|
|
113
|
+
def inspect
|
|
114
|
+
"#{@fpath ? @fpath : 'nil'}:" +
|
|
115
|
+
"#{@line_no ? @line_no : 'nil'}:#{@column_no ? @column_no : 'nil'}"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
def under_inclusion_paths?(fpath, traits)
|
|
120
|
+
traits.of_project.target_files.inclusion_paths.any? do |dpath|
|
|
121
|
+
fpath.under?(dpath)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def under_exclusion_paths?(fpath, traits)
|
|
126
|
+
traits.of_project.target_files.exclusion_paths.any? do |dpath|
|
|
127
|
+
fpath.under?(dpath)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
module LocationHolder
|
|
133
|
+
# NOTE: Host class must respond to #location.
|
|
134
|
+
|
|
135
|
+
def analysis_target?(traits)
|
|
136
|
+
location.in_analysis_target?(traits)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
data/lib/adlint/memo.rb
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Memoizing utility.
|
|
2
|
+
#
|
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
|
+
#
|
|
7
|
+
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
8
|
+
|
|
9
|
+
#--
|
|
10
|
+
# ___ ____ __ ___ _________
|
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
|
+
#
|
|
16
|
+
# This file is part of AdLint.
|
|
17
|
+
#
|
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
21
|
+
# version.
|
|
22
|
+
#
|
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
26
|
+
#
|
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
#
|
|
30
|
+
#++
|
|
31
|
+
|
|
32
|
+
module AdLint #:nodoc:
|
|
33
|
+
|
|
34
|
+
module Memoizable
|
|
35
|
+
def memoize(name, *key_indices)
|
|
36
|
+
var_name = name.to_s.sub("?", "Q")
|
|
37
|
+
org_name = "_org_#{name}"
|
|
38
|
+
class_eval <<-EOS
|
|
39
|
+
alias_method("#{org_name}", "#{name}")
|
|
40
|
+
private("#{org_name}")
|
|
41
|
+
EOS
|
|
42
|
+
if key_indices.empty?
|
|
43
|
+
if instance_method("#{name}").arity == 0
|
|
44
|
+
define_cache_manipulator(name, var_name)
|
|
45
|
+
class_eval <<-EOS
|
|
46
|
+
define_method("#{name}") do
|
|
47
|
+
@_cache_of__#{var_name}_initialized ||= false
|
|
48
|
+
if @_cache_of__#{var_name}_initialized
|
|
49
|
+
@_cache_of__#{var_name}_forbidden = false
|
|
50
|
+
@_cache_of__#{var_name}
|
|
51
|
+
else
|
|
52
|
+
@_cache_of__#{var_name}_forbidden ||= false
|
|
53
|
+
if @_cache_of__#{var_name}_forbidden
|
|
54
|
+
@_cache_of__#{var_name}_forbidden = false
|
|
55
|
+
#{org_name}
|
|
56
|
+
else
|
|
57
|
+
@_cache_of__#{var_name}_initialized = true
|
|
58
|
+
@_cache_of__#{var_name} = #{org_name}
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
EOS
|
|
63
|
+
else
|
|
64
|
+
define_cache_manipulator(name, var_name, key_indices)
|
|
65
|
+
class_eval <<-EOS
|
|
66
|
+
define_method("#{name}") do |*args|
|
|
67
|
+
@_cache_of__#{var_name}_initialized ||= false
|
|
68
|
+
if @_cache_of__#{var_name}_initialized
|
|
69
|
+
@_cache_of__#{var_name}_forbidden = false
|
|
70
|
+
if @_cache_of__#{var_name}.include?(args)
|
|
71
|
+
@_cache_of__#{var_name}[args]
|
|
72
|
+
else
|
|
73
|
+
@_cache_of__#{var_name}[args] = #{org_name}(*args)
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
@_cache_of__#{var_name}_forbidden ||= false
|
|
77
|
+
if @_cache_of__#{var_name}_forbidden
|
|
78
|
+
@_cache_of__#{var_name}_forbidden = false
|
|
79
|
+
#{org_name}(*args)
|
|
80
|
+
else
|
|
81
|
+
@_cache_of__#{var_name}_initialized = true
|
|
82
|
+
@_cache_of__#{var_name} = {}
|
|
83
|
+
@_cache_of__#{var_name}[args] = #{org_name}(*args)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
EOS
|
|
88
|
+
end
|
|
89
|
+
else
|
|
90
|
+
define_cache_manipulator(name, var_name, key_indices)
|
|
91
|
+
class_eval <<-EOS
|
|
92
|
+
define_method("#{name}") do |*args|
|
|
93
|
+
@_cache_of__#{var_name}_initialized ||= false
|
|
94
|
+
key = args.values_at(#{key_indices.join(',')})
|
|
95
|
+
if @_cache_of__#{var_name}_initialized
|
|
96
|
+
@_cache_of__#{var_name}_forbidden = false
|
|
97
|
+
if @_cache_of__#{var_name}.include?(key)
|
|
98
|
+
@_cache_of__#{var_name}[key]
|
|
99
|
+
else
|
|
100
|
+
@_cache_of__#{var_name}[key] = #{org_name}(*args)
|
|
101
|
+
end
|
|
102
|
+
else
|
|
103
|
+
@_cache_of__#{var_name}_forbidden ||= false
|
|
104
|
+
if @_cache_of__#{var_name}_forbidden
|
|
105
|
+
@_cache_of__#{var_name}_forbidden = false
|
|
106
|
+
#{org_name}(*args)
|
|
107
|
+
else
|
|
108
|
+
@_cache_of__#{var_name}_initialized = true
|
|
109
|
+
@_cache_of__#{var_name} = {}
|
|
110
|
+
@_cache_of__#{var_name}[key] = #{org_name}(*args)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
EOS
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
def define_cache_manipulator(name, var_name, key_indices = nil)
|
|
120
|
+
class_eval <<-EOS
|
|
121
|
+
define_method("forbid_once_memo_of__#{name}") do
|
|
122
|
+
@_cache_of__#{var_name}_forbidden = true
|
|
123
|
+
end
|
|
124
|
+
define_method("clear_memo_of__#{name}") do
|
|
125
|
+
@_cache_of__#{var_name} = nil
|
|
126
|
+
@_cache_of__#{var_name}_initialized = false
|
|
127
|
+
end
|
|
128
|
+
EOS
|
|
129
|
+
case
|
|
130
|
+
when key_indices && key_indices.empty?
|
|
131
|
+
class_eval <<-EOS
|
|
132
|
+
define_method("forget_memo_of__#{name}") do |*args|
|
|
133
|
+
if @_cache_of__#{var_name}_initialized
|
|
134
|
+
@_cache_of__#{var_name}.delete(args)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
EOS
|
|
138
|
+
when key_indices
|
|
139
|
+
class_eval <<-EOS
|
|
140
|
+
define_method("forget_memo_of__#{name}") do |*args|
|
|
141
|
+
if @_cache_of__#{var_name}_initialized
|
|
142
|
+
key = args.values_at(#{key_indices.join(',')})
|
|
143
|
+
@_cache_of__#{var_name}.delete(key)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
EOS
|
|
147
|
+
else
|
|
148
|
+
class_eval <<-EOS
|
|
149
|
+
define_method("forget_memo_of__#{name}") do
|
|
150
|
+
clear_memo_of__#{name}
|
|
151
|
+
end
|
|
152
|
+
EOS
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
end
|