adlint 2.6.14 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,818 +0,0 @@
|
|
1
|
-
# Metric measurements (cc1-phase) of adlint-exam-c_builtin package.
|
2
|
-
#
|
3
|
-
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-2012, 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-2012, 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
|
-
require "adlint/exam"
|
33
|
-
require "adlint/report"
|
34
|
-
require "adlint/c/phase"
|
35
|
-
require "adlint/c/syntax"
|
36
|
-
|
37
|
-
module AdLint #:nodoc:
|
38
|
-
module Exam #:nodoc:
|
39
|
-
module CBuiltin #:nodoc:
|
40
|
-
|
41
|
-
class FL_STMT < MetricMeasurement
|
42
|
-
def_registrant_phase C::Prepare2Phase
|
43
|
-
|
44
|
-
def initialize(context)
|
45
|
-
super
|
46
|
-
@fpath = context[:sources].first.fpath
|
47
|
-
visitor = context[:c_visitor]
|
48
|
-
visitor.enter_error_statement += method(:count_statement)
|
49
|
-
visitor.enter_generic_labeled_statement += method(:count_statement)
|
50
|
-
visitor.enter_case_labeled_statement += method(:count_statement)
|
51
|
-
visitor.enter_default_labeled_statement += method(:count_statement)
|
52
|
-
visitor.enter_expression_statement += method(:count_statement)
|
53
|
-
visitor.enter_if_statement += method(:count_statement)
|
54
|
-
visitor.enter_if_else_statement += method(:count_statement)
|
55
|
-
visitor.enter_switch_statement += method(:count_statement)
|
56
|
-
visitor.enter_while_statement += method(:count_statement)
|
57
|
-
visitor.enter_do_statement += method(:count_statement)
|
58
|
-
visitor.enter_for_statement += method(:count_statement)
|
59
|
-
visitor.enter_c99_for_statement += method(:count_statement)
|
60
|
-
visitor.enter_goto_statement += method(:count_statement)
|
61
|
-
visitor.enter_continue_statement += method(:count_statement)
|
62
|
-
visitor.enter_break_statement += method(:count_statement)
|
63
|
-
visitor.enter_return_statement += method(:count_statement)
|
64
|
-
visitor.leave_translation_unit += method(:measure)
|
65
|
-
@statement_count = 0
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
def do_prepare(context) end
|
70
|
-
def do_execute(context) end
|
71
|
-
|
72
|
-
def count_statement(statement)
|
73
|
-
if @fpath == statement.location.fpath
|
74
|
-
@statement_count += 1
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def measure(node)
|
79
|
-
FL_STMT(@fpath, @statement_count)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
class FL_FUNC < MetricMeasurement
|
84
|
-
def_registrant_phase C::Prepare2Phase
|
85
|
-
|
86
|
-
def initialize(context)
|
87
|
-
super
|
88
|
-
@fpath = context[:sources].first.fpath
|
89
|
-
visitor = context[:c_visitor]
|
90
|
-
visitor.enter_ansi_function_definition += method(:count_function)
|
91
|
-
visitor.enter_kandr_function_definition += method(:count_function)
|
92
|
-
visitor.leave_translation_unit += method(:measure)
|
93
|
-
@function_count = 0
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
def do_prepare(context) end
|
98
|
-
def do_execute(context) end
|
99
|
-
|
100
|
-
def count_function(function_definition)
|
101
|
-
if @fpath == function_definition.location.fpath
|
102
|
-
@function_count += 1
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def measure(node)
|
107
|
-
FL_FUNC(@fpath, @function_count)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class FN_STMT < MetricMeasurement
|
112
|
-
def_registrant_phase C::Prepare2Phase
|
113
|
-
|
114
|
-
def initialize(context)
|
115
|
-
super
|
116
|
-
@fpath = context[:sources].first.fpath
|
117
|
-
visitor = context[:c_visitor]
|
118
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
119
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
120
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
121
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
122
|
-
visitor.enter_error_statement += method(:count_statement)
|
123
|
-
visitor.enter_generic_labeled_statement += method(:count_statement)
|
124
|
-
visitor.enter_case_labeled_statement += method(:count_statement)
|
125
|
-
visitor.enter_default_labeled_statement += method(:count_statement)
|
126
|
-
visitor.enter_expression_statement += method(:count_statement)
|
127
|
-
visitor.enter_if_statement += method(:count_statement)
|
128
|
-
visitor.enter_if_else_statement += method(:count_statement)
|
129
|
-
visitor.enter_switch_statement += method(:count_statement)
|
130
|
-
visitor.enter_while_statement += method(:count_statement)
|
131
|
-
visitor.enter_do_statement += method(:count_statement)
|
132
|
-
visitor.enter_for_statement += method(:count_statement)
|
133
|
-
visitor.enter_c99_for_statement += method(:count_statement)
|
134
|
-
visitor.enter_goto_statement += method(:count_statement)
|
135
|
-
visitor.enter_continue_statement += method(:count_statement)
|
136
|
-
visitor.enter_break_statement += method(:count_statement)
|
137
|
-
visitor.enter_return_statement += method(:count_statement)
|
138
|
-
@current_function = nil
|
139
|
-
@statement_count = 0
|
140
|
-
end
|
141
|
-
|
142
|
-
private
|
143
|
-
def do_prepare(context) end
|
144
|
-
def do_execute(context) end
|
145
|
-
|
146
|
-
def enter_function(function_definition)
|
147
|
-
if @fpath == function_definition.location.fpath
|
148
|
-
@current_function = function_definition
|
149
|
-
@statement_count = 0
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def leave_function(function_definition)
|
154
|
-
return unless @current_function
|
155
|
-
|
156
|
-
FN_STMT(FunctionIdentifier.new(@current_function.identifier.value,
|
157
|
-
@current_function.signature.to_s),
|
158
|
-
@current_function.location, @statement_count)
|
159
|
-
|
160
|
-
@current_function = nil
|
161
|
-
@statement_count = 0
|
162
|
-
end
|
163
|
-
|
164
|
-
def count_statement(statement)
|
165
|
-
if @current_function
|
166
|
-
@statement_count += 1
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
class FN_UNRC < MetricMeasurement
|
172
|
-
def_registrant_phase C::Prepare2Phase
|
173
|
-
|
174
|
-
def initialize(context)
|
175
|
-
super
|
176
|
-
@fpath = context[:sources].first.fpath
|
177
|
-
visitor = context[:c_visitor]
|
178
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
179
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
180
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
181
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
182
|
-
visitor.enter_error_statement += method(:count_statement)
|
183
|
-
visitor.enter_generic_labeled_statement += method(:count_statement)
|
184
|
-
visitor.enter_case_labeled_statement += method(:count_statement)
|
185
|
-
visitor.enter_default_labeled_statement += method(:count_statement)
|
186
|
-
visitor.enter_expression_statement += method(:count_statement)
|
187
|
-
visitor.enter_if_statement += method(:count_statement)
|
188
|
-
visitor.enter_if_else_statement += method(:count_statement)
|
189
|
-
visitor.enter_switch_statement += method(:count_statement)
|
190
|
-
visitor.enter_while_statement += method(:count_statement)
|
191
|
-
visitor.enter_do_statement += method(:count_statement)
|
192
|
-
visitor.enter_for_statement += method(:count_statement)
|
193
|
-
visitor.enter_c99_for_statement += method(:count_statement)
|
194
|
-
visitor.enter_goto_statement += method(:count_statement)
|
195
|
-
visitor.enter_continue_statement += method(:count_statement)
|
196
|
-
visitor.enter_break_statement += method(:count_statement)
|
197
|
-
visitor.enter_return_statement += method(:count_statement)
|
198
|
-
@current_function = nil
|
199
|
-
@unreached_statement_count = 0
|
200
|
-
end
|
201
|
-
|
202
|
-
private
|
203
|
-
def do_prepare(context) end
|
204
|
-
def do_execute(context) end
|
205
|
-
|
206
|
-
def enter_function(function_definition)
|
207
|
-
if @fpath == function_definition.location.fpath
|
208
|
-
@current_function = function_definition
|
209
|
-
@unreached_statement_count = 0
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def leave_function(function_definition)
|
214
|
-
return unless @current_function
|
215
|
-
|
216
|
-
FN_UNRC(FunctionIdentifier.new(@current_function.identifier.value,
|
217
|
-
@current_function.signature.to_s),
|
218
|
-
@current_function.location, @unreached_statement_count)
|
219
|
-
|
220
|
-
@current_function = nil
|
221
|
-
@unreached_statement_count = 0
|
222
|
-
end
|
223
|
-
|
224
|
-
def count_statement(statement)
|
225
|
-
return unless @current_function
|
226
|
-
|
227
|
-
unless statement.executed?
|
228
|
-
@unreached_statement_count += 1
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
class FN_LINE < MetricMeasurement
|
234
|
-
def_registrant_phase C::Prepare2Phase
|
235
|
-
|
236
|
-
def initialize(context)
|
237
|
-
super
|
238
|
-
@fpath = context[:sources].first.fpath
|
239
|
-
visitor = context[:c_visitor]
|
240
|
-
visitor.enter_ansi_function_definition += method(:measure)
|
241
|
-
visitor.enter_kandr_function_definition += method(:measure)
|
242
|
-
end
|
243
|
-
|
244
|
-
private
|
245
|
-
def do_prepare(context) end
|
246
|
-
def do_execute(context) end
|
247
|
-
|
248
|
-
def measure(function_definition)
|
249
|
-
if @fpath == function_definition.location.fpath
|
250
|
-
FN_LINE(FunctionIdentifier.new(function_definition.identifier.value,
|
251
|
-
function_definition.signature.to_s),
|
252
|
-
function_definition.location, function_definition.lines)
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
class FN_PARA < MetricMeasurement
|
258
|
-
def_registrant_phase C::Prepare2Phase
|
259
|
-
|
260
|
-
def initialize(context)
|
261
|
-
super
|
262
|
-
@fpath = context[:sources].first.fpath
|
263
|
-
visitor = context[:c_visitor]
|
264
|
-
visitor.enter_ansi_function_definition += method(:measure_ansi_func)
|
265
|
-
visitor.enter_kandr_function_definition += method(:measure_kandr_func)
|
266
|
-
end
|
267
|
-
|
268
|
-
private
|
269
|
-
def do_prepare(context) end
|
270
|
-
def do_execute(context) end
|
271
|
-
|
272
|
-
def measure_ansi_func(function_definition)
|
273
|
-
if @fpath == function_definition.location.fpath
|
274
|
-
# TODO: Determine how many parameters if function has va_list.
|
275
|
-
if function_definition.parameter_type_list
|
276
|
-
parameters = function_definition.parameter_definitions
|
277
|
-
FN_PARA(FunctionIdentifier.new(function_definition.identifier.value,
|
278
|
-
function_definition.signature.to_s),
|
279
|
-
function_definition.location,
|
280
|
-
parameters.count { |param| !param.type.void? })
|
281
|
-
else
|
282
|
-
# TODO: Determine how many parameters if signature is abbreviated.
|
283
|
-
FN_PARA(FunctionIdentifier.new(function_definition.identifier.value,
|
284
|
-
function_definition.signature.to_s),
|
285
|
-
function_definition.location, 0)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
def measure_kandr_func(function_definition)
|
291
|
-
if @fpath == function_definition.location.fpath
|
292
|
-
FN_PARA(FunctionIdentifier.new(function_definition.identifier.value,
|
293
|
-
function_definition.signature.to_s),
|
294
|
-
function_definition.location,
|
295
|
-
function_definition.identifier_list.size)
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
class FN_UNUV < MetricMeasurement
|
301
|
-
def_registrant_phase C::Prepare2Phase
|
302
|
-
|
303
|
-
def initialize(context)
|
304
|
-
super
|
305
|
-
@fpath = context[:sources].first.fpath
|
306
|
-
interp = context[:c_interpreter]
|
307
|
-
interp.on_function_started += method(:enter_function)
|
308
|
-
interp.on_function_ended += method(:leave_function)
|
309
|
-
interp.on_variable_defined += method(:define_variable)
|
310
|
-
interp.on_parameter_defined += method(:define_variable)
|
311
|
-
interp.on_variable_referred += method(:refer_variable)
|
312
|
-
interp.on_variable_value_referred += method(:read_variable)
|
313
|
-
interp.on_variable_value_updated += method(:write_variable)
|
314
|
-
@current_function = nil
|
315
|
-
@variables = nil
|
316
|
-
end
|
317
|
-
|
318
|
-
private
|
319
|
-
def do_prepare(context) end
|
320
|
-
def do_execute(context) end
|
321
|
-
|
322
|
-
def enter_function(function_definition, function)
|
323
|
-
if @fpath == function_definition.location.fpath
|
324
|
-
@current_function = function_definition
|
325
|
-
@variables = {}
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def leave_function(function_definition, function)
|
330
|
-
return unless @current_function
|
331
|
-
|
332
|
-
useless_count = @variables.each_value.reduce(0) { |count, read_count|
|
333
|
-
read_count == 0 ? count + 1 : count
|
334
|
-
}
|
335
|
-
|
336
|
-
FN_UNUV(FunctionIdentifier.new(@current_function.identifier.value,
|
337
|
-
@current_function.signature.to_s),
|
338
|
-
@current_function.location, useless_count)
|
339
|
-
|
340
|
-
@current_function = nil
|
341
|
-
@variables = nil
|
342
|
-
end
|
343
|
-
|
344
|
-
def define_variable(definition, variable)
|
345
|
-
if @current_function
|
346
|
-
@variables[variable.name] = 0
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
def refer_variable(expression, variable)
|
351
|
-
return unless @current_function
|
352
|
-
|
353
|
-
if variable.named? && @variables[variable.name]
|
354
|
-
@variables[variable.name] += 1
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
def read_variable(expression, variable)
|
359
|
-
return unless @current_function
|
360
|
-
|
361
|
-
if variable.named? && @variables[variable.name]
|
362
|
-
@variables[variable.name] += 1
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
def write_variable(expression, variable)
|
367
|
-
return unless @current_function
|
368
|
-
|
369
|
-
if variable.named? && @variables[variable.name]
|
370
|
-
@variables[variable.name] = 0
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
class FN_CSUB < MetricMeasurement
|
376
|
-
def_registrant_phase C::Prepare2Phase
|
377
|
-
|
378
|
-
def initialize(context)
|
379
|
-
super
|
380
|
-
@fpath = context[:sources].first.fpath
|
381
|
-
visitor = context[:c_visitor]
|
382
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
383
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
384
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
385
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
386
|
-
visitor.enter_function_call_expression += method(:count_function_call)
|
387
|
-
@current_function = nil
|
388
|
-
@function_call_count = 0
|
389
|
-
end
|
390
|
-
|
391
|
-
private
|
392
|
-
def do_prepare(context) end
|
393
|
-
def do_execute(context) end
|
394
|
-
|
395
|
-
def enter_function(function_definition)
|
396
|
-
if @fpath == function_definition.location.fpath
|
397
|
-
@current_function = function_definition
|
398
|
-
@function_call_count = 0
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
def leave_function(function_definition)
|
403
|
-
return unless @current_function
|
404
|
-
|
405
|
-
FN_CSUB(FunctionIdentifier.new(@current_function.identifier.value,
|
406
|
-
@current_function.signature.to_s),
|
407
|
-
@current_function.location, @function_call_count)
|
408
|
-
|
409
|
-
@current_function = nil
|
410
|
-
@function_call_count = 0
|
411
|
-
end
|
412
|
-
|
413
|
-
def count_function_call(node)
|
414
|
-
if @current_function
|
415
|
-
@function_call_count += 1
|
416
|
-
end
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
class FN_GOTO < MetricMeasurement
|
421
|
-
def_registrant_phase C::Prepare2Phase
|
422
|
-
|
423
|
-
def initialize(context)
|
424
|
-
super
|
425
|
-
@fpath = context[:sources].first.fpath
|
426
|
-
visitor = context[:c_visitor]
|
427
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
428
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
429
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
430
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
431
|
-
visitor.enter_goto_statement += method(:count_goto)
|
432
|
-
@current_function = nil
|
433
|
-
@goto_count = 0
|
434
|
-
end
|
435
|
-
|
436
|
-
private
|
437
|
-
def do_prepare(context) end
|
438
|
-
def do_execute(context) end
|
439
|
-
|
440
|
-
def enter_function(function_definition)
|
441
|
-
if @fpath == function_definition.location.fpath
|
442
|
-
@current_function = function_definition
|
443
|
-
@goto_count = 0
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
def leave_function(function_definition)
|
448
|
-
return unless @current_function
|
449
|
-
|
450
|
-
FN_GOTO(FunctionIdentifier.new(@current_function.identifier.value,
|
451
|
-
@current_function.signature.to_s),
|
452
|
-
@current_function.location, @goto_count)
|
453
|
-
|
454
|
-
@current_function = nil
|
455
|
-
@goto_count = 0
|
456
|
-
end
|
457
|
-
|
458
|
-
def count_goto(node)
|
459
|
-
if @current_function
|
460
|
-
@goto_count += 1
|
461
|
-
end
|
462
|
-
end
|
463
|
-
end
|
464
|
-
|
465
|
-
class FN_RETN < MetricMeasurement
|
466
|
-
def_registrant_phase C::Prepare2Phase
|
467
|
-
|
468
|
-
def initialize(context)
|
469
|
-
super
|
470
|
-
@fpath = context[:sources].first.fpath
|
471
|
-
visitor = context[:c_visitor]
|
472
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
473
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
474
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
475
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
476
|
-
visitor.enter_error_statement += method(:enter_statement)
|
477
|
-
visitor.enter_generic_labeled_statement += method(:enter_statement)
|
478
|
-
visitor.enter_case_labeled_statement += method(:enter_statement)
|
479
|
-
visitor.enter_default_labeled_statement += method(:enter_statement)
|
480
|
-
visitor.enter_expression_statement += method(:enter_statement)
|
481
|
-
visitor.enter_if_statement += method(:enter_statement)
|
482
|
-
visitor.enter_if_else_statement += method(:enter_statement)
|
483
|
-
visitor.enter_switch_statement += method(:enter_statement)
|
484
|
-
visitor.enter_while_statement += method(:enter_statement)
|
485
|
-
visitor.enter_do_statement += method(:enter_statement)
|
486
|
-
visitor.enter_for_statement += method(:enter_statement)
|
487
|
-
visitor.enter_c99_for_statement += method(:enter_statement)
|
488
|
-
visitor.enter_goto_statement += method(:enter_statement)
|
489
|
-
visitor.enter_continue_statement += method(:enter_statement)
|
490
|
-
visitor.enter_break_statement += method(:enter_statement)
|
491
|
-
visitor.enter_return_statement += method(:count_return)
|
492
|
-
@current_function = nil
|
493
|
-
@return_count = 0
|
494
|
-
@last_statement = nil
|
495
|
-
end
|
496
|
-
|
497
|
-
private
|
498
|
-
def do_prepare(context) end
|
499
|
-
def do_execute(context) end
|
500
|
-
|
501
|
-
def enter_function(function_definition)
|
502
|
-
if @fpath == function_definition.location.fpath
|
503
|
-
@current_function = function_definition
|
504
|
-
@return_count = 0
|
505
|
-
@last_statement = nil
|
506
|
-
end
|
507
|
-
end
|
508
|
-
|
509
|
-
def leave_function(function_definition)
|
510
|
-
return unless @current_function
|
511
|
-
|
512
|
-
if @current_function.type.return_type.void? &&
|
513
|
-
!(@last_statement.kind_of?(C::ReturnStatement))
|
514
|
-
FN_RETN(FunctionIdentifier.new(@current_function.identifier.value,
|
515
|
-
@current_function.signature.to_s),
|
516
|
-
@current_function.location, @return_count + 1)
|
517
|
-
else
|
518
|
-
FN_RETN(FunctionIdentifier.new(@current_function.identifier.value,
|
519
|
-
@current_function.signature.to_s),
|
520
|
-
@current_function.location, @return_count)
|
521
|
-
end
|
522
|
-
|
523
|
-
@current_function = nil
|
524
|
-
@return_count = 0
|
525
|
-
@last_statement = nil
|
526
|
-
end
|
527
|
-
|
528
|
-
def enter_statement(node)
|
529
|
-
return unless @current_function
|
530
|
-
|
531
|
-
if node.executed?
|
532
|
-
@last_statement = node
|
533
|
-
end
|
534
|
-
end
|
535
|
-
|
536
|
-
def count_return(node)
|
537
|
-
if @current_function
|
538
|
-
@return_count += 1
|
539
|
-
@last_statement = node
|
540
|
-
end
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
class FN_UELS < MetricMeasurement
|
545
|
-
def_registrant_phase C::Prepare2Phase
|
546
|
-
|
547
|
-
def initialize(context)
|
548
|
-
super
|
549
|
-
@fpath = context[:sources].first.fpath
|
550
|
-
visitor = context[:c_visitor]
|
551
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
552
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
553
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
554
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
555
|
-
visitor.enter_if_else_statement += method(:enter_if_else_statement)
|
556
|
-
visitor.leave_if_else_statement += method(:leave_if_else_statement)
|
557
|
-
@current_function = nil
|
558
|
-
@if_else_statement_chain = 0
|
559
|
-
@incomplete_if_else_statement_count = 0
|
560
|
-
end
|
561
|
-
|
562
|
-
private
|
563
|
-
def do_prepare(context) end
|
564
|
-
def do_execute(context) end
|
565
|
-
|
566
|
-
def enter_function(function_definition)
|
567
|
-
if @fpath == function_definition.location.fpath
|
568
|
-
@current_function = function_definition
|
569
|
-
@if_else_statement_chain = 0
|
570
|
-
@incomplete_if_else_statement_count = 0
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
def leave_function(function_definition)
|
575
|
-
return unless @current_function
|
576
|
-
|
577
|
-
FN_UELS(FunctionIdentifier.new(@current_function.identifier.value,
|
578
|
-
@current_function.signature.to_s),
|
579
|
-
@current_function.location, @incomplete_if_else_statement_count)
|
580
|
-
|
581
|
-
@current_function = nil
|
582
|
-
@if_else_statement_chain = 0
|
583
|
-
@incomplete_if_else_statement_count = 0
|
584
|
-
end
|
585
|
-
|
586
|
-
def enter_if_else_statement(node)
|
587
|
-
@if_else_statement_chain += 1
|
588
|
-
|
589
|
-
if @current_function && @if_else_statement_chain > 0
|
590
|
-
if node.else_statement.kind_of?(C::IfStatement)
|
591
|
-
@incomplete_if_else_statement_count += 1
|
592
|
-
end
|
593
|
-
end
|
594
|
-
end
|
595
|
-
|
596
|
-
def leave_if_else_statement(node)
|
597
|
-
@if_else_statement_chain -= 1
|
598
|
-
end
|
599
|
-
end
|
600
|
-
|
601
|
-
class FN_NEST < MetricMeasurement
|
602
|
-
def_registrant_phase C::Prepare2Phase
|
603
|
-
|
604
|
-
def initialize(context)
|
605
|
-
super
|
606
|
-
@fpath = context[:sources].first.fpath
|
607
|
-
visitor = context[:c_visitor]
|
608
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
609
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
610
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
611
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
612
|
-
visitor.enter_compound_statement += method(:enter_block)
|
613
|
-
visitor.leave_compound_statement += method(:leave_block)
|
614
|
-
visitor.enter_if_statement += method(:check_statement)
|
615
|
-
visitor.enter_if_else_statement += method(:check_statement)
|
616
|
-
visitor.enter_while_statement += method(:check_statement)
|
617
|
-
visitor.enter_do_statement += method(:check_statement)
|
618
|
-
visitor.enter_for_statement += method(:check_statement)
|
619
|
-
visitor.enter_c99_for_statement += method(:check_statement)
|
620
|
-
@current_function = nil
|
621
|
-
end
|
622
|
-
|
623
|
-
private
|
624
|
-
def do_prepare(context) end
|
625
|
-
def do_execute(context) end
|
626
|
-
|
627
|
-
def enter_function(function_definition)
|
628
|
-
if @fpath == function_definition.location.fpath
|
629
|
-
@current_function = function_definition
|
630
|
-
# NOTE: Nest level of the top of the function is 0.
|
631
|
-
# Function definition must have a compound-statement as the
|
632
|
-
# function body.
|
633
|
-
@max_nest_level = @current_nest_level = -1
|
634
|
-
end
|
635
|
-
end
|
636
|
-
|
637
|
-
def leave_function(function_definition)
|
638
|
-
return unless @current_function
|
639
|
-
|
640
|
-
FN_NEST(FunctionIdentifier.new(@current_function.identifier.value,
|
641
|
-
@current_function.signature.to_s),
|
642
|
-
@current_function.location, @max_nest_level)
|
643
|
-
|
644
|
-
@current_function = nil
|
645
|
-
end
|
646
|
-
|
647
|
-
def enter_block(compound_statement)
|
648
|
-
if @current_function
|
649
|
-
@current_nest_level += 1
|
650
|
-
@max_nest_level = [@max_nest_level, @current_nest_level].max
|
651
|
-
end
|
652
|
-
end
|
653
|
-
|
654
|
-
def leave_block(compound_statement)
|
655
|
-
if @current_function
|
656
|
-
@current_nest_level -= 1
|
657
|
-
end
|
658
|
-
end
|
659
|
-
|
660
|
-
def check_statement(statement)
|
661
|
-
return unless @current_function
|
662
|
-
|
663
|
-
case statement
|
664
|
-
when C::IfStatement
|
665
|
-
sub_statement = statement.statement
|
666
|
-
when C::IfElseStatement
|
667
|
-
if statement.then_statement.kind_of?(C::CompoundStatement)
|
668
|
-
sub_statement = statement.else_statement
|
669
|
-
else
|
670
|
-
sub_statement = statement.then_statement
|
671
|
-
end
|
672
|
-
when C::WhileStatement, C::DoStatement
|
673
|
-
sub_statement = statement.statement
|
674
|
-
when C::ForStatement, C::C99ForStatement
|
675
|
-
sub_statement = statement.body_statement
|
676
|
-
end
|
677
|
-
|
678
|
-
case sub_statement
|
679
|
-
when C::CompoundStatement, C::IfStatement, C::IfElseStatement
|
680
|
-
else
|
681
|
-
@current_nest_level += 1
|
682
|
-
@max_nest_level = [@max_nest_level, @current_nest_level].max
|
683
|
-
end
|
684
|
-
end
|
685
|
-
end
|
686
|
-
|
687
|
-
class FN_PATH < MetricMeasurement
|
688
|
-
def_registrant_phase C::Prepare2Phase
|
689
|
-
|
690
|
-
def initialize(context)
|
691
|
-
super
|
692
|
-
@fpath = context[:sources].first.fpath
|
693
|
-
interp = context[:c_interpreter]
|
694
|
-
interp.on_function_started += method(:enter_function)
|
695
|
-
interp.on_function_ended += method(:leave_function)
|
696
|
-
interp.on_branch_started += method(:enter_branch)
|
697
|
-
interp.on_branch_ended += method(:leave_branch)
|
698
|
-
@current_function = nil
|
699
|
-
end
|
700
|
-
|
701
|
-
private
|
702
|
-
def do_prepare(context) end
|
703
|
-
def do_execute(context) end
|
704
|
-
|
705
|
-
def enter_function(function_definition, function)
|
706
|
-
if @fpath == function_definition.location.fpath
|
707
|
-
@current_function = function_definition
|
708
|
-
|
709
|
-
# NOTE: Number of paths in the current function.
|
710
|
-
@paths_in_function = 1
|
711
|
-
# NOTE: Stack of the number of paths to enter the current branch group.
|
712
|
-
@paths_to_enter_branch_group = [@paths_in_function]
|
713
|
-
# NOTE: Stack of the number of paths in the current branch.
|
714
|
-
@paths_in_branch = [@paths_in_function]
|
715
|
-
# NOTE: Stack of the number of paths in the current branch group.
|
716
|
-
@paths_in_branch_group = [@paths_in_function]
|
717
|
-
end
|
718
|
-
end
|
719
|
-
|
720
|
-
def leave_function(function_definition, function)
|
721
|
-
return unless @current_function
|
722
|
-
|
723
|
-
FN_PATH(FunctionIdentifier.new(@current_function.identifier.value,
|
724
|
-
@current_function.signature.to_s),
|
725
|
-
@current_function.location, @paths_in_function)
|
726
|
-
|
727
|
-
@current_function = nil
|
728
|
-
end
|
729
|
-
|
730
|
-
def enter_branch(branch)
|
731
|
-
return unless @current_function
|
732
|
-
|
733
|
-
# NOTE: Entering into new branch group.
|
734
|
-
if branch.first?
|
735
|
-
@paths_in_function -= @paths_in_branch.last
|
736
|
-
@paths_to_enter_branch_group.push(@paths_in_branch.last)
|
737
|
-
@paths_in_branch_group.push(0)
|
738
|
-
end
|
739
|
-
|
740
|
-
# NOTE: Entering into new branch.
|
741
|
-
@paths_in_branch.push(@paths_to_enter_branch_group.last)
|
742
|
-
@paths_in_function += @paths_to_enter_branch_group.last
|
743
|
-
end
|
744
|
-
|
745
|
-
def leave_branch(branch)
|
746
|
-
return unless @current_function
|
747
|
-
|
748
|
-
paths_in_this_branch = @paths_in_branch.pop
|
749
|
-
|
750
|
-
# NOTE: Leaving from the current branch whose paths are not terminated.
|
751
|
-
unless branch.break_with_return?
|
752
|
-
@paths_in_branch_group[-1] += paths_in_this_branch
|
753
|
-
end
|
754
|
-
|
755
|
-
# NOTE: Leaving from the current branch group.
|
756
|
-
if branch.final?
|
757
|
-
paths_to_enter_this_branch_group = @paths_to_enter_branch_group.pop
|
758
|
-
paths_in_this_branch_group = @paths_in_branch_group.pop
|
759
|
-
|
760
|
-
@paths_in_branch[-1] = paths_in_this_branch_group
|
761
|
-
|
762
|
-
# NOTE: The current branch group is an incomplete branch group.
|
763
|
-
unless branch.group.complete?
|
764
|
-
@paths_in_function += paths_to_enter_this_branch_group
|
765
|
-
@paths_in_branch[-1] += paths_to_enter_this_branch_group
|
766
|
-
end
|
767
|
-
end
|
768
|
-
end
|
769
|
-
end
|
770
|
-
|
771
|
-
class FN_CYCM < MetricMeasurement
|
772
|
-
def_registrant_phase C::Prepare2Phase
|
773
|
-
|
774
|
-
def initialize(context)
|
775
|
-
super
|
776
|
-
@fpath = context[:sources].first.fpath
|
777
|
-
visitor = context[:c_visitor]
|
778
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
779
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
780
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
781
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
782
|
-
visitor.enter_if_statement += method(:enter_selection)
|
783
|
-
visitor.enter_if_else_statement += method(:enter_selection)
|
784
|
-
visitor.enter_case_labeled_statement += method(:enter_selection)
|
785
|
-
@current_function = nil
|
786
|
-
@complexity = 0
|
787
|
-
end
|
788
|
-
|
789
|
-
private
|
790
|
-
def do_prepare(context) end
|
791
|
-
def do_execute(context) end
|
792
|
-
|
793
|
-
def enter_function(function_definition)
|
794
|
-
if @fpath == function_definition.location.fpath
|
795
|
-
@current_function = function_definition
|
796
|
-
@complexity = 0
|
797
|
-
end
|
798
|
-
end
|
799
|
-
|
800
|
-
def leave_function(function_definition)
|
801
|
-
return unless @current_function
|
802
|
-
|
803
|
-
FN_CYCM(FunctionIdentifier.new(@current_function.identifier.value,
|
804
|
-
@current_function.signature.to_s),
|
805
|
-
@current_function.location, @complexity + 1)
|
806
|
-
|
807
|
-
@current_function = nil
|
808
|
-
@total_branch_count = 0
|
809
|
-
end
|
810
|
-
|
811
|
-
def enter_selection(if_statement)
|
812
|
-
@complexity += 1 if @current_function
|
813
|
-
end
|
814
|
-
end
|
815
|
-
|
816
|
-
end
|
817
|
-
end
|
818
|
-
end
|