adlint 2.6.14 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
|
@@ -1,983 +0,0 @@
|
|
|
1
|
-
# Code checkings (cc1-phase) of adlint-exam-c_builtin package.
|
|
2
|
-
#
|
|
3
|
-
# Author:: Rie Shima <mailto:rkakuuchi@users.sourceforge.net>
|
|
4
|
-
# Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
|
5
|
-
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
|
-
#
|
|
7
|
-
# Owner:: Rie Shima <mailto:rkakuuchi@users.sourceforge.net>
|
|
8
|
-
|
|
9
|
-
#--
|
|
10
|
-
# ___ ____ __ ___ _________
|
|
11
|
-
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
|
-
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
|
-
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
|
15
|
-
#
|
|
16
|
-
# This file is part of AdLint.
|
|
17
|
-
#
|
|
18
|
-
# AdLint is free software: you can redistribute it and/or modify it under the
|
|
19
|
-
# terms of the GNU General Public License as published by the Free Software
|
|
20
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
|
21
|
-
# version.
|
|
22
|
-
#
|
|
23
|
-
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
24
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
25
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
26
|
-
#
|
|
27
|
-
# You should have received a copy of the GNU General Public License along with
|
|
28
|
-
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
-
#
|
|
30
|
-
#++
|
|
31
|
-
|
|
32
|
-
require "adlint/exam"
|
|
33
|
-
require "adlint/report"
|
|
34
|
-
require "adlint/c/phase"
|
|
35
|
-
require "adlint/c/syntax"
|
|
36
|
-
require "adlint/c/format"
|
|
37
|
-
|
|
38
|
-
module AdLint #:nodoc:
|
|
39
|
-
module Exam #:nodoc:
|
|
40
|
-
module CBuiltin #:nodoc:
|
|
41
|
-
|
|
42
|
-
class W0573 < PassiveCodeCheck
|
|
43
|
-
def_registrant_phase C::Prepare2Phase
|
|
44
|
-
|
|
45
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
46
|
-
# step-in analysis is supported.
|
|
47
|
-
ensure_uniqueness_of :W0573
|
|
48
|
-
|
|
49
|
-
def initialize(context)
|
|
50
|
-
super
|
|
51
|
-
interp = context[:c_interpreter]
|
|
52
|
-
interp.on_function_call_expr_evaled += method(:check)
|
|
53
|
-
@environ = interp.environment
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
private
|
|
57
|
-
def check(function_call_expression, function, arg_variables,
|
|
58
|
-
result_variable)
|
|
59
|
-
if function.named? && function.name =~ /\A.*scanf\z/
|
|
60
|
-
format = create_format(function_call_expression,
|
|
61
|
-
format_str_index_of(function_call_expression),
|
|
62
|
-
arg_variables, @environ)
|
|
63
|
-
return unless format
|
|
64
|
-
|
|
65
|
-
format.conversion_specifiers.each_with_index do |cs, index|
|
|
66
|
-
if cs.scanset && cs.scanset.include?("-")
|
|
67
|
-
W(:W0573, format.location)
|
|
68
|
-
break
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def format_str_index_of(function_call_expression)
|
|
75
|
-
function_call_expression.argument_expressions.index do |arg_expr|
|
|
76
|
-
arg_expr.kind_of?(C::StringLiteralSpecifier)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def create_format(function_call_expression,
|
|
81
|
-
format_str_index, arg_variables, environment)
|
|
82
|
-
if format_str_index
|
|
83
|
-
format_str =
|
|
84
|
-
function_call_expression.argument_expressions[format_str_index]
|
|
85
|
-
if format_str && format_str.literal.value =~ /\AL?"(.*)"\z/i
|
|
86
|
-
location = format_str.location
|
|
87
|
-
trailing_args = arg_variables[(format_str_index + 1)..-1] || []
|
|
88
|
-
return C::ScanfFormat.new($1, location, trailing_args, environment)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
nil
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
class W0606 < PassiveCodeCheck
|
|
96
|
-
def_registrant_phase C::Prepare2Phase
|
|
97
|
-
|
|
98
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
99
|
-
# step-in analysis is supported.
|
|
100
|
-
ensure_uniqueness_of :W0606
|
|
101
|
-
|
|
102
|
-
def initialize(context)
|
|
103
|
-
super
|
|
104
|
-
visitor = context[:c_visitor]
|
|
105
|
-
visitor.enter_union_type_declaration += method(:check)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
private
|
|
109
|
-
def check(node)
|
|
110
|
-
node.struct_declarations.each do |struct_declaration|
|
|
111
|
-
struct_declaration.items.each do |member_decl|
|
|
112
|
-
if member_decl.type.scalar? && member_decl.type.floating?
|
|
113
|
-
W(:W0606, node.location)
|
|
114
|
-
return
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
class W0645 < PassiveCodeCheck
|
|
122
|
-
def_registrant_phase C::Prepare2Phase
|
|
123
|
-
|
|
124
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
125
|
-
# step-in analysis is supported.
|
|
126
|
-
ensure_uniqueness_of :W0645
|
|
127
|
-
|
|
128
|
-
def initialize(context)
|
|
129
|
-
super
|
|
130
|
-
visitor = context[:c_visitor]
|
|
131
|
-
visitor.enter_kandr_function_definition += method(:check)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def check(node)
|
|
135
|
-
if node.type.parameter_types.any? { |type| type.void? }
|
|
136
|
-
W(:W0645, node.location)
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
class W0685 < W0573
|
|
142
|
-
def_registrant_phase C::Prepare2Phase
|
|
143
|
-
|
|
144
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
145
|
-
# step-in analysis is supported.
|
|
146
|
-
ensure_uniqueness_of :W0685
|
|
147
|
-
|
|
148
|
-
def check(function_call_expression, function, arg_variables,
|
|
149
|
-
result_variable)
|
|
150
|
-
if function.named? && function.name =~ /\A.*scanf\z/
|
|
151
|
-
format = create_format(function_call_expression,
|
|
152
|
-
format_str_index_of(function_call_expression),
|
|
153
|
-
arg_variables, @environ)
|
|
154
|
-
return unless format
|
|
155
|
-
|
|
156
|
-
format.conversion_specifiers.each do |cs|
|
|
157
|
-
next unless cs.scanset
|
|
158
|
-
|
|
159
|
-
cs.scanset.scan(/(.)-(.)/).each do |lhs, rhs|
|
|
160
|
-
W(:W0685, format.location) if lhs.ord > rhs.ord
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
class W0686 < W0573
|
|
168
|
-
def_registrant_phase C::Prepare2Phase
|
|
169
|
-
|
|
170
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
171
|
-
# step-in analysis is supported.
|
|
172
|
-
ensure_uniqueness_of :W0686
|
|
173
|
-
|
|
174
|
-
def check(function_call_expression, function, arg_variables,
|
|
175
|
-
result_variable)
|
|
176
|
-
if function.named? && function.name =~ /\A.*scanf\z/
|
|
177
|
-
format = create_format(function_call_expression,
|
|
178
|
-
format_str_index_of(function_call_expression),
|
|
179
|
-
arg_variables, @environ)
|
|
180
|
-
return unless format
|
|
181
|
-
|
|
182
|
-
format.conversion_specifiers.each do |cs|
|
|
183
|
-
next unless cs.scanset
|
|
184
|
-
|
|
185
|
-
unless cs.valid_scanset?
|
|
186
|
-
W(:W0686, format.location)
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
class W0697 < PassiveCodeCheck
|
|
194
|
-
def_registrant_phase C::Prepare2Phase
|
|
195
|
-
|
|
196
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
197
|
-
# step-in analysis is supported.
|
|
198
|
-
ensure_uniqueness_of :W0697
|
|
199
|
-
|
|
200
|
-
def initialize(context)
|
|
201
|
-
super
|
|
202
|
-
interp = context[:c_interpreter]
|
|
203
|
-
interp.on_function_started += method(:start_function)
|
|
204
|
-
interp.on_function_ended += method(:end_function)
|
|
205
|
-
interp.on_implicit_return_evaled += method(:check_implicit_return)
|
|
206
|
-
@current_function = nil
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
private
|
|
210
|
-
def start_function(function_definition, function)
|
|
211
|
-
@current_function = function_definition
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def end_function(function_definition, function)
|
|
215
|
-
@current_function = nil
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
def check_implicit_return
|
|
219
|
-
return unless @current_function
|
|
220
|
-
|
|
221
|
-
unless @current_function.type.return_type.void?
|
|
222
|
-
W(:W0697,
|
|
223
|
-
@current_function.location, @current_function.identifier.value)
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
class W0698 < PassiveCodeCheck
|
|
229
|
-
def_registrant_phase C::Prepare2Phase
|
|
230
|
-
|
|
231
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
232
|
-
# step-in analysis is supported.
|
|
233
|
-
ensure_uniqueness_of :W0698
|
|
234
|
-
|
|
235
|
-
def initialize(context)
|
|
236
|
-
super
|
|
237
|
-
visitor = context[:c_visitor]
|
|
238
|
-
visitor.enter_ansi_function_definition += method(:start_function)
|
|
239
|
-
visitor.enter_kandr_function_definition += method(:start_function)
|
|
240
|
-
visitor.leave_ansi_function_definition += method(:end_function)
|
|
241
|
-
visitor.leave_kandr_function_definition += method(:end_function)
|
|
242
|
-
visitor.enter_return_statement += method(:check)
|
|
243
|
-
@current_function = nil
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
private
|
|
247
|
-
def start_function(function_definition)
|
|
248
|
-
@current_function = function_definition
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
def end_function(function_definition)
|
|
252
|
-
@current_function = nil
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
def check(return_statement)
|
|
256
|
-
return unless @current_function.explicitly_typed?
|
|
257
|
-
|
|
258
|
-
if return_type = @current_function.type.return_type
|
|
259
|
-
if !return_type.void? && return_statement.expression.nil?
|
|
260
|
-
W(:W0698, return_statement.location,
|
|
261
|
-
@current_function.identifier.value)
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
class W0699 < W0698
|
|
268
|
-
def_registrant_phase C::Prepare2Phase
|
|
269
|
-
|
|
270
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
271
|
-
# step-in analysis is supported.
|
|
272
|
-
ensure_uniqueness_of :W0699
|
|
273
|
-
|
|
274
|
-
private
|
|
275
|
-
def check(return_statement)
|
|
276
|
-
return unless @current_function.implicitly_typed?
|
|
277
|
-
|
|
278
|
-
if return_statement.expression.nil?
|
|
279
|
-
W(:W0699, return_statement.location,
|
|
280
|
-
@current_function.identifier.value)
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
class W0700 < PassiveCodeCheck
|
|
286
|
-
def_registrant_phase C::Prepare2Phase
|
|
287
|
-
|
|
288
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
289
|
-
# step-in analysis is supported.
|
|
290
|
-
ensure_uniqueness_of :W0700
|
|
291
|
-
|
|
292
|
-
def initialize(context)
|
|
293
|
-
super
|
|
294
|
-
interp = context[:c_interpreter]
|
|
295
|
-
interp.on_function_started += method(:start_function)
|
|
296
|
-
interp.on_function_ended += method(:end_function)
|
|
297
|
-
interp.on_return_stmt_evaled += method(:check_explicit_return)
|
|
298
|
-
interp.on_implicit_return_evaled += method(:check_implicit_return)
|
|
299
|
-
@current_function = nil
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
private
|
|
303
|
-
def start_function(function_definition, function)
|
|
304
|
-
@current_function = function_definition
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
def end_function(function_definition, function)
|
|
308
|
-
@current_function = nil
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
def check_explicit_return(return_stmt, result_variable)
|
|
312
|
-
return unless @current_function
|
|
313
|
-
|
|
314
|
-
if @current_function.implicitly_typed? && return_stmt.expression.nil?
|
|
315
|
-
W(:W0700,
|
|
316
|
-
@current_function.location, @current_function.identifier.value)
|
|
317
|
-
end
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
def check_implicit_return
|
|
321
|
-
return unless @current_function
|
|
322
|
-
|
|
323
|
-
if @current_function.implicitly_typed?
|
|
324
|
-
W(:W0700,
|
|
325
|
-
@current_function.location, @current_function.identifier.value)
|
|
326
|
-
end
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
class W0711 < PassiveCodeCheck
|
|
331
|
-
def_registrant_phase C::Prepare2Phase
|
|
332
|
-
|
|
333
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
334
|
-
# step-in analysis is supported.
|
|
335
|
-
ensure_uniqueness_of :W0711
|
|
336
|
-
|
|
337
|
-
def initialize(context)
|
|
338
|
-
super
|
|
339
|
-
visitor = context[:c_visitor]
|
|
340
|
-
visitor.enter_relational_expression += method(:check)
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
private
|
|
344
|
-
def check(expression)
|
|
345
|
-
if !expression.lhs_operand.logical? && expression.rhs_operand.logical?
|
|
346
|
-
W(:W0711, expression.rhs_operand.location)
|
|
347
|
-
end
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
class W0712 < W0711
|
|
352
|
-
def_registrant_phase C::Prepare2Phase
|
|
353
|
-
|
|
354
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
355
|
-
# step-in analysis is supported.
|
|
356
|
-
ensure_uniqueness_of :W0712
|
|
357
|
-
|
|
358
|
-
private
|
|
359
|
-
def check(expression)
|
|
360
|
-
if expression.lhs_operand.logical? && !expression.rhs_operand.logical?
|
|
361
|
-
W(:W0712, expression.lhs_operand.location)
|
|
362
|
-
end
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
class W0713 < W0711
|
|
367
|
-
def_registrant_phase C::Prepare2Phase
|
|
368
|
-
|
|
369
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
370
|
-
# step-in analysis is supported.
|
|
371
|
-
ensure_uniqueness_of :W0713
|
|
372
|
-
|
|
373
|
-
private
|
|
374
|
-
def check(expression)
|
|
375
|
-
if expression.lhs_operand.logical? && expression.rhs_operand.logical?
|
|
376
|
-
W(:W0713, expression.location)
|
|
377
|
-
end
|
|
378
|
-
end
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
class W0714 < PassiveCodeCheck
|
|
382
|
-
def_registrant_phase C::Prepare2Phase
|
|
383
|
-
|
|
384
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
385
|
-
# step-in analysis is supported.
|
|
386
|
-
ensure_uniqueness_of :W0714
|
|
387
|
-
|
|
388
|
-
def initialize(context)
|
|
389
|
-
super
|
|
390
|
-
visitor = context[:c_visitor]
|
|
391
|
-
visitor.enter_and_expression += method(:check)
|
|
392
|
-
end
|
|
393
|
-
|
|
394
|
-
private
|
|
395
|
-
def check(expression)
|
|
396
|
-
if expression.lhs_operand.logical? && expression.rhs_operand.logical?
|
|
397
|
-
W(:W0714, expression.location)
|
|
398
|
-
end
|
|
399
|
-
end
|
|
400
|
-
end
|
|
401
|
-
|
|
402
|
-
class W0715 < PassiveCodeCheck
|
|
403
|
-
def_registrant_phase C::Prepare2Phase
|
|
404
|
-
|
|
405
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
406
|
-
# step-in analysis is supported.
|
|
407
|
-
ensure_uniqueness_of :W0715
|
|
408
|
-
|
|
409
|
-
def initialize(context)
|
|
410
|
-
super
|
|
411
|
-
visitor = context[:c_visitor]
|
|
412
|
-
visitor.enter_inclusive_or_expression += method(:check)
|
|
413
|
-
end
|
|
414
|
-
|
|
415
|
-
private
|
|
416
|
-
def check(expression)
|
|
417
|
-
if expression.lhs_operand.logical? && expression.rhs_operand.logical?
|
|
418
|
-
W(:W0715, expression.location)
|
|
419
|
-
end
|
|
420
|
-
end
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
class W0716 < PassiveCodeCheck
|
|
424
|
-
def_registrant_phase C::Prepare2Phase
|
|
425
|
-
|
|
426
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
427
|
-
# step-in analysis is supported.
|
|
428
|
-
ensure_uniqueness_of :W0716
|
|
429
|
-
|
|
430
|
-
def initialize(context)
|
|
431
|
-
super
|
|
432
|
-
visitor = context[:c_visitor]
|
|
433
|
-
visitor.enter_additive_expression += method(:check)
|
|
434
|
-
visitor.enter_multiplicative_expression += method(:check)
|
|
435
|
-
visitor.enter_shift_expression += method(:check)
|
|
436
|
-
visitor.enter_and_expression += method(:check)
|
|
437
|
-
visitor.enter_exclusive_or_expression += method(:check)
|
|
438
|
-
visitor.enter_inclusive_or_expression += method(:check)
|
|
439
|
-
visitor.enter_compound_assignment_expression += lambda { |expr|
|
|
440
|
-
case expr.operator.type
|
|
441
|
-
when "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", "&=", "^=", "|="
|
|
442
|
-
check(expr)
|
|
443
|
-
end
|
|
444
|
-
}
|
|
445
|
-
end
|
|
446
|
-
|
|
447
|
-
private
|
|
448
|
-
def check(expression)
|
|
449
|
-
if expression.lhs_operand.logical? && expression.rhs_operand.logical?
|
|
450
|
-
W(:W0716, expression.location)
|
|
451
|
-
end
|
|
452
|
-
end
|
|
453
|
-
end
|
|
454
|
-
|
|
455
|
-
class W0717 < W0716
|
|
456
|
-
def_registrant_phase C::Prepare2Phase
|
|
457
|
-
|
|
458
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
459
|
-
# step-in analysis is supported.
|
|
460
|
-
ensure_uniqueness_of :W0717
|
|
461
|
-
|
|
462
|
-
private
|
|
463
|
-
def check(expression)
|
|
464
|
-
if expression.lhs_operand.logical? && !expression.rhs_operand.logical?
|
|
465
|
-
W(:W0717, expression.lhs_operand.location)
|
|
466
|
-
end
|
|
467
|
-
end
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
class W0718 < W0716
|
|
471
|
-
def_registrant_phase C::Prepare2Phase
|
|
472
|
-
|
|
473
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
474
|
-
# step-in analysis is supported.
|
|
475
|
-
ensure_uniqueness_of :W0718
|
|
476
|
-
|
|
477
|
-
private
|
|
478
|
-
def check(expression)
|
|
479
|
-
if !expression.lhs_operand.logical? && expression.rhs_operand.logical?
|
|
480
|
-
W(:W0718, expression.rhs_operand.location)
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
end
|
|
484
|
-
|
|
485
|
-
class W0726 < W0698
|
|
486
|
-
def_registrant_phase C::Prepare2Phase
|
|
487
|
-
|
|
488
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
489
|
-
# step-in analysis is supported.
|
|
490
|
-
ensure_uniqueness_of :W0726
|
|
491
|
-
|
|
492
|
-
private
|
|
493
|
-
def check(return_statement)
|
|
494
|
-
return unless return_statement.expression
|
|
495
|
-
|
|
496
|
-
if return_type = @current_function.type.return_type
|
|
497
|
-
if return_type.void? && (return_type.const? || return_type.volatile?)
|
|
498
|
-
W(:W0726, return_statement.location,
|
|
499
|
-
@current_function.identifier.value)
|
|
500
|
-
end
|
|
501
|
-
end
|
|
502
|
-
end
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
class W0732 < PassiveCodeCheck
|
|
506
|
-
def_registrant_phase C::Prepare2Phase
|
|
507
|
-
|
|
508
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
509
|
-
# step-in analysis is supported.
|
|
510
|
-
ensure_uniqueness_of :W0732
|
|
511
|
-
|
|
512
|
-
def initialize(context)
|
|
513
|
-
super
|
|
514
|
-
visitor = context[:c_visitor]
|
|
515
|
-
visitor.enter_logical_and_expression += method(:check)
|
|
516
|
-
end
|
|
517
|
-
|
|
518
|
-
private
|
|
519
|
-
def check(expr)
|
|
520
|
-
if expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
|
521
|
-
if expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
|
522
|
-
W(:W0732, expr.location)
|
|
523
|
-
end
|
|
524
|
-
end
|
|
525
|
-
end
|
|
526
|
-
end
|
|
527
|
-
|
|
528
|
-
class W0733 < PassiveCodeCheck
|
|
529
|
-
def_registrant_phase C::Prepare2Phase
|
|
530
|
-
|
|
531
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
532
|
-
# step-in analysis is supported.
|
|
533
|
-
ensure_uniqueness_of :W0733
|
|
534
|
-
|
|
535
|
-
def initialize(context)
|
|
536
|
-
super
|
|
537
|
-
visitor = context[:c_visitor]
|
|
538
|
-
visitor.enter_logical_or_expression += method(:check)
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
private
|
|
542
|
-
def check(expr)
|
|
543
|
-
if expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
|
544
|
-
if expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
|
545
|
-
W(:W0733, expr.location)
|
|
546
|
-
end
|
|
547
|
-
end
|
|
548
|
-
end
|
|
549
|
-
end
|
|
550
|
-
|
|
551
|
-
class W0734 < PassiveCodeCheck
|
|
552
|
-
def_registrant_phase C::Prepare2Phase
|
|
553
|
-
|
|
554
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
555
|
-
# step-in analysis is supported.
|
|
556
|
-
ensure_uniqueness_of :W0734
|
|
557
|
-
|
|
558
|
-
def initialize(context)
|
|
559
|
-
super
|
|
560
|
-
visitor = context[:c_visitor]
|
|
561
|
-
visitor.enter_logical_and_expression += method(:check)
|
|
562
|
-
visitor.enter_logical_or_expression += method(:check)
|
|
563
|
-
end
|
|
564
|
-
|
|
565
|
-
private
|
|
566
|
-
def check(expr)
|
|
567
|
-
if expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
|
568
|
-
unless expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
|
569
|
-
W(:W0734, expr.lhs_operand.location)
|
|
570
|
-
end
|
|
571
|
-
end
|
|
572
|
-
end
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
class W0735 < W0734
|
|
576
|
-
def_registrant_phase C::Prepare2Phase
|
|
577
|
-
|
|
578
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
579
|
-
# step-in analysis is supported.
|
|
580
|
-
ensure_uniqueness_of :W0735
|
|
581
|
-
|
|
582
|
-
private
|
|
583
|
-
def check(expr)
|
|
584
|
-
if expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
|
585
|
-
unless expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
|
586
|
-
W(:W0735, expr.rhs_operand.location)
|
|
587
|
-
end
|
|
588
|
-
end
|
|
589
|
-
end
|
|
590
|
-
end
|
|
591
|
-
|
|
592
|
-
class W0781 < PassiveCodeCheck
|
|
593
|
-
def_registrant_phase C::Prepare2Phase
|
|
594
|
-
|
|
595
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
596
|
-
# step-in analysis is supported.
|
|
597
|
-
ensure_uniqueness_of :W0781
|
|
598
|
-
|
|
599
|
-
def initialize(context)
|
|
600
|
-
super
|
|
601
|
-
visitor = context[:c_visitor]
|
|
602
|
-
visitor.enter_switch_statement += method(:enter_switch_statement)
|
|
603
|
-
visitor.leave_switch_statement += method(:check)
|
|
604
|
-
visitor.enter_case_labeled_statement += method(:add_exec_path)
|
|
605
|
-
visitor.enter_default_labeled_statement += method(:add_exec_path)
|
|
606
|
-
@exec_path_nums = []
|
|
607
|
-
end
|
|
608
|
-
|
|
609
|
-
private
|
|
610
|
-
def enter_switch_statement(node)
|
|
611
|
-
@exec_path_nums.push(0)
|
|
612
|
-
end
|
|
613
|
-
|
|
614
|
-
def check(node)
|
|
615
|
-
if exec_path_num = @exec_path_nums.last and exec_path_num < 2
|
|
616
|
-
W(:W0781, node.location)
|
|
617
|
-
end
|
|
618
|
-
@exec_path_nums.pop
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
def add_exec_path(node)
|
|
622
|
-
@exec_path_nums[-1] += 1 if node.executed?
|
|
623
|
-
end
|
|
624
|
-
end
|
|
625
|
-
|
|
626
|
-
class W0801 < PassiveCodeCheck
|
|
627
|
-
def_registrant_phase C::Prepare2Phase
|
|
628
|
-
|
|
629
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
630
|
-
# step-in analysis is supported.
|
|
631
|
-
ensure_uniqueness_of :W0801
|
|
632
|
-
|
|
633
|
-
def initialize(context)
|
|
634
|
-
super
|
|
635
|
-
visitor = context[:c_visitor]
|
|
636
|
-
visitor.enter_struct_type_declaration += method(:check)
|
|
637
|
-
visitor.enter_union_type_declaration += method(:check)
|
|
638
|
-
end
|
|
639
|
-
|
|
640
|
-
private
|
|
641
|
-
def check(node)
|
|
642
|
-
W(:W0801, node.location) if node.type.members.empty?
|
|
643
|
-
end
|
|
644
|
-
end
|
|
645
|
-
|
|
646
|
-
class W0809 < PassiveCodeCheck
|
|
647
|
-
def_registrant_phase C::Prepare2Phase
|
|
648
|
-
|
|
649
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
650
|
-
# step-in analysis is supported.
|
|
651
|
-
ensure_uniqueness_of :W0809
|
|
652
|
-
|
|
653
|
-
def initialize(context)
|
|
654
|
-
super
|
|
655
|
-
visitor = context[:c_visitor]
|
|
656
|
-
visitor.enter_function_declaration += method(:check_function_name)
|
|
657
|
-
visitor.enter_variable_declaration += method(:check_variable_name)
|
|
658
|
-
visitor.enter_variable_definition += method(:check_variable_name)
|
|
659
|
-
visitor.enter_parameter_definition += method(:check_variable_name)
|
|
660
|
-
visitor.enter_typedef_declaration += method(:check_typedef_name)
|
|
661
|
-
visitor.enter_struct_type_declaration += method(:check_tag_name)
|
|
662
|
-
visitor.enter_union_type_declaration += method(:check_tag_name)
|
|
663
|
-
visitor.enter_enum_type_declaration += method(:check_tag_name)
|
|
664
|
-
visitor.enter_enumerator += method(:check_enumerator_name)
|
|
665
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
|
666
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
|
667
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
|
668
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
|
669
|
-
@function_def_level = 0
|
|
670
|
-
end
|
|
671
|
-
|
|
672
|
-
private
|
|
673
|
-
def check_function_name(function_decl)
|
|
674
|
-
check_object_name(function_decl)
|
|
675
|
-
end
|
|
676
|
-
|
|
677
|
-
def check_variable_name(variable_decl_or_def)
|
|
678
|
-
check_object_name(variable_decl_or_def)
|
|
679
|
-
end
|
|
680
|
-
|
|
681
|
-
def check_typedef_name(typedef_decl)
|
|
682
|
-
if typedef_decl.identifier
|
|
683
|
-
case name = typedef_decl.identifier.value
|
|
684
|
-
when /\A__/, /\A_[A-Z]/, /\A_/
|
|
685
|
-
W(:W0809, typedef_decl.location, name)
|
|
686
|
-
end
|
|
687
|
-
end
|
|
688
|
-
end
|
|
689
|
-
|
|
690
|
-
def check_tag_name(type_decl)
|
|
691
|
-
if type_decl.identifier
|
|
692
|
-
case name = type_decl.identifier.value
|
|
693
|
-
when /\A__adlint/
|
|
694
|
-
# NOTE: To ignore AdLint internal tag names.
|
|
695
|
-
when /\A__/, /\A_[A-Z]/, /\A_/
|
|
696
|
-
W(:W0809, type_decl.location, name)
|
|
697
|
-
end
|
|
698
|
-
end
|
|
699
|
-
end
|
|
700
|
-
|
|
701
|
-
def check_enumerator_name(enumerator)
|
|
702
|
-
if enumerator.identifier
|
|
703
|
-
case name = enumerator.identifier.value
|
|
704
|
-
when /\A__/, /\A_[A-Z]/, /\A_/
|
|
705
|
-
W(:W0809, enumerator.location, name)
|
|
706
|
-
end
|
|
707
|
-
end
|
|
708
|
-
end
|
|
709
|
-
|
|
710
|
-
def enter_function(node)
|
|
711
|
-
check_object_name(node)
|
|
712
|
-
@function_def_level += 1
|
|
713
|
-
end
|
|
714
|
-
|
|
715
|
-
def leave_function(node)
|
|
716
|
-
@function_def_level -= 1
|
|
717
|
-
end
|
|
718
|
-
|
|
719
|
-
def check_object_name(decl_or_def)
|
|
720
|
-
if decl_or_def.identifier
|
|
721
|
-
case name = decl_or_def.identifier.value
|
|
722
|
-
when /\A__/, /\A_[A-Z]/
|
|
723
|
-
W(:W0809, decl_or_def.location, name)
|
|
724
|
-
when /\A_/
|
|
725
|
-
check_filelocal_object_name(name, decl_or_def)
|
|
726
|
-
end
|
|
727
|
-
end
|
|
728
|
-
end
|
|
729
|
-
|
|
730
|
-
def check_filelocal_object_name(name, decl_or_def)
|
|
731
|
-
if @function_def_level == 0
|
|
732
|
-
if scs = decl_or_def.storage_class_specifier and scs.type == :STATIC
|
|
733
|
-
W(:W0809, decl_or_def.location, name)
|
|
734
|
-
end
|
|
735
|
-
end
|
|
736
|
-
end
|
|
737
|
-
end
|
|
738
|
-
|
|
739
|
-
class W1030 < PassiveCodeCheck
|
|
740
|
-
def_registrant_phase C::Prepare2Phase
|
|
741
|
-
|
|
742
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
743
|
-
# step-in analysis is supported.
|
|
744
|
-
ensure_uniqueness_of :W1030
|
|
745
|
-
|
|
746
|
-
def initialize(context)
|
|
747
|
-
super
|
|
748
|
-
visitor = context[:c_visitor]
|
|
749
|
-
visitor.enter_generic_labeled_statement += method(:check)
|
|
750
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
|
751
|
-
visitor.leave_ansi_function_definition += method(:leave_function)
|
|
752
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
|
753
|
-
visitor.leave_kandr_function_definition += method(:leave_function)
|
|
754
|
-
@labels = nil
|
|
755
|
-
end
|
|
756
|
-
|
|
757
|
-
private
|
|
758
|
-
def check(generic_labeled_statement)
|
|
759
|
-
return unless @labels
|
|
760
|
-
|
|
761
|
-
label = generic_labeled_statement.label
|
|
762
|
-
if @labels.include?(label.value)
|
|
763
|
-
W(:W1030, label.location, label.value)
|
|
764
|
-
else
|
|
765
|
-
@labels.add(label.value)
|
|
766
|
-
end
|
|
767
|
-
end
|
|
768
|
-
|
|
769
|
-
def enter_function(node)
|
|
770
|
-
@labels = Set.new
|
|
771
|
-
end
|
|
772
|
-
|
|
773
|
-
def leave_function(node)
|
|
774
|
-
@labels = nil
|
|
775
|
-
end
|
|
776
|
-
end
|
|
777
|
-
|
|
778
|
-
class W1033 < PassiveCodeCheck
|
|
779
|
-
def_registrant_phase C::Prepare2Phase
|
|
780
|
-
|
|
781
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
782
|
-
# step-in analysis is supported.
|
|
783
|
-
ensure_uniqueness_of :W1033
|
|
784
|
-
|
|
785
|
-
def initialize(context)
|
|
786
|
-
super
|
|
787
|
-
visitor = context[:c_visitor]
|
|
788
|
-
visitor.enter_ansi_function_definition += method(:check)
|
|
789
|
-
visitor.enter_kandr_function_definition += method(:check)
|
|
790
|
-
visitor.enter_function_declaration += method(:check)
|
|
791
|
-
end
|
|
792
|
-
|
|
793
|
-
private
|
|
794
|
-
def check(definition_or_declaration)
|
|
795
|
-
if return_type = definition_or_declaration.type.return_type
|
|
796
|
-
if return_type.const? || return_type.volatile?
|
|
797
|
-
W(:W1033, definition_or_declaration.location)
|
|
798
|
-
end
|
|
799
|
-
end
|
|
800
|
-
end
|
|
801
|
-
end
|
|
802
|
-
|
|
803
|
-
class W1066 < PassiveCodeCheck
|
|
804
|
-
def_registrant_phase C::Prepare2Phase
|
|
805
|
-
|
|
806
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
807
|
-
# step-in analysis is supported.
|
|
808
|
-
ensure_uniqueness_of :W1066
|
|
809
|
-
|
|
810
|
-
def initialize(context)
|
|
811
|
-
super
|
|
812
|
-
@interp = context[:c_interpreter]
|
|
813
|
-
@interp.on_explicit_conv_performed += method(:check)
|
|
814
|
-
@interp.on_function_started += method(:clear_rvalues)
|
|
815
|
-
@interp.on_additive_expr_evaled += method(:handle_additive)
|
|
816
|
-
@interp.on_multiplicative_expr_evaled += method(:handle_multiplicative)
|
|
817
|
-
@rvalues = nil
|
|
818
|
-
end
|
|
819
|
-
|
|
820
|
-
private
|
|
821
|
-
def check(*, orig_var, result_var)
|
|
822
|
-
if @rvalues && orig_var.type.floating?
|
|
823
|
-
case expr = @rvalues[orig_var]
|
|
824
|
-
when C::AdditiveExpression, C::MultiplicativeExpression
|
|
825
|
-
if orig_var.type.same_as?(from_type) &&
|
|
826
|
-
result_var.type.same_as?(to_type)
|
|
827
|
-
W(message_id, expr.location)
|
|
828
|
-
end
|
|
829
|
-
end
|
|
830
|
-
end
|
|
831
|
-
end
|
|
832
|
-
|
|
833
|
-
def clear_rvalues(*)
|
|
834
|
-
@rvalues = {}
|
|
835
|
-
end
|
|
836
|
-
|
|
837
|
-
def handle_additive(expr, lhs_var, rhs_var, result_var)
|
|
838
|
-
memorize_rvalue_derivation(result_var, expr)
|
|
839
|
-
end
|
|
840
|
-
|
|
841
|
-
def handle_multiplicative(expr, lhs_var, rhs_var, result_var)
|
|
842
|
-
unless expr.operator.type == "%"
|
|
843
|
-
memorize_rvalue_derivation(result_var, expr)
|
|
844
|
-
end
|
|
845
|
-
end
|
|
846
|
-
|
|
847
|
-
def memorize_rvalue_derivation(rvalue_holder, expr)
|
|
848
|
-
@rvalues[rvalue_holder] = expr if @rvalues
|
|
849
|
-
end
|
|
850
|
-
|
|
851
|
-
def from_type
|
|
852
|
-
@interp.float_type
|
|
853
|
-
end
|
|
854
|
-
|
|
855
|
-
def to_type
|
|
856
|
-
@interp.double_type
|
|
857
|
-
end
|
|
858
|
-
|
|
859
|
-
def message_id
|
|
860
|
-
self.class.name.sub(/\A.*::/, "").intern
|
|
861
|
-
end
|
|
862
|
-
end
|
|
863
|
-
|
|
864
|
-
class W1067 < W1066
|
|
865
|
-
def_registrant_phase C::Prepare2Phase
|
|
866
|
-
|
|
867
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
868
|
-
# step-in analysis is supported.
|
|
869
|
-
ensure_uniqueness_of :W1067
|
|
870
|
-
|
|
871
|
-
private
|
|
872
|
-
def from_type
|
|
873
|
-
@interp.float_type
|
|
874
|
-
end
|
|
875
|
-
|
|
876
|
-
def to_type
|
|
877
|
-
@interp.long_double_type
|
|
878
|
-
end
|
|
879
|
-
end
|
|
880
|
-
|
|
881
|
-
class W1068 < W1066
|
|
882
|
-
def_registrant_phase C::Prepare2Phase
|
|
883
|
-
|
|
884
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
885
|
-
# step-in analysis is supported.
|
|
886
|
-
ensure_uniqueness_of :W1068
|
|
887
|
-
|
|
888
|
-
private
|
|
889
|
-
def from_type
|
|
890
|
-
@interp.double_type
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
def to_type
|
|
894
|
-
@interp.long_double_type
|
|
895
|
-
end
|
|
896
|
-
end
|
|
897
|
-
|
|
898
|
-
class W1069 < PassiveCodeCheck
|
|
899
|
-
def_registrant_phase C::Prepare2Phase
|
|
900
|
-
|
|
901
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
902
|
-
# step-in analysis is supported.
|
|
903
|
-
ensure_uniqueness_of :W1069
|
|
904
|
-
|
|
905
|
-
def initialize(context)
|
|
906
|
-
super
|
|
907
|
-
visitor = context[:c_visitor]
|
|
908
|
-
visitor.enter_ansi_function_definition += method(:enter_function)
|
|
909
|
-
visitor.enter_kandr_function_definition += method(:enter_function)
|
|
910
|
-
visitor.enter_compound_statement += method(:enter_compound_stmt)
|
|
911
|
-
visitor.leave_compound_statement += method(:leave_compound_stmt)
|
|
912
|
-
visitor.enter_if_else_statement += method(:enter_if_else_stmt)
|
|
913
|
-
visitor.leave_if_else_statement += method(:leave_if_else_stmt)
|
|
914
|
-
@if_else_stmt_chain_stack = []
|
|
915
|
-
end
|
|
916
|
-
|
|
917
|
-
private
|
|
918
|
-
def enter_function(*)
|
|
919
|
-
@if_else_stmt_chain_stack = []
|
|
920
|
-
end
|
|
921
|
-
|
|
922
|
-
def enter_compound_stmt(*)
|
|
923
|
-
@if_else_stmt_chain_stack.push([])
|
|
924
|
-
end
|
|
925
|
-
|
|
926
|
-
def leave_compound_stmt(*)
|
|
927
|
-
@if_else_stmt_chain_stack.pop
|
|
928
|
-
end
|
|
929
|
-
|
|
930
|
-
def enter_if_else_stmt(node)
|
|
931
|
-
@if_else_stmt_chain_stack.last.push(node)
|
|
932
|
-
if node.else_statement.kind_of?(C::IfStatement)
|
|
933
|
-
W(:W1069, @if_else_stmt_chain_stack.last.first.location)
|
|
934
|
-
end
|
|
935
|
-
end
|
|
936
|
-
|
|
937
|
-
def leave_if_else_stmt(*)
|
|
938
|
-
@if_else_stmt_chain_stack.last.pop
|
|
939
|
-
end
|
|
940
|
-
end
|
|
941
|
-
|
|
942
|
-
class W1070 < W0781
|
|
943
|
-
def_registrant_phase C::Prepare2Phase
|
|
944
|
-
|
|
945
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
946
|
-
# step-in analysis is supported.
|
|
947
|
-
ensure_uniqueness_of :W1070
|
|
948
|
-
|
|
949
|
-
private
|
|
950
|
-
def check(node)
|
|
951
|
-
if exec_path_num = @exec_path_nums.last and exec_path_num == 2
|
|
952
|
-
W(:W1070, node.location)
|
|
953
|
-
end
|
|
954
|
-
@exec_path_nums.pop
|
|
955
|
-
end
|
|
956
|
-
|
|
957
|
-
def add_exec_path(node)
|
|
958
|
-
@exec_path_nums[-1] += 1
|
|
959
|
-
end
|
|
960
|
-
end
|
|
961
|
-
|
|
962
|
-
class W1072 < PassiveCodeCheck
|
|
963
|
-
def_registrant_phase C::Prepare2Phase
|
|
964
|
-
|
|
965
|
-
# NOTE: All messages of cc1-phase code check should be unique till function
|
|
966
|
-
# step-in analysis is supported.
|
|
967
|
-
ensure_uniqueness_of :W1072
|
|
968
|
-
|
|
969
|
-
def initialize(context)
|
|
970
|
-
super
|
|
971
|
-
visitor = context[:c_visitor]
|
|
972
|
-
visitor.enter_goto_statement += method(:warn_goto)
|
|
973
|
-
end
|
|
974
|
-
|
|
975
|
-
private
|
|
976
|
-
def warn_goto(node)
|
|
977
|
-
W(:W1072, node.location)
|
|
978
|
-
end
|
|
979
|
-
end
|
|
980
|
-
|
|
981
|
-
end
|
|
982
|
-
end
|
|
983
|
-
end
|