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,7 +1,7 @@
|
|
1
1
|
# Kernel of the abstract interpreter of C language.
|
2
2
|
#
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
6
|
#
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
15
|
#
|
16
16
|
# This file is part of AdLint.
|
17
17
|
#
|
@@ -30,23 +30,24 @@
|
|
30
30
|
#++
|
31
31
|
|
32
32
|
require "adlint/monitor"
|
33
|
-
require "adlint/
|
34
|
-
require "adlint/
|
35
|
-
require "adlint/
|
36
|
-
require "adlint/
|
37
|
-
require "adlint/
|
38
|
-
require "adlint/
|
39
|
-
require "adlint/
|
40
|
-
require "adlint/
|
41
|
-
require "adlint/
|
33
|
+
require "adlint/util"
|
34
|
+
require "adlint/cc1/environ"
|
35
|
+
require "adlint/cc1/resolver"
|
36
|
+
require "adlint/cc1/mediator"
|
37
|
+
require "adlint/cc1/syntax"
|
38
|
+
require "adlint/cc1/expr"
|
39
|
+
require "adlint/cc1/conv"
|
40
|
+
require "adlint/cc1/option"
|
41
|
+
require "adlint/cc1/operator"
|
42
|
+
require "adlint/cc1/util"
|
42
43
|
|
43
44
|
module AdLint #:nodoc:
|
44
|
-
module
|
45
|
+
module Cc1 #:nodoc:
|
45
46
|
|
46
47
|
class Program
|
47
|
-
def initialize(interp,
|
48
|
+
def initialize(interp, tunit)
|
48
49
|
@interpreter = interp
|
49
|
-
@translation_unit =
|
50
|
+
@translation_unit = tunit
|
50
51
|
end
|
51
52
|
|
52
53
|
def execute
|
@@ -73,10 +74,10 @@ module C #:nodoc:
|
|
73
74
|
include InterpreterOptions
|
74
75
|
include BranchOptions
|
75
76
|
|
76
|
-
def initialize(
|
77
|
-
type_table
|
78
|
-
@environment
|
79
|
-
@type_resolver = DynamicTypeResolver.new(
|
77
|
+
def initialize(type_tbl)
|
78
|
+
@type_table = type_tbl
|
79
|
+
@environment = Environment.new(type_tbl)
|
80
|
+
@type_resolver = DynamicTypeResolver.new(type_tbl, self)
|
80
81
|
|
81
82
|
@sub_interpreters = [
|
82
83
|
DeclarationInterpreter.new(self),
|
@@ -97,6 +98,12 @@ module C #:nodoc:
|
|
97
98
|
attr_reader :environment
|
98
99
|
attr_reader :type_resolver
|
99
100
|
|
101
|
+
extend Forwardable
|
102
|
+
|
103
|
+
def_delegator :@type_table, :traits
|
104
|
+
def_delegator :@type_table, :monitor
|
105
|
+
def_delegator :@type_table, :logger
|
106
|
+
|
100
107
|
extend Pluggable
|
101
108
|
|
102
109
|
def self.def_plugin_and_notifier(event_name, *arg_names)
|
@@ -122,10 +129,10 @@ module C #:nodoc:
|
|
122
129
|
def_plugin_and_notifier :variable_initialized, :var_def, :var, :init_var
|
123
130
|
|
124
131
|
# NOTE: Notified when the interpreter evaluates a function-declaration.
|
125
|
-
def_plugin_and_notifier :
|
132
|
+
def_plugin_and_notifier :explicit_function_declared, :fun_dcl, :fun
|
126
133
|
|
127
134
|
# NOTE: Notified when the interpreter evaluates a function-definition.
|
128
|
-
def_plugin_and_notifier :
|
135
|
+
def_plugin_and_notifier :explicit_function_defined, :fun_def, :fun
|
129
136
|
|
130
137
|
# NOTE: Notified when the interpreter evaluates a struct-type-declaration.
|
131
138
|
def_plugin_and_notifier :struct_declared, :struct_type_dcl
|
@@ -141,11 +148,11 @@ module C #:nodoc:
|
|
141
148
|
|
142
149
|
# NOTE: Notified when the interpreter starts execution of a
|
143
150
|
# function-definition.
|
144
|
-
def_plugin_and_notifier :function_started, :
|
151
|
+
def_plugin_and_notifier :function_started, :fun_def, :fun
|
145
152
|
|
146
153
|
# NOTE: Notified when the interpreter ends execution of a
|
147
154
|
# function-definition.
|
148
|
-
def_plugin_and_notifier :function_ended, :
|
155
|
+
def_plugin_and_notifier :function_ended, :fun_def, :fun
|
149
156
|
|
150
157
|
# NOTE: Notified when the interpreter evaluates a parameter-definition at
|
151
158
|
# beginning of execution of a function-definition.
|
@@ -169,83 +176,85 @@ module C #:nodoc:
|
|
169
176
|
|
170
177
|
# NOTE: Notified when the interpreter refers to a function object while
|
171
178
|
# evaluating an expression.
|
172
|
-
def_plugin_and_notifier :function_referred, :expr, :
|
179
|
+
def_plugin_and_notifier :function_referred, :expr, :fun
|
180
|
+
|
181
|
+
# NOTE: Notified when the interpreter creates function-declaration of an
|
182
|
+
# implicit function.
|
183
|
+
def_plugin_and_notifier :implicit_function_declared, :obj_spec, :fun
|
173
184
|
|
174
185
|
# NOTE: Notified when the interpreter evaluates a sizeof-expression.
|
175
|
-
def_plugin_and_notifier :sizeof_expr_evaled,
|
176
|
-
:expr, :operand_var, :result_var
|
186
|
+
def_plugin_and_notifier :sizeof_expr_evaled, :expr, :ope_var, :res_var
|
177
187
|
|
178
188
|
# NOTE: Notified when the interpreter evaluates a sizeof-type-expression.
|
179
|
-
def_plugin_and_notifier :sizeof_type_expr_evaled, :expr, :type, :
|
189
|
+
def_plugin_and_notifier :sizeof_type_expr_evaled, :expr, :type, :res_var
|
180
190
|
|
181
191
|
# NOTE: Notified when the interpreter evaluates a cast-expression.
|
182
|
-
def_plugin_and_notifier :explicit_conv_performed,
|
183
|
-
:expr, :orig_var, :result_var
|
192
|
+
def_plugin_and_notifier :explicit_conv_performed, :expr, :org_var, :res_var
|
184
193
|
|
185
194
|
# NOTE: Notified when the interpreter performs an implicit type conversion
|
186
195
|
# while evaluating an expression.
|
187
196
|
def_plugin_and_notifier :implicit_conv_performed,
|
188
|
-
:init_or_expr, :
|
197
|
+
:init_or_expr, :org_var, :res_var
|
189
198
|
|
190
199
|
# NOTE: Notified when the interpreter evaluates an
|
191
200
|
# array-subscript-expression.
|
192
201
|
def_plugin_and_notifier :array_subscript_expr_evaled,
|
193
|
-
:expr, :ary_or_ptr, :subs, :ary_var, :
|
202
|
+
:expr, :ary_or_ptr, :subs, :ary_var, :res_var
|
194
203
|
|
195
204
|
# NOTE: Notified when the interpreter evaluates a function-call-expression.
|
196
205
|
def_plugin_and_notifier :function_call_expr_evaled,
|
197
|
-
:expr, :
|
206
|
+
:expr, :fun, :arg_vars, :res_var
|
198
207
|
|
199
208
|
# NOTE: Notified when the interpreter evaluates an
|
200
209
|
# unary-arithmetic-expression.
|
201
210
|
def_plugin_and_notifier :unary_arithmetic_expr_evaled,
|
202
|
-
:expr, :
|
211
|
+
:expr, :ope_var, :res_var
|
203
212
|
|
204
213
|
# NOTE: Notified when the interpreter evaluates a
|
205
214
|
# multiplicative-expression.
|
206
215
|
def_plugin_and_notifier :multiplicative_expr_evaled,
|
207
|
-
:expr, :lhs_var, :rhs_var, :
|
216
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
208
217
|
|
209
218
|
# NOTE: Notified when the interpreter evaluates an additive-expression.
|
210
219
|
def_plugin_and_notifier :additive_expr_evaled,
|
211
|
-
:expr, :lhs_var, :rhs_var, :
|
220
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
212
221
|
|
213
222
|
# NOTE: Notified when the interpreter evaluates a shift-expression.
|
214
223
|
def_plugin_and_notifier :shift_expr_evaled,
|
215
|
-
:expr, :lhs_var, :rhs_var, :
|
224
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
216
225
|
|
217
226
|
# NOTE: Notified when the interpreter evaluates a relational-expression.
|
218
227
|
def_plugin_and_notifier :relational_expr_evaled,
|
219
|
-
:expr, :lhs_var, :rhs_var, :
|
228
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
220
229
|
|
221
230
|
# NOTE: Notified when the interpreter evaluates an equality-expression.
|
222
231
|
def_plugin_and_notifier :equality_expr_evaled,
|
223
|
-
:expr, :lhs_var, :rhs_var, :
|
232
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
224
233
|
|
225
234
|
# NOTE: Notified when the interpreter evaluates a bitwise and-expression.
|
226
235
|
def_plugin_and_notifier :and_expr_evaled,
|
227
|
-
:expr, :lhs_var, :rhs_var, :
|
236
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
228
237
|
|
229
238
|
# NOTE: Notified when the interpreter evaluates an exclusive-or-expression.
|
230
239
|
def_plugin_and_notifier :exclusive_or_expr_evaled,
|
231
|
-
:expr, :lhs_var, :rhs_var, :
|
240
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
232
241
|
|
233
242
|
# NOTE: Notified when the interpreter evaluates a bitwise
|
234
243
|
# inclusive-or-expression.
|
235
244
|
def_plugin_and_notifier :inclusive_or_expr_evaled,
|
236
|
-
:expr, :lhs_var, :rhs_var, :
|
245
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
237
246
|
|
238
247
|
# NOTE: Notified when the interpreter evaluates a logical-and-expression.
|
239
248
|
def_plugin_and_notifier :logical_and_expr_evaled,
|
240
|
-
:expr, :lhs_var, :rhs_var, :
|
249
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
241
250
|
|
242
251
|
# NOTE: Notified when the interpreter evaluates a logical-or-expression.
|
243
252
|
def_plugin_and_notifier :logical_or_expr_evaled,
|
244
|
-
:expr, :lhs_var, :rhs_var, :
|
253
|
+
:expr, :lhs_var, :rhs_var, :res_var
|
245
254
|
|
246
255
|
# NOTE: Notified when the interpreter evaluates a conditional-expression.
|
247
256
|
def_plugin_and_notifier :conditional_expr_evaled,
|
248
|
-
:expr, :ctrlexpr_var, :
|
257
|
+
:expr, :ctrlexpr_var, :res_var
|
249
258
|
|
250
259
|
# NOTE: Notified when the interpreter evaluates an address-expression.
|
251
260
|
def_plugin_and_notifier :address_expr_evaled, :expr, :obj, :ptr_var
|
@@ -263,22 +272,22 @@ module C #:nodoc:
|
|
263
272
|
# NOTE: Notified when the interpreter evaluates a
|
264
273
|
# prefix-increment-expression.
|
265
274
|
def_plugin_and_notifier :prefix_increment_expr_evaled,
|
266
|
-
:expr, :
|
275
|
+
:expr, :ope_var, :org_val
|
267
276
|
|
268
277
|
# NOTE: Notified when the interpreter evaluates a
|
269
278
|
# postfix-increment-expression.
|
270
279
|
def_plugin_and_notifier :postfix_increment_expr_evaled,
|
271
|
-
:expr, :
|
280
|
+
:expr, :ope_var, :res_var
|
272
281
|
|
273
282
|
# NOTE: Notified when the interpreter evaluates a
|
274
283
|
# prefix-decrement-expression.
|
275
284
|
def_plugin_and_notifier :prefix_decrement_expr_evaled,
|
276
|
-
:expr, :
|
285
|
+
:expr, :ope_var, :org_val
|
277
286
|
|
278
287
|
# NOTE: Notified when the interpreter evaluates a
|
279
288
|
# postfix-decrement-expression.
|
280
289
|
def_plugin_and_notifier :postfix_decrement_expr_evaled,
|
281
|
-
:expr, :
|
290
|
+
:expr, :ope_var, :res_var
|
282
291
|
|
283
292
|
# NOTE: Notified when the interpreter evaluates a
|
284
293
|
# simple-assignment-expression or a compound-assignment-expression.
|
@@ -330,10 +339,10 @@ module C #:nodoc:
|
|
330
339
|
def_plugin_and_notifier :goto_stmt_evaled, :stmt, :label_name
|
331
340
|
|
332
341
|
# NOTE: Notified when the interpreter evaluates a return-statement.
|
333
|
-
def_plugin_and_notifier :return_stmt_evaled, :stmt, :
|
342
|
+
def_plugin_and_notifier :return_stmt_evaled, :stmt, :retn_var
|
334
343
|
|
335
344
|
# NOTE: Notified when the interpreter evaluates an implicit return.
|
336
|
-
def_plugin_and_notifier :implicit_return_evaled
|
345
|
+
def_plugin_and_notifier :implicit_return_evaled, :loc
|
337
346
|
|
338
347
|
# NOTE: Notified when the interpreter evaluates a controlling expression of
|
339
348
|
# the if-statement.
|
@@ -393,16 +402,16 @@ module C #:nodoc:
|
|
393
402
|
|
394
403
|
# NOTE: Notified when the interpreter starts execution of a
|
395
404
|
# translation-unit.
|
396
|
-
def_plugin_and_notifier :translation_unit_started, :
|
405
|
+
def_plugin_and_notifier :translation_unit_started, :tunit
|
397
406
|
|
398
407
|
# NOTE: Notified when the interpreter ends execution of a translation-unit.
|
399
|
-
def_plugin_and_notifier :translation_unit_ended, :
|
408
|
+
def_plugin_and_notifier :translation_unit_ended, :tunit
|
400
409
|
|
401
410
|
# NOTE: Notified when the control reaches to a sequence-point.
|
402
411
|
def_plugin_and_notifier :sequence_point_reached, :seqp
|
403
412
|
|
404
413
|
def execute(node, *opts)
|
405
|
-
@options_stack.push(
|
414
|
+
@options_stack.push(cur_opts + opts)
|
406
415
|
if quiet_without_side_effect?
|
407
416
|
result = nil
|
408
417
|
branched_eval(nil, FINAL) do
|
@@ -421,9 +430,9 @@ module C #:nodoc:
|
|
421
430
|
def object_to_variable(obj)
|
422
431
|
case
|
423
432
|
when obj.function?
|
424
|
-
|
433
|
+
create_tmpvar(pointer_type(obj.type), pointer_value_of(obj))
|
425
434
|
when obj.type.array?
|
426
|
-
|
435
|
+
create_tmpvar(pointer_type(obj.type.base_type), pointer_value_of(obj))
|
427
436
|
else
|
428
437
|
obj
|
429
438
|
end
|
@@ -438,33 +447,32 @@ module C #:nodoc:
|
|
438
447
|
end
|
439
448
|
|
440
449
|
def pointer_value_of(obj)
|
441
|
-
|
450
|
+
scalar_value_of(obj.binding.memory.address)
|
442
451
|
end
|
443
452
|
|
444
453
|
def quiet?
|
445
|
-
|
446
|
-
current_options.include?(QUIET_WITHOUT_SIDE_EFFECT)
|
454
|
+
cur_opts.include?(QUIET) || cur_opts.include?(QUIET_WITHOUT_SIDE_EFFECT)
|
447
455
|
end
|
448
456
|
|
449
457
|
def _quiet=(quiet)
|
450
458
|
# NOTE: This method is called only from ControllingExpression.
|
451
459
|
if quiet
|
452
|
-
|
460
|
+
cur_opts.add(QUIET)
|
453
461
|
else
|
454
|
-
|
462
|
+
cur_opts.delete(QUIET)
|
455
463
|
end
|
456
464
|
end
|
457
465
|
|
458
466
|
def quiet_without_side_effect?
|
459
|
-
|
467
|
+
cur_opts.include?(QUIET_WITHOUT_SIDE_EFFECT)
|
460
468
|
end
|
461
469
|
|
462
470
|
def _quiet_without_side_effect=(quiet_without_side_effect)
|
463
471
|
# NOTE: This method is called only from ExpressionEvaluator.
|
464
472
|
if quiet_without_side_effect
|
465
|
-
|
473
|
+
cur_opts.add(QUIET_WITHOUT_SIDE_EFFECT)
|
466
474
|
else
|
467
|
-
|
475
|
+
cur_opts.delete(QUIET_WITHOUT_SIDE_EFFECT)
|
468
476
|
end
|
469
477
|
end
|
470
478
|
|
@@ -476,9 +484,9 @@ module C #:nodoc:
|
|
476
484
|
@active_function_stack.last
|
477
485
|
end
|
478
486
|
|
479
|
-
def _enter_function(
|
487
|
+
def _enter_function(fun_def)
|
480
488
|
# NOTE: This method is called only from FunctionInterpreter.
|
481
|
-
@active_function_stack.push(
|
489
|
+
@active_function_stack.push(fun_def)
|
482
490
|
end
|
483
491
|
|
484
492
|
def _leave_function(*)
|
@@ -493,7 +501,7 @@ module C #:nodoc:
|
|
493
501
|
end
|
494
502
|
end
|
495
503
|
|
496
|
-
def
|
504
|
+
def cur_opts
|
497
505
|
@options_stack.last || Set.new
|
498
506
|
end
|
499
507
|
|
@@ -505,11 +513,12 @@ module C #:nodoc:
|
|
505
513
|
end
|
506
514
|
|
507
515
|
class SubInterpreter < SyntaxTreeVisitor
|
516
|
+
include InterpreterOptions
|
508
517
|
include InterpreterMediator
|
509
518
|
include NotifierMediator
|
510
519
|
include Conversion
|
511
520
|
include MonitorUtil
|
512
|
-
include
|
521
|
+
include LogUtil
|
513
522
|
|
514
523
|
def initialize(owner, target_node_class)
|
515
524
|
@owner = owner
|
@@ -520,8 +529,19 @@ module C #:nodoc:
|
|
520
529
|
|
521
530
|
private
|
522
531
|
def interpreter
|
532
|
+
# NOTE: This is private attr_reader for InterpreterMediator.
|
533
|
+
# This attribute is read via a normal method to suppress
|
534
|
+
# `private attribute?' warning.
|
523
535
|
@owner
|
524
536
|
end
|
537
|
+
|
538
|
+
extend Forwardable
|
539
|
+
|
540
|
+
def_delegator :interpreter, :monitor
|
541
|
+
private :monitor
|
542
|
+
|
543
|
+
def_delegator :interpreter, :logger
|
544
|
+
private :logger
|
525
545
|
end
|
526
546
|
|
527
547
|
class DeclarationInterpreter < SubInterpreter
|
@@ -537,8 +557,8 @@ module C #:nodoc:
|
|
537
557
|
dcl.mark_as_referred_by(node.identifier)
|
538
558
|
end
|
539
559
|
|
540
|
-
|
541
|
-
|
560
|
+
fun = declare_explicit_function(node)
|
561
|
+
notify_explicit_function_declared(node, fun)
|
542
562
|
evaluate_sequence_point(node.init_declarator.declarator)
|
543
563
|
end
|
544
564
|
|
@@ -622,8 +642,8 @@ module C #:nodoc:
|
|
622
642
|
notify_typedef_declared(node)
|
623
643
|
evaluate_sequence_point(node.init_declarator.declarator)
|
624
644
|
|
625
|
-
|
626
|
-
|
645
|
+
LOG_I("user-type `#{node.identifier.value}' " +
|
646
|
+
"defined at #{node.location.to_s}.")
|
627
647
|
end
|
628
648
|
|
629
649
|
private
|
@@ -638,7 +658,7 @@ module C #:nodoc:
|
|
638
658
|
# string-literal-specifier as the initializer.
|
639
659
|
if var_def.type.array? && var.type.pointer?
|
640
660
|
unless ary = pointee_of(var) and ary.type.array?
|
641
|
-
ary =
|
661
|
+
ary = create_tmpvar(var_def.type)
|
642
662
|
end
|
643
663
|
deduct_array_length_from_array_variable(var_def, ary)
|
644
664
|
var = conved = ary
|
@@ -656,8 +676,8 @@ module C #:nodoc:
|
|
656
676
|
end
|
657
677
|
end
|
658
678
|
|
659
|
-
def evaluate_sequence_point(
|
660
|
-
if seqp =
|
679
|
+
def evaluate_sequence_point(full_dcr)
|
680
|
+
if seqp = full_dcr.subsequent_sequence_point
|
661
681
|
notify_sequence_point_reached(seqp)
|
662
682
|
end
|
663
683
|
end
|
@@ -694,11 +714,11 @@ module C #:nodoc:
|
|
694
714
|
conved = var
|
695
715
|
else
|
696
716
|
conved = do_conversion(var, var_def.type) ||
|
697
|
-
|
717
|
+
create_tmpvar(var_def.type)
|
698
718
|
notify_implicit_conv_performed(inits, var, conved)
|
699
719
|
end
|
700
720
|
else
|
701
|
-
var = conved =
|
721
|
+
var = conved = create_tmpvar(var_def.type)
|
702
722
|
end
|
703
723
|
|
704
724
|
return var, conved
|
@@ -715,7 +735,7 @@ module C #:nodoc:
|
|
715
735
|
if var.type.same_as?(type)
|
716
736
|
conved = var
|
717
737
|
else
|
718
|
-
conved = do_conversion(var, type) ||
|
738
|
+
conved = do_conversion(var, type) || create_tmpvar(type)
|
719
739
|
notify_implicit_conv_performed(expr, var, conved)
|
720
740
|
end
|
721
741
|
|
@@ -744,9 +764,9 @@ module C #:nodoc:
|
|
744
764
|
# (recursively) according to these rules.
|
745
765
|
if fst_memb = type.members.first
|
746
766
|
fst_obj = evaluate_initializers(inits, fst_memb.type)
|
747
|
-
return
|
767
|
+
return create_tmpvar(type, value_of(fst_obj))
|
748
768
|
else
|
749
|
-
return
|
769
|
+
return create_tmpvar(type)
|
750
770
|
end
|
751
771
|
when type.array?
|
752
772
|
# NOTE: The ISO C99 standard says;
|
@@ -794,22 +814,22 @@ module C #:nodoc:
|
|
794
814
|
|
795
815
|
case
|
796
816
|
when type.array?
|
797
|
-
|
817
|
+
create_tmpvar(type, ArrayValue.new(vals))
|
798
818
|
when type.composite?
|
799
|
-
|
819
|
+
create_tmpvar(type, CompositeValue.new(vals))
|
800
820
|
else
|
801
|
-
|
821
|
+
create_tmpvar(type, vals.first)
|
802
822
|
end
|
803
823
|
end
|
804
824
|
|
805
|
-
def deduct_array_length_from_initializers(
|
806
|
-
unless
|
807
|
-
if
|
808
|
-
|
825
|
+
def deduct_array_length_from_initializers(org_ary_type, inits)
|
826
|
+
unless org_ary_type.length
|
827
|
+
if org_ary_type.user?
|
828
|
+
org_ary_type = org_ary_type.dup
|
809
829
|
end
|
810
|
-
|
830
|
+
org_ary_type.length = inits.size
|
811
831
|
end
|
812
|
-
|
832
|
+
org_ary_type
|
813
833
|
end
|
814
834
|
|
815
835
|
def interpreter
|
@@ -818,6 +838,11 @@ module C #:nodoc:
|
|
818
838
|
# `private attribute?' warning.
|
819
839
|
@interpreter
|
820
840
|
end
|
841
|
+
|
842
|
+
extend Forwardable
|
843
|
+
|
844
|
+
def_delegator :interpreter, :monitor
|
845
|
+
private :monitor
|
821
846
|
end
|
822
847
|
|
823
848
|
class ParameterDefinitionInterpreter < SubInterpreter
|
@@ -829,15 +854,17 @@ module C #:nodoc:
|
|
829
854
|
checkpoint(node.location)
|
830
855
|
|
831
856
|
resolve_unresolved_type(node)
|
857
|
+
id = node.identifier
|
858
|
+
|
832
859
|
node.type.declarations.each do |dcl|
|
833
|
-
if
|
834
|
-
dcl.mark_as_referred_by(
|
860
|
+
if id
|
861
|
+
dcl.mark_as_referred_by(id)
|
835
862
|
else
|
836
863
|
dcl.mark_as_referred_by(node.head_token)
|
837
864
|
end
|
838
865
|
end
|
839
866
|
|
840
|
-
if
|
867
|
+
if id
|
841
868
|
var = define_variable(node.to_variable_definition,
|
842
869
|
node.type.parameter_value)
|
843
870
|
notify_parameter_defined(node, var)
|
@@ -859,49 +886,50 @@ module C #:nodoc:
|
|
859
886
|
end
|
860
887
|
|
861
888
|
private
|
862
|
-
def interpret_function(
|
863
|
-
checkpoint(
|
889
|
+
def interpret_function(fun_def)
|
890
|
+
checkpoint(fun_def.location)
|
864
891
|
|
865
892
|
reset_environment
|
866
|
-
resolve_unresolved_type(
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
begin
|
871
|
-
interpreter._enter_function(node)
|
872
|
-
scoped_eval do
|
873
|
-
notify_function_started(node, func)
|
874
|
-
notify_block_started(node.function_body)
|
893
|
+
resolve_unresolved_type(fun_def)
|
894
|
+
fun = lookup_or_define_function(fun_def)
|
895
|
+
notify_explicit_function_defined(fun_def, fun)
|
875
896
|
|
876
|
-
|
897
|
+
interpret_function_body(fun_def, fun) if fun_def.analysis_target?(traits)
|
898
|
+
end
|
877
899
|
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
900
|
+
def interpret_function_body(fun_def, fun)
|
901
|
+
interpreter._enter_function(fun_def)
|
902
|
+
scoped_eval do
|
903
|
+
notify_function_started(fun_def, fun)
|
904
|
+
notify_block_started(fun_def.function_body)
|
882
905
|
|
883
|
-
|
884
|
-
|
906
|
+
fun_def.parameter_definitions.each { |param_def| interpret(param_def) }
|
907
|
+
BreakEvent.catch do
|
908
|
+
fun_def.function_body.block_items.each { |item| interpret(item) }
|
909
|
+
notify_implicit_return_evaled(fun_def.function_body.tail_location)
|
885
910
|
end
|
886
|
-
|
887
|
-
|
911
|
+
|
912
|
+
notify_block_ended(fun_def.function_body)
|
913
|
+
notify_function_ended(fun_def, fun)
|
888
914
|
end
|
915
|
+
ensure
|
916
|
+
interpreter._leave_function(fun_def)
|
889
917
|
end
|
890
918
|
|
891
|
-
def lookup_or_define_function(
|
892
|
-
|
893
|
-
dcl.mark_as_referred_by(
|
919
|
+
def lookup_or_define_function(fun_def)
|
920
|
+
fun_def.type.declarations.each do |dcl|
|
921
|
+
dcl.mark_as_referred_by(fun_def.identifier)
|
894
922
|
end
|
895
923
|
|
896
|
-
if
|
897
|
-
|
898
|
-
dcl_or_def.mark_as_referred_by(
|
924
|
+
if fun = function_named(fun_def.identifier.value) and fun.explicit?
|
925
|
+
fun.declarations_and_definitions.each do |dcl_or_def|
|
926
|
+
dcl_or_def.mark_as_referred_by(fun_def.identifier)
|
899
927
|
end
|
900
|
-
|
928
|
+
fun.declarations_and_definitions.push(fun_def)
|
929
|
+
fun
|
901
930
|
else
|
902
|
-
|
931
|
+
define_explicit_function(fun_def)
|
903
932
|
end
|
904
|
-
func
|
905
933
|
end
|
906
934
|
end
|
907
935
|
|
@@ -976,16 +1004,16 @@ module C #:nodoc:
|
|
976
1004
|
|
977
1005
|
node.executed = true
|
978
1006
|
|
979
|
-
|
980
|
-
if
|
981
|
-
ctrlexpr_val =
|
1007
|
+
org_ctrlexpr = node.expression
|
1008
|
+
if org_ctrlexpr == effective_ctrlexpr
|
1009
|
+
ctrlexpr_val = scalar_value_of_arbitrary
|
982
1010
|
ctrlexpr = nil
|
983
1011
|
else
|
984
|
-
ctrlexpr_var = object_to_variable(interpret(
|
1012
|
+
ctrlexpr_var = object_to_variable(interpret(org_ctrlexpr))
|
985
1013
|
ctrlexpr_val = value_of(ctrlexpr_var)
|
986
|
-
notify_variable_value_referred(
|
987
|
-
notify_sequence_point_reached(SequencePoint.new(
|
988
|
-
ctrlexpr =
|
1014
|
+
notify_variable_value_referred(org_ctrlexpr, ctrlexpr_var)
|
1015
|
+
notify_sequence_point_reached(SequencePoint.new(org_ctrlexpr))
|
1016
|
+
ctrlexpr = org_ctrlexpr.to_normalized_logical
|
989
1017
|
end
|
990
1018
|
notify_if_ctrlexpr_evaled(node, ctrlexpr_val)
|
991
1019
|
|
@@ -1009,16 +1037,16 @@ module C #:nodoc:
|
|
1009
1037
|
|
1010
1038
|
node.executed = true
|
1011
1039
|
|
1012
|
-
|
1013
|
-
if
|
1014
|
-
ctrlexpr_val =
|
1040
|
+
org_ctrlexpr = node.expression
|
1041
|
+
if org_ctrlexpr == effective_ctrlexpr
|
1042
|
+
ctrlexpr_val = scalar_value_of_arbitrary
|
1015
1043
|
ctrlexpr = nil
|
1016
1044
|
else
|
1017
|
-
ctrlexpr_var = object_to_variable(interpret(
|
1045
|
+
ctrlexpr_var = object_to_variable(interpret(org_ctrlexpr))
|
1018
1046
|
ctrlexpr_val = value_of(ctrlexpr_var)
|
1019
|
-
notify_variable_value_referred(
|
1020
|
-
notify_sequence_point_reached(SequencePoint.new(
|
1021
|
-
ctrlexpr =
|
1047
|
+
notify_variable_value_referred(org_ctrlexpr, ctrlexpr_var)
|
1048
|
+
notify_sequence_point_reached(SequencePoint.new(org_ctrlexpr))
|
1049
|
+
ctrlexpr = org_ctrlexpr.to_normalized_logical
|
1022
1050
|
end
|
1023
1051
|
notify_if_else_ctrlexpr_evaled(node, ctrlexpr_val)
|
1024
1052
|
|
@@ -1038,7 +1066,7 @@ module C #:nodoc:
|
|
1038
1066
|
when IfStatement, IfElseStatement
|
1039
1067
|
interpret(node.else_statement)
|
1040
1068
|
else
|
1041
|
-
branched_eval(nil, NARROWING, FINAL, COMPLETE) do
|
1069
|
+
branched_eval(nil, NARROWING, COMPLEMENTAL, FINAL, COMPLETE) do
|
1042
1070
|
interpret(node.else_statement)
|
1043
1071
|
end
|
1044
1072
|
end
|
@@ -1058,26 +1086,26 @@ module C #:nodoc:
|
|
1058
1086
|
notify_sequence_point_reached(SequencePoint.new(node.expression))
|
1059
1087
|
notify_while_ctrlexpr_evaled(node, ctrlexpr_val)
|
1060
1088
|
|
1061
|
-
|
1089
|
+
org_ctrlexpr, ctrlexpr = node.deduct_controlling_expression
|
1062
1090
|
|
1063
1091
|
case
|
1064
1092
|
when ctrlexpr_val.must_be_true?
|
1065
1093
|
begin
|
1066
|
-
enter_iteration_statement(
|
1094
|
+
enter_iteration_statement(org_ctrlexpr)
|
1067
1095
|
branched_eval(ctrlexpr, NARROWING, FINAL, IMPLICIT_COND, COMPLETE) do
|
1068
1096
|
interpret(node.statement)
|
1069
1097
|
end
|
1070
1098
|
ensure
|
1071
|
-
leave_iteration_statement(
|
1099
|
+
leave_iteration_statement(org_ctrlexpr)
|
1072
1100
|
end
|
1073
1101
|
when ctrlexpr_val.may_be_true?
|
1074
1102
|
begin
|
1075
|
-
enter_iteration_statement(
|
1103
|
+
enter_iteration_statement(org_ctrlexpr)
|
1076
1104
|
branched_eval(ctrlexpr, NARROWING, FINAL, IMPLICIT_COND) do
|
1077
1105
|
interpret(node.statement)
|
1078
1106
|
end
|
1079
1107
|
ensure
|
1080
|
-
leave_iteration_statement(
|
1108
|
+
leave_iteration_statement(org_ctrlexpr)
|
1081
1109
|
end
|
1082
1110
|
end
|
1083
1111
|
ensure
|
@@ -1092,15 +1120,15 @@ module C #:nodoc:
|
|
1092
1120
|
|
1093
1121
|
widen_varying_variable_value_domain(node)
|
1094
1122
|
|
1095
|
-
|
1123
|
+
org_ctrlexpr, ctrlexpr = node.deduct_controlling_expression
|
1096
1124
|
|
1097
1125
|
begin
|
1098
|
-
enter_iteration_statement(
|
1126
|
+
enter_iteration_statement(org_ctrlexpr)
|
1099
1127
|
branched_eval(ctrlexpr, NARROWING, FINAL, IMPLICIT_COND, COMPLETE) do
|
1100
1128
|
interpret(node.statement)
|
1101
1129
|
end
|
1102
1130
|
ensure
|
1103
|
-
leave_iteration_statement(
|
1131
|
+
leave_iteration_statement(org_ctrlexpr)
|
1104
1132
|
end
|
1105
1133
|
|
1106
1134
|
ctrlexpr_var = object_to_variable(interpret(node.expression))
|
@@ -1121,7 +1149,7 @@ module C #:nodoc:
|
|
1121
1149
|
node.initial_statement.accept(self)
|
1122
1150
|
|
1123
1151
|
widen_varying_variable_value_domain(node)
|
1124
|
-
|
1152
|
+
org_ctrlexpr, ctrlexpr = node.deduct_controlling_expression
|
1125
1153
|
|
1126
1154
|
node.condition_statement.executed = true
|
1127
1155
|
if explicit_ctrlexpr = node.condition_statement.expression
|
@@ -1131,14 +1159,14 @@ module C #:nodoc:
|
|
1131
1159
|
notify_sequence_point_reached(SequencePoint.new(explicit_ctrlexpr))
|
1132
1160
|
notify_for_ctrlexpr_evaled(node, ctrlexpr_val)
|
1133
1161
|
else
|
1134
|
-
ctrlexpr_val =
|
1162
|
+
ctrlexpr_val = scalar_value_of_true
|
1135
1163
|
end
|
1136
1164
|
|
1137
1165
|
case
|
1138
1166
|
when ctrlexpr_val.must_be_true?
|
1139
|
-
interpret_for_body_statement(node,
|
1167
|
+
interpret_for_body_statement(node, org_ctrlexpr, ctrlexpr, true)
|
1140
1168
|
when ctrlexpr_val.may_be_true?
|
1141
|
-
interpret_for_body_statement(node,
|
1169
|
+
interpret_for_body_statement(node, org_ctrlexpr, ctrlexpr, false)
|
1142
1170
|
end
|
1143
1171
|
ensure
|
1144
1172
|
notify_for_stmt_ended(node)
|
@@ -1154,7 +1182,7 @@ module C #:nodoc:
|
|
1154
1182
|
notify_c99_for_stmt_started(node)
|
1155
1183
|
|
1156
1184
|
widen_varying_variable_value_domain(node)
|
1157
|
-
|
1185
|
+
org_ctrlexpr, ctrlexpr = node.deduct_controlling_expression
|
1158
1186
|
|
1159
1187
|
node.condition_statement.executed = true
|
1160
1188
|
if explicit_ctrlexpr = node.condition_statement.expression
|
@@ -1164,14 +1192,14 @@ module C #:nodoc:
|
|
1164
1192
|
notify_sequence_point_reached(SequencePoint.new(explicit_ctrlexpr))
|
1165
1193
|
notify_c99_for_ctrlexpr_evaled(node, ctrlexpr_val)
|
1166
1194
|
else
|
1167
|
-
ctrlexpr_val =
|
1195
|
+
ctrlexpr_val = scalar_value_of_true
|
1168
1196
|
end
|
1169
1197
|
|
1170
1198
|
case
|
1171
1199
|
when ctrlexpr_val.must_be_true?
|
1172
|
-
interpret_for_body_statement(node,
|
1200
|
+
interpret_for_body_statement(node, org_ctrlexpr, ctrlexpr, true)
|
1173
1201
|
when ctrlexpr_val.may_be_true?
|
1174
|
-
interpret_for_body_statement(node,
|
1202
|
+
interpret_for_body_statement(node, org_ctrlexpr, ctrlexpr, false)
|
1175
1203
|
end
|
1176
1204
|
end
|
1177
1205
|
ensure
|
@@ -1218,13 +1246,12 @@ module C #:nodoc:
|
|
1218
1246
|
|
1219
1247
|
notify_variable_value_referred(node.expression, var)
|
1220
1248
|
|
1221
|
-
if
|
1222
|
-
|
1223
|
-
if var.type.same_as?(
|
1249
|
+
if active_fun = interpreter._active_function and
|
1250
|
+
retn_type = active_fun.type.return_type
|
1251
|
+
if var.type.same_as?(retn_type)
|
1224
1252
|
conved = var
|
1225
1253
|
else
|
1226
|
-
conved = do_conversion(var,
|
1227
|
-
create_tempvar(return_type)
|
1254
|
+
conved = do_conversion(var, retn_type) || create_tmpvar(retn_type)
|
1228
1255
|
notify_implicit_conv_performed(node.expression, var, conved)
|
1229
1256
|
end
|
1230
1257
|
else
|
@@ -1237,8 +1264,8 @@ module C #:nodoc:
|
|
1237
1264
|
end
|
1238
1265
|
|
1239
1266
|
private
|
1240
|
-
def interpret_for_body_statement(node,
|
1241
|
-
enter_iteration_statement(
|
1267
|
+
def interpret_for_body_statement(node, org_ctrlexpr, ctrlexpr, complete)
|
1268
|
+
enter_iteration_statement(org_ctrlexpr)
|
1242
1269
|
|
1243
1270
|
if complete
|
1244
1271
|
branch_opts = [NARROWING, FINAL, IMPLICIT_COND, COMPLETE]
|
@@ -1267,7 +1294,7 @@ module C #:nodoc:
|
|
1267
1294
|
end
|
1268
1295
|
end
|
1269
1296
|
ensure
|
1270
|
-
leave_iteration_statement(
|
1297
|
+
leave_iteration_statement(org_ctrlexpr)
|
1271
1298
|
end
|
1272
1299
|
|
1273
1300
|
def uninitialize_block_local_variables(generic_labeled_stmt)
|
@@ -1300,12 +1327,12 @@ module C #:nodoc:
|
|
1300
1327
|
end
|
1301
1328
|
end
|
1302
1329
|
|
1303
|
-
varying_vars.each do |var,
|
1330
|
+
varying_vars.each do |var, org_val|
|
1304
1331
|
case deduct_variable_varying_path(var, iteration_stmt)
|
1305
1332
|
when :increase
|
1306
|
-
var.narrow_value_domain!(Operator::GE,
|
1333
|
+
var.narrow_value_domain!(Operator::GE, org_val)
|
1307
1334
|
when :decrease
|
1308
|
-
var.narrow_value_domain!(Operator::LE,
|
1335
|
+
var.narrow_value_domain!(Operator::LE, org_val)
|
1309
1336
|
end
|
1310
1337
|
end
|
1311
1338
|
end
|
@@ -1407,6 +1434,7 @@ module C #:nodoc:
|
|
1407
1434
|
ctrlexpr = node.expression
|
1408
1435
|
ctrlexpr_var = object_to_variable(interpret(ctrlexpr))
|
1409
1436
|
notify_switch_ctrlexpr_evaled(node, ctrlexpr_var)
|
1437
|
+
notify_variable_value_referred(ctrlexpr, ctrlexpr_var)
|
1410
1438
|
|
1411
1439
|
execute_switch_body(ctrlexpr_var, node.statement)
|
1412
1440
|
notify_switch_stmt_ended(node)
|
@@ -1434,34 +1462,38 @@ module C #:nodoc:
|
|
1434
1462
|
base_opts = [SMOTHER_BREAK, IMPLICIT_COND, NARROWING]
|
1435
1463
|
end
|
1436
1464
|
|
1437
|
-
|
1438
|
-
while block_item = block_items[
|
1439
|
-
|
1465
|
+
idx = 0
|
1466
|
+
while block_item = block_items[idx]
|
1467
|
+
case block_item
|
1468
|
+
when GenericLabeledStatement
|
1440
1469
|
block_item.executed = true
|
1441
1470
|
notify_label_defined(block_item)
|
1442
1471
|
block_item = block_item.statement
|
1443
|
-
|
1444
|
-
|
1445
|
-
case block_item
|
1472
|
+
redo
|
1446
1473
|
when CaseLabeledStatement, DefaultLabeledStatement
|
1447
|
-
if final_branch?(block_items,
|
1474
|
+
if final_branch?(block_items, idx)
|
1448
1475
|
opts = base_opts + [FINAL]
|
1449
1476
|
else
|
1450
1477
|
opts = base_opts.dup
|
1451
1478
|
end
|
1452
|
-
|
1453
|
-
break unless
|
1479
|
+
idx = execute_branch(block_item, block_items, idx, opts)
|
1480
|
+
break unless idx
|
1454
1481
|
else
|
1455
1482
|
interpret(block_item)
|
1456
|
-
|
1483
|
+
idx += 1
|
1457
1484
|
end
|
1458
1485
|
end
|
1459
1486
|
end
|
1460
1487
|
|
1461
|
-
def execute_branch(labeled_stmt, block_items,
|
1488
|
+
def execute_branch(labeled_stmt, block_items, idx, branch_opts)
|
1462
1489
|
ctrlexpr = labeled_stmt.normalized_expression
|
1463
1490
|
ctrlexpr_val = value_of(interpret(ctrlexpr, QUIET))
|
1464
1491
|
|
1492
|
+
case labeled_stmt
|
1493
|
+
when DefaultLabeledStatement
|
1494
|
+
branch_opts.push(COMPLEMENTAL)
|
1495
|
+
end
|
1496
|
+
|
1465
1497
|
case
|
1466
1498
|
when ctrlexpr_val.must_be_true?
|
1467
1499
|
branch_opts.push(FINAL, COMPLETE)
|
@@ -1469,33 +1501,54 @@ module C #:nodoc:
|
|
1469
1501
|
# NOTE: To end the current branch group of switch-statement if this
|
1470
1502
|
# case-clause is the final one.
|
1471
1503
|
branched_eval(ctrlexpr, *branch_opts) {}
|
1472
|
-
return seek_next_branch(block_items,
|
1504
|
+
return seek_next_branch(block_items, idx)
|
1473
1505
|
end
|
1474
1506
|
|
1475
1507
|
branched_eval(ctrlexpr, *branch_opts) do |branch|
|
1508
|
+
case stmt = labeled_stmt.statement
|
1509
|
+
when CaseLabeledStatement, DefaultLabeledStatement
|
1510
|
+
# NOTE: Consecutive label appears!
|
1511
|
+
enter_next_clause(stmt, block_items, idx, branch, branch_opts)
|
1512
|
+
end
|
1476
1513
|
interpret(labeled_stmt)
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1514
|
+
idx += 1
|
1515
|
+
|
1516
|
+
while item = block_items[idx]
|
1517
|
+
case item
|
1518
|
+
when GenericLabeledStatement
|
1519
|
+
item.executed = true
|
1520
|
+
notify_label_defined(item)
|
1521
|
+
item = item.statement
|
1522
|
+
redo
|
1485
1523
|
when CaseLabeledStatement, DefaultLabeledStatement
|
1486
1524
|
# NOTE: Fall through!
|
1487
|
-
|
1488
|
-
branch_opts.push(FINAL) if final_branch?(block_items, index)
|
1489
|
-
branch.add_options(*branch_opts)
|
1525
|
+
enter_next_clause(item, block_items, idx, branch, branch_opts)
|
1490
1526
|
end
|
1491
|
-
interpret(
|
1492
|
-
|
1527
|
+
interpret(item)
|
1528
|
+
idx += 1
|
1493
1529
|
end
|
1494
1530
|
# NOTE: To simulate implicit breaking of the last case-clause.
|
1495
1531
|
BreakEvent.of_break.throw
|
1496
1532
|
end
|
1497
1533
|
|
1498
|
-
branch_opts.include?(FINAL) ? nil : seek_next_branch(block_items,
|
1534
|
+
branch_opts.include?(FINAL) ? nil : seek_next_branch(block_items, idx)
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
def enter_next_clause(labeled_stmt, block_items, idx, branch, branch_opts)
|
1538
|
+
prepare_fall_through(branch, branch_opts, labeled_stmt)
|
1539
|
+
|
1540
|
+
case labeled_stmt
|
1541
|
+
when DefaultLabeledStatement
|
1542
|
+
branch_opts.push(COMPLEMENTAL)
|
1543
|
+
end
|
1544
|
+
|
1545
|
+
branch_opts.push(FINAL) if final_branch?(block_items, idx)
|
1546
|
+
branch.add_options(*branch_opts)
|
1547
|
+
|
1548
|
+
case stmt = labeled_stmt.statement
|
1549
|
+
when CaseLabeledStatement, DefaultLabeledStatement
|
1550
|
+
enter_next_clause(stmt, block_items, idx, branch, branch_opts)
|
1551
|
+
end
|
1499
1552
|
end
|
1500
1553
|
|
1501
1554
|
def prepare_fall_through(branch, branch_opts, labeled_stmt)
|
@@ -1519,55 +1572,51 @@ module C #:nodoc:
|
|
1519
1572
|
value_domain_manip.commit!
|
1520
1573
|
end
|
1521
1574
|
|
1522
|
-
def final_branch?(block_items,
|
1523
|
-
|
1524
|
-
while block_item = block_items[
|
1525
|
-
while block_item.kind_of?(GenericLabeledStatement)
|
1526
|
-
block_item = block_item.statement
|
1527
|
-
end
|
1528
|
-
|
1575
|
+
def final_branch?(block_items, idx)
|
1576
|
+
idx += 1
|
1577
|
+
while block_item = block_items[idx]
|
1529
1578
|
case block_item
|
1579
|
+
when GenericLabeledStatement
|
1580
|
+
block_item = block_item.statement
|
1581
|
+
redo
|
1530
1582
|
when CaseLabeledStatement, DefaultLabeledStatement
|
1531
1583
|
return false
|
1532
1584
|
else
|
1533
|
-
|
1585
|
+
idx += 1
|
1534
1586
|
end
|
1535
1587
|
end
|
1536
1588
|
true
|
1537
1589
|
end
|
1538
1590
|
|
1539
1591
|
def complete?(block_items)
|
1540
|
-
|
1541
|
-
while block_item = block_items[index]
|
1542
|
-
while block_item.kind_of?(GenericLabeledStatement)
|
1543
|
-
block_item = block_item.statement
|
1544
|
-
end
|
1545
|
-
|
1592
|
+
block_items.any? do |block_item|
|
1546
1593
|
case block_item
|
1594
|
+
when GenericLabeledStatement, CaseLabeledStatement
|
1595
|
+
block_item = block_item.statement
|
1596
|
+
redo
|
1547
1597
|
when DefaultLabeledStatement
|
1548
|
-
|
1598
|
+
true
|
1549
1599
|
else
|
1550
|
-
|
1600
|
+
false
|
1551
1601
|
end
|
1552
1602
|
end
|
1553
|
-
false
|
1554
1603
|
end
|
1555
1604
|
|
1556
|
-
def seek_next_branch(block_items,
|
1557
|
-
|
1558
|
-
|
1605
|
+
def seek_next_branch(block_items, idx)
|
1606
|
+
idx += 1
|
1607
|
+
while block_item = block_items[idx]
|
1608
|
+
case block_item
|
1609
|
+
when GenericLabeledStatement
|
1559
1610
|
notify_label_defined(block_item)
|
1560
1611
|
block_item = block_item.statement
|
1561
|
-
|
1562
|
-
|
1563
|
-
case block_item
|
1612
|
+
redo
|
1564
1613
|
when CaseLabeledStatement, DefaultLabeledStatement
|
1565
|
-
|
1614
|
+
return idx
|
1566
1615
|
else
|
1567
|
-
|
1616
|
+
idx += 1
|
1568
1617
|
end
|
1569
1618
|
end
|
1570
|
-
|
1619
|
+
nil
|
1571
1620
|
end
|
1572
1621
|
end
|
1573
1622
|
|
@@ -1660,8 +1709,8 @@ module C #:nodoc:
|
|
1660
1709
|
|
1661
1710
|
case
|
1662
1711
|
when then_var && else_var
|
1663
|
-
|
1664
|
-
|
1712
|
+
res_val = then_var.value.single_value_unified_with(else_var.value)
|
1713
|
+
res_var = create_tmpvar(then_var.type, res_val)
|
1665
1714
|
# FIXME: Not to over-warn about discarding a function return value.
|
1666
1715
|
# Because the unified result is a new temporary variable, it is
|
1667
1716
|
# impossible to relate a reference of the unified result and a
|
@@ -1669,17 +1718,17 @@ module C #:nodoc:
|
|
1669
1718
|
notify_variable_value_referred(node, then_var)
|
1670
1719
|
notify_variable_value_referred(node, else_var)
|
1671
1720
|
when then_var
|
1672
|
-
|
1721
|
+
res_var = then_var
|
1673
1722
|
when else_var
|
1674
|
-
|
1723
|
+
res_var = else_var
|
1675
1724
|
else
|
1676
1725
|
# FIXME: Nevertheless, the then-expression is not reachable, the branch
|
1677
1726
|
# execution check may fail in evaluation of the else branch.
|
1678
|
-
|
1727
|
+
res_var = create_tmpvar
|
1679
1728
|
end
|
1680
1729
|
|
1681
|
-
notify_conditional_expr_evaled(node, ctrlexpr_var,
|
1682
|
-
|
1730
|
+
notify_conditional_expr_evaled(node, ctrlexpr_var, res_var)
|
1731
|
+
res_var
|
1683
1732
|
ensure
|
1684
1733
|
if seqp = node.subsequent_sequence_point
|
1685
1734
|
notify_sequence_point_reached(seqp)
|