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
@@ -0,0 +1,459 @@
|
|
1
|
+
# Code structure extractions (cc1-phase) of adlint-exam-c_builtin package.
|
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
|
+
require "adlint/exam"
|
33
|
+
require "adlint/report"
|
34
|
+
require "adlint/cc1/phase"
|
35
|
+
require "adlint/cc1/syntax"
|
36
|
+
|
37
|
+
module AdLint #:nodoc:
|
38
|
+
module Exam #:nodoc:
|
39
|
+
module CBuiltin #:nodoc:
|
40
|
+
|
41
|
+
class TypeDeclExtraction < CodeExtraction
|
42
|
+
def_registrant_phase Cc1::Prepare2Phase
|
43
|
+
|
44
|
+
def initialize(phase_ctxt)
|
45
|
+
super
|
46
|
+
visitor = phase_ctxt[:cc1_visitor]
|
47
|
+
visitor.enter_typedef_declaration += T(:extract_typedef)
|
48
|
+
visitor.enter_struct_type_declaration += T(:extract_struct)
|
49
|
+
visitor.enter_union_type_declaration += T(:extract_union)
|
50
|
+
visitor.enter_enum_type_declaration += T(:extract_enum)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def do_prepare(*) end
|
55
|
+
def do_execute(*) end
|
56
|
+
|
57
|
+
def extract_typedef(typedef_dcl)
|
58
|
+
TYPEDCL(typedef_dcl.identifier.location, "T",
|
59
|
+
typedef_dcl.type.name, typedef_dcl.type.image)
|
60
|
+
end
|
61
|
+
|
62
|
+
def extract_struct(struct_type_dcl)
|
63
|
+
TYPEDCL(struct_type_dcl.identifier.location, "S",
|
64
|
+
struct_type_dcl.type.name, struct_type_dcl.type.image)
|
65
|
+
end
|
66
|
+
|
67
|
+
def extract_union(union_type_dcl)
|
68
|
+
TYPEDCL(union_type_dcl.identifier.location, "U",
|
69
|
+
union_type_dcl.type.name, union_type_dcl.type.image)
|
70
|
+
end
|
71
|
+
|
72
|
+
def extract_enum(enum_type_dcl)
|
73
|
+
TYPEDCL(enum_type_dcl.identifier.location, "E",
|
74
|
+
enum_type_dcl.type.name, enum_type_dcl.type.image)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class GVarDeclExtraction < CodeExtraction
|
79
|
+
def_registrant_phase Cc1::Prepare2Phase
|
80
|
+
|
81
|
+
def initialize(phase_ctxt)
|
82
|
+
super
|
83
|
+
interp = phase_ctxt[:cc1_interpreter]
|
84
|
+
interp.on_variable_declared += T(:extract)
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def do_prepare(*) end
|
89
|
+
def do_execute(*) end
|
90
|
+
|
91
|
+
def extract(var_dcl, var)
|
92
|
+
if var.declared_as_extern?
|
93
|
+
GVARDCL(var_dcl.identifier.location, var_dcl.identifier.value,
|
94
|
+
var_dcl.type.brief_image)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class FuncDeclExtraction < CodeExtraction
|
100
|
+
def_registrant_phase Cc1::Prepare2Phase
|
101
|
+
|
102
|
+
def initialize(phase_ctxt)
|
103
|
+
super
|
104
|
+
interp = phase_ctxt[:cc1_interpreter]
|
105
|
+
interp.on_explicit_function_declared += T(:extract_explicit_dcl)
|
106
|
+
interp.on_implicit_function_declared += T(:extract_implicit_dcl)
|
107
|
+
interp.on_block_started += T(:enter_block)
|
108
|
+
interp.on_block_ended += T(:leave_block)
|
109
|
+
@block_level = 0
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
def do_prepare(*) end
|
114
|
+
def do_execute(*) end
|
115
|
+
|
116
|
+
def extract_explicit_dcl(fun_dcl, fun)
|
117
|
+
if fun.declared_as_extern?
|
118
|
+
FUNCDCL(fun_dcl.identifier.location, "X",
|
119
|
+
@block_level == 0 ? "F" : "B", "E",
|
120
|
+
FunctionId.new(fun_dcl.identifier.value,
|
121
|
+
fun_dcl.signature.to_s))
|
122
|
+
else
|
123
|
+
FUNCDCL(fun_dcl.identifier.location, "I",
|
124
|
+
@block_level == 0 ? "F" : "B", "E",
|
125
|
+
FunctionId.new(fun_dcl.identifier.value,
|
126
|
+
fun_dcl.signature.to_s))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def extract_implicit_dcl(expr, fun)
|
131
|
+
if fun.named?
|
132
|
+
FUNCDCL(expr.location, "X", "F", "I",
|
133
|
+
FunctionId.new(fun.name, fun.signature.to_s))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def enter_block(*)
|
138
|
+
@block_level += 1
|
139
|
+
end
|
140
|
+
|
141
|
+
def leave_block(*)
|
142
|
+
@block_level -= 1
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class VarDefExtraction < CodeExtraction
|
147
|
+
def_registrant_phase Cc1::Prepare2Phase
|
148
|
+
|
149
|
+
def initialize(phase_ctxt)
|
150
|
+
super
|
151
|
+
interp = phase_ctxt[:cc1_interpreter]
|
152
|
+
interp.on_variable_defined += T(:extract_variable)
|
153
|
+
interp.on_parameter_defined += T(:extract_parameter)
|
154
|
+
interp.on_block_started += T(:enter_block)
|
155
|
+
interp.on_block_ended += T(:leave_block)
|
156
|
+
@block_level = 0
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
def do_prepare(*) end
|
161
|
+
def do_execute(*) end
|
162
|
+
|
163
|
+
def extract_variable(var_def, var)
|
164
|
+
case
|
165
|
+
when var.declared_as_extern?
|
166
|
+
VARDEF(var_def.identifier.location, "X", @block_level == 0 ? "F" : "B",
|
167
|
+
storage_class_type(var_def.storage_class_specifier),
|
168
|
+
var_def.identifier.value, var_def.type.brief_image)
|
169
|
+
when var.declared_as_static?
|
170
|
+
VARDEF(var_def.identifier.location, "I", @block_level == 0 ? "F" : "B",
|
171
|
+
storage_class_type(var_def.storage_class_specifier),
|
172
|
+
var_def.identifier.value, var_def.type.brief_image)
|
173
|
+
when var.declared_as_auto?
|
174
|
+
VARDEF(var_def.identifier.location, "I", @block_level == 0 ? "F" : "B",
|
175
|
+
storage_class_type(var_def.storage_class_specifier),
|
176
|
+
var_def.identifier.value, var_def.type.brief_image)
|
177
|
+
when var.declared_as_register?
|
178
|
+
VARDEF(var_def.identifier.location, "I", @block_level == 0 ? "F" : "B",
|
179
|
+
storage_class_type(var_def.storage_class_specifier),
|
180
|
+
var_def.identifier.value, var_def.type.brief_image)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def extract_parameter(param_def, var)
|
185
|
+
if var.named?
|
186
|
+
VARDEF(param_def.identifier.location, "I", "P",
|
187
|
+
storage_class_type(param_def.storage_class_specifier),
|
188
|
+
param_def.identifier.value, param_def.type.brief_image)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def enter_block(*)
|
193
|
+
@block_level += 1
|
194
|
+
end
|
195
|
+
|
196
|
+
def leave_block(*)
|
197
|
+
@block_level -= 1
|
198
|
+
end
|
199
|
+
|
200
|
+
def storage_class_type(sc_spec)
|
201
|
+
if sc_spec
|
202
|
+
case sc_spec.type
|
203
|
+
when :AUTO
|
204
|
+
"A"
|
205
|
+
when :REGISTER
|
206
|
+
"R"
|
207
|
+
when :STATIC
|
208
|
+
"S"
|
209
|
+
when :EXTERN
|
210
|
+
"E"
|
211
|
+
else
|
212
|
+
"N"
|
213
|
+
end
|
214
|
+
else
|
215
|
+
"N"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class FuncDefExtraction < CodeExtraction
|
221
|
+
def_registrant_phase Cc1::Prepare2Phase
|
222
|
+
|
223
|
+
def initialize(phase_ctxt)
|
224
|
+
super
|
225
|
+
interp = phase_ctxt[:cc1_interpreter]
|
226
|
+
interp.on_explicit_function_defined += T(:extract_function)
|
227
|
+
end
|
228
|
+
|
229
|
+
private
|
230
|
+
def do_prepare(*) end
|
231
|
+
def do_execute(*) end
|
232
|
+
|
233
|
+
def extract_function(fun_def, fun)
|
234
|
+
fun_id = FunctionId.new(fun_def.identifier.value, fun_def.signature.to_s)
|
235
|
+
case
|
236
|
+
when fun.declared_as_extern?
|
237
|
+
FUNCDEF(fun_def.identifier.location, "X", "F", fun_id, fun_def.lines)
|
238
|
+
when fun.declared_as_static?
|
239
|
+
FUNCDEF(fun_def.identifier.location, "I", "F", fun_id, fun_def.lines)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
class LabelDefExtraction < CodeExtraction
|
245
|
+
def_registrant_phase Cc1::Prepare2Phase
|
246
|
+
|
247
|
+
def initialize(phase_ctxt)
|
248
|
+
super
|
249
|
+
visitor = phase_ctxt[:cc1_visitor]
|
250
|
+
visitor.enter_generic_labeled_statement += T(:extract)
|
251
|
+
end
|
252
|
+
|
253
|
+
private
|
254
|
+
def do_prepare(*) end
|
255
|
+
def do_execute(*) end
|
256
|
+
|
257
|
+
def extract(labeled_stmt)
|
258
|
+
LABELDEF(labeled_stmt.label.location, labeled_stmt.label.value)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
class InitializationExtraction < CodeExtraction
|
263
|
+
def_registrant_phase Cc1::Prepare2Phase
|
264
|
+
|
265
|
+
def initialize(phase_ctxt)
|
266
|
+
super
|
267
|
+
visitor = phase_ctxt[:cc1_visitor]
|
268
|
+
visitor.enter_variable_definition += T(:extract)
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
def do_prepare(*) end
|
273
|
+
def do_execute(*) end
|
274
|
+
|
275
|
+
def extract(var_def)
|
276
|
+
if var_def.initializer
|
277
|
+
INITIALIZATION(var_def.identifier.location, var_def.identifier.value,
|
278
|
+
var_def.initializer.to_s)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
class AssignmentExtraction < CodeExtraction
|
284
|
+
def_registrant_phase Cc1::Prepare2Phase
|
285
|
+
|
286
|
+
def initialize(phase_ctxt)
|
287
|
+
super
|
288
|
+
visitor = phase_ctxt[:cc1_visitor]
|
289
|
+
visitor.enter_simple_assignment_expression += T(:extract)
|
290
|
+
visitor.enter_compound_assignment_expression += T(:extract)
|
291
|
+
end
|
292
|
+
|
293
|
+
private
|
294
|
+
def do_prepare(*) end
|
295
|
+
def do_execute(*) end
|
296
|
+
|
297
|
+
def extract(assign_expr)
|
298
|
+
ASSIGNMENT(assign_expr.operator.location, assign_expr.lhs_operand.to_s,
|
299
|
+
stringify(assign_expr))
|
300
|
+
end
|
301
|
+
|
302
|
+
def stringify(assign_expr)
|
303
|
+
"#{assign_expr.operator.value} #{assign_expr.rhs_operand.to_s}"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
class FuncCallExtraction < CodeExtraction
|
308
|
+
def_registrant_phase Cc1::Prepare2Phase
|
309
|
+
|
310
|
+
def initialize(phase_ctxt)
|
311
|
+
super
|
312
|
+
@interp = phase_ctxt[:cc1_interpreter]
|
313
|
+
@interp.on_function_started += T(:update_caller)
|
314
|
+
@interp.on_function_call_expr_evaled += T(:extract_function_call)
|
315
|
+
@caller = nil
|
316
|
+
end
|
317
|
+
|
318
|
+
private
|
319
|
+
def do_prepare(*) end
|
320
|
+
def do_execute(*) end
|
321
|
+
|
322
|
+
def update_caller(*, fun)
|
323
|
+
@caller = fun
|
324
|
+
end
|
325
|
+
|
326
|
+
def extract_function_call(funcall_expr, fun, *)
|
327
|
+
if @caller && fun.named?
|
328
|
+
CALL(funcall_expr.location,
|
329
|
+
FunctionId.new(@caller.name, @caller.signature.to_s),
|
330
|
+
FunctionId.new(fun.name, fun.signature.to_s))
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
class CrossRefExtraction < CodeExtraction
|
336
|
+
def_registrant_phase Cc1::Prepare2Phase
|
337
|
+
|
338
|
+
def initialize(phase_ctxt)
|
339
|
+
super
|
340
|
+
interp = phase_ctxt[:cc1_interpreter]
|
341
|
+
interp.on_function_started += T(:update_accessor)
|
342
|
+
interp.on_function_ended += T(:clear_accessor)
|
343
|
+
interp.on_variable_value_referred += T(:extract_variable_read)
|
344
|
+
interp.on_variable_value_updated += T(:extract_variable_write)
|
345
|
+
interp.on_function_referred += T(:extract_function_reference)
|
346
|
+
@accessor = nil
|
347
|
+
end
|
348
|
+
|
349
|
+
private
|
350
|
+
def do_prepare(*) end
|
351
|
+
def do_execute(*) end
|
352
|
+
|
353
|
+
def update_accessor(*, fun)
|
354
|
+
@accessor = fun
|
355
|
+
end
|
356
|
+
|
357
|
+
def clear_accessor(*)
|
358
|
+
@accessor = nil
|
359
|
+
end
|
360
|
+
|
361
|
+
def extract_variable_read(expr, var)
|
362
|
+
if @accessor && var.scope.global? && var.named?
|
363
|
+
# NOTE: When a value of the inner-variable of array or composite object
|
364
|
+
# is referred, dependency record of only outmost-variable access
|
365
|
+
# should be output.
|
366
|
+
var = var.owner while var.inner?
|
367
|
+
XREF_VAR(expr.location,
|
368
|
+
FunctionId.new(@accessor.name, @accessor.signature.to_s),
|
369
|
+
"R", var.name)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def extract_variable_write(expr, var)
|
374
|
+
if @accessor && var.scope.global? && var.named?
|
375
|
+
unless var.inner?
|
376
|
+
# NOTE: When a value of the inner-variable of array or composite
|
377
|
+
# object is updated, dependency record of the inner-variable
|
378
|
+
# access should not be output and the outer variable's value
|
379
|
+
# will also be notified later.
|
380
|
+
XREF_VAR(expr.location,
|
381
|
+
FunctionId.new(@accessor.name, @accessor.signature.to_s),
|
382
|
+
"W", var.name)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
def extract_function_reference(expr, fun)
|
388
|
+
if @accessor && fun.named?
|
389
|
+
XREF_FUNC(expr.location,
|
390
|
+
FunctionId.new(@accessor.name, @accessor.signature.to_s),
|
391
|
+
"R", FunctionId.new(fun.name, fun.signature.to_s))
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
class LiteralExtraction < CodeExtraction
|
397
|
+
def_registrant_phase Cc1::Prepare2Phase
|
398
|
+
|
399
|
+
def initialize(phase_ctxt)
|
400
|
+
super
|
401
|
+
visitor = phase_ctxt[:cc1_visitor]
|
402
|
+
visitor.enter_constant_specifier += T(:extract_constant)
|
403
|
+
visitor.enter_string_literal_specifier += T(:extract_string_literal)
|
404
|
+
end
|
405
|
+
|
406
|
+
private
|
407
|
+
def do_prepare(*) end
|
408
|
+
def do_execute(*) end
|
409
|
+
|
410
|
+
def extract_constant(const_spec)
|
411
|
+
LIT(const_spec.location, type_of(const_spec),
|
412
|
+
const_spec.prefix, const_spec.suffix, const_spec.constant.value)
|
413
|
+
end
|
414
|
+
|
415
|
+
def extract_string_literal(str_lit_spec)
|
416
|
+
LIT(str_lit_spec.location, type_of(str_lit_spec),
|
417
|
+
str_lit_spec.prefix, nil, str_lit_spec.literal.value)
|
418
|
+
end
|
419
|
+
|
420
|
+
def type_of(const_or_str_lit_spec)
|
421
|
+
case const_or_str_lit_spec
|
422
|
+
when Cc1::ConstantSpecifier
|
423
|
+
case const_or_str_lit_spec.constant.value
|
424
|
+
when /\A0x[0-9a-f]+[UL]*\z/i
|
425
|
+
"HN"
|
426
|
+
when /\A0b[01]+[UL]*\z/i
|
427
|
+
"BN"
|
428
|
+
when /\A0[0-9]+[UL]*\z/i
|
429
|
+
"ON"
|
430
|
+
when /\A[0-9]+[UL]*\z/i
|
431
|
+
"DN"
|
432
|
+
when /\A(?:[0-9]*\.[0-9]*E[+-]?[0-9]+|[0-9]+\.?E[+-]?[0-9]+)[FL]*\z/i,
|
433
|
+
/\A(?:[0-9]*\.[0-9]+|[0-9]+\.)[FL]*\z/i
|
434
|
+
"FN"
|
435
|
+
when /\A'.*'\z/i
|
436
|
+
"CN"
|
437
|
+
when /\AL'.*'\z/i
|
438
|
+
"CW"
|
439
|
+
else
|
440
|
+
"NA"
|
441
|
+
end
|
442
|
+
when Cc1::StringLiteralSpecifier
|
443
|
+
case const_or_str_lit_spec.literal.value
|
444
|
+
when /\A".*"\z/i
|
445
|
+
"SN"
|
446
|
+
when /\AL".*"\z/i
|
447
|
+
"SW"
|
448
|
+
else
|
449
|
+
"NA"
|
450
|
+
end
|
451
|
+
else
|
452
|
+
raise TypeError
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|