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
|
# Code checkings (cpp-phase) of adlint-exam-c_builtin package.
|
2
2
|
#
|
3
3
|
# Author:: Rie Shima <mailto:rkakuuchi@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:: Rie Shima <mailto:rkakuuchi@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
|
#
|
@@ -43,18 +43,18 @@ module CBuiltin #:nodoc:
|
|
43
43
|
|
44
44
|
# NOTE: W0687 may be duplicative when the same header which causes this
|
45
45
|
# warning is included twice or more.
|
46
|
-
|
46
|
+
mark_as_unique
|
47
47
|
|
48
|
-
def initialize(
|
48
|
+
def initialize(phase_ctxt)
|
49
49
|
super
|
50
|
-
interp =
|
51
|
-
interp.on_macro_undefined +=
|
50
|
+
interp = phase_ctxt[:cpp_interpreter]
|
51
|
+
interp.on_macro_undefined += T(:check)
|
52
52
|
end
|
53
53
|
|
54
54
|
private
|
55
|
-
def check(undef_line,
|
55
|
+
def check(undef_line, *)
|
56
56
|
if undef_line.identifier.value == "defined"
|
57
|
-
W(
|
57
|
+
W(undef_line.identifier.location)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -64,12 +64,12 @@ module CBuiltin #:nodoc:
|
|
64
64
|
|
65
65
|
# NOTE: W0688 may be duplicative when the same header which causes this
|
66
66
|
# warning is included twice or more.
|
67
|
-
|
67
|
+
mark_as_unique
|
68
68
|
|
69
|
-
def initialize(
|
69
|
+
def initialize(phase_ctxt)
|
70
70
|
super
|
71
|
-
visitor =
|
72
|
-
visitor.enter_line_line +=
|
71
|
+
visitor = phase_ctxt[:cpp_visitor]
|
72
|
+
visitor.enter_line_line += T(:check)
|
73
73
|
end
|
74
74
|
|
75
75
|
private
|
@@ -77,7 +77,7 @@ module CBuiltin #:nodoc:
|
|
77
77
|
if line_no_arg = line_no_argument(line_line)
|
78
78
|
line_no = Integer(line_no_arg.value)
|
79
79
|
unless line_no > 0 && line_no < 32768
|
80
|
-
W(
|
80
|
+
W(line_no_arg.location)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
rescue
|
@@ -93,13 +93,13 @@ module CBuiltin #:nodoc:
|
|
93
93
|
|
94
94
|
# NOTE: W0689 may be duplicative when the same header which causes this
|
95
95
|
# warning is included twice or more.
|
96
|
-
|
96
|
+
mark_as_unique
|
97
97
|
|
98
98
|
private
|
99
99
|
def check(line_line)
|
100
100
|
if fname_arg = file_name_argument(line_line)
|
101
101
|
unless fname_arg.value =~ /\A".*"\z/
|
102
|
-
W(
|
102
|
+
W(fname_arg.location)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -114,7 +114,7 @@ module CBuiltin #:nodoc:
|
|
114
114
|
|
115
115
|
# NOTE: W0690 may be duplicative when the same header which causes this
|
116
116
|
# warning is included twice or more.
|
117
|
-
|
117
|
+
mark_as_unique
|
118
118
|
|
119
119
|
private
|
120
120
|
def check(line_line)
|
@@ -122,7 +122,7 @@ module CBuiltin #:nodoc:
|
|
122
122
|
Integer(line_no_arg.value)
|
123
123
|
end
|
124
124
|
rescue
|
125
|
-
W(
|
125
|
+
W(line_no_arg.location)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -131,12 +131,12 @@ module CBuiltin #:nodoc:
|
|
131
131
|
|
132
132
|
# NOTE: W0695 may be duplicative when the same header which causes this
|
133
133
|
# warning is included twice or more.
|
134
|
-
|
134
|
+
mark_as_unique
|
135
135
|
|
136
136
|
private
|
137
|
-
def check(undef_line,
|
137
|
+
def check(undef_line, *)
|
138
138
|
if undef_line.identifier.value == "assert"
|
139
|
-
W(
|
139
|
+
W(undef_line.identifier.location)
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
@@ -146,18 +146,18 @@ module CBuiltin #:nodoc:
|
|
146
146
|
|
147
147
|
# NOTE: W0806 may be duplicative when the same header which causes this
|
148
148
|
# warning is included twice or more.
|
149
|
-
|
149
|
+
mark_as_unique
|
150
150
|
|
151
|
-
def initialize(
|
151
|
+
def initialize(phase_ctxt)
|
152
152
|
super
|
153
|
-
interp =
|
154
|
-
interp.on_object_like_macro_defined +=
|
153
|
+
interp = phase_ctxt[:cpp_interpreter]
|
154
|
+
interp.on_object_like_macro_defined += T(:check)
|
155
155
|
end
|
156
156
|
|
157
157
|
private
|
158
|
-
def check(define_line,
|
158
|
+
def check(define_line, *)
|
159
159
|
if define_line.identifier.value == "defined"
|
160
|
-
W(
|
160
|
+
W(define_line.identifier.location)
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
@@ -167,13 +167,13 @@ module CBuiltin #:nodoc:
|
|
167
167
|
|
168
168
|
# NOTE: W0807 may be duplicative when the same header which causes this
|
169
169
|
# warning is included twice or more.
|
170
|
-
|
170
|
+
mark_as_unique
|
171
171
|
|
172
172
|
private
|
173
173
|
def check(undef_line, macro)
|
174
174
|
if macro.kind_of?(Cpp::SpecialMacro)
|
175
175
|
identifier = undef_line.identifier
|
176
|
-
W(
|
176
|
+
W(identifier.location, identifier.value)
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
@@ -183,22 +183,19 @@ module CBuiltin #:nodoc:
|
|
183
183
|
|
184
184
|
# NOTE: W0808 may be duplicative when the same header which causes this
|
185
185
|
# warning is included twice or more.
|
186
|
-
|
186
|
+
mark_as_unique
|
187
187
|
|
188
|
-
def initialize(
|
188
|
+
def initialize(phase_ctxt)
|
189
189
|
super
|
190
|
-
interp =
|
191
|
-
interp.on_object_like_macro_defined +=
|
192
|
-
@
|
190
|
+
interp = phase_ctxt[:cpp_interpreter]
|
191
|
+
interp.on_object_like_macro_defined += T(:check)
|
192
|
+
@macro_tbl = phase_ctxt[:cpp_macro_table]
|
193
193
|
end
|
194
194
|
|
195
195
|
private
|
196
|
-
def check(define_line,
|
197
|
-
|
198
|
-
|
199
|
-
if @macro_table.lookup(identifier.value)
|
200
|
-
W(:W0808, identifier.location, identifier.value)
|
201
|
-
end
|
196
|
+
def check(define_line, *)
|
197
|
+
id = define_line.identifier
|
198
|
+
W(id.location, id.value) if @macro_tbl.lookup(id.value)
|
202
199
|
end
|
203
200
|
end
|
204
201
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Code structure extractions (cpp-phase) of adlint-exam-c_builtin package.
|
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
|
#
|
@@ -40,15 +40,15 @@ module CBuiltin #:nodoc:
|
|
40
40
|
class ObjectLikeMacroExtraction < CodeExtraction
|
41
41
|
def_registrant_phase Cpp::Prepare2Phase
|
42
42
|
|
43
|
-
def initialize(
|
43
|
+
def initialize(phase_ctxt)
|
44
44
|
super
|
45
|
-
interp =
|
46
|
-
interp.on_object_like_macro_defined +=
|
45
|
+
interp = phase_ctxt[:cpp_interpreter]
|
46
|
+
interp.on_object_like_macro_defined += T(:extract)
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
|
-
def do_prepare(
|
51
|
-
def do_execute(
|
50
|
+
def do_prepare(*) end
|
51
|
+
def do_execute(*) end
|
52
52
|
|
53
53
|
def extract(define_line, macro)
|
54
54
|
MACRODEF(define_line.location, macro.name.value, "O")
|
@@ -58,16 +58,16 @@ module CBuiltin #:nodoc:
|
|
58
58
|
class FuncLikeMacroExtraction < CodeExtraction
|
59
59
|
def_registrant_phase Cpp::Prepare2Phase
|
60
60
|
|
61
|
-
def initialize(
|
61
|
+
def initialize(phase_ctxt)
|
62
62
|
super
|
63
|
-
interp =
|
64
|
-
interp.on_function_like_macro_defined
|
65
|
-
interp.on_va_function_like_macro_defined +=
|
63
|
+
interp = phase_ctxt[:cpp_interpreter]
|
64
|
+
interp.on_function_like_macro_defined += T(:extract)
|
65
|
+
interp.on_va_function_like_macro_defined += T(:extract)
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
|
-
def do_prepare(
|
70
|
-
def do_execute(
|
69
|
+
def do_prepare(*) end
|
70
|
+
def do_execute(*) end
|
71
71
|
|
72
72
|
def extract(define_line, macro)
|
73
73
|
MACRODEF(define_line.location, macro.name.value, "F")
|
@@ -77,91 +77,90 @@ module CBuiltin #:nodoc:
|
|
77
77
|
class IncludeDirectiveExtraction < CodeExtraction
|
78
78
|
def_registrant_phase Cpp::Prepare2Phase
|
79
79
|
|
80
|
-
def initialize(
|
80
|
+
def initialize(phase_ctxt)
|
81
81
|
super
|
82
|
-
interp =
|
83
|
-
interp.on_system_header_included +=
|
84
|
-
interp.on_user_header_included
|
82
|
+
interp = phase_ctxt[:cpp_interpreter]
|
83
|
+
interp.on_system_header_included += T(:extract_system_include)
|
84
|
+
interp.on_user_header_included += T(:extract_user_include)
|
85
85
|
end
|
86
86
|
|
87
87
|
private
|
88
|
-
def do_prepare(
|
89
|
-
def do_execute(
|
88
|
+
def do_prepare(*) end
|
89
|
+
def do_execute(*) end
|
90
90
|
|
91
|
-
def extract_system_include(
|
92
|
-
INCLUDE(
|
91
|
+
def extract_system_include(sys_include_line, sys_header)
|
92
|
+
INCLUDE(sys_include_line.location, "<#{sys_header.fpath}>")
|
93
93
|
end
|
94
94
|
|
95
|
-
def extract_user_include(
|
96
|
-
INCLUDE(
|
95
|
+
def extract_user_include(usr_include_line, usr_header)
|
96
|
+
INCLUDE(usr_include_line.location, "\"#{usr_header.fpath}\"")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
class DirectiveExtraction < CodeExtraction
|
101
101
|
def_registrant_phase Cpp::Prepare2Phase
|
102
102
|
|
103
|
-
def initialize(
|
103
|
+
def initialize(phase_ctxt)
|
104
104
|
super
|
105
|
-
visitor =
|
106
|
-
visitor.enter_if_statement
|
107
|
-
visitor.enter_ifdef_statement
|
108
|
-
visitor.enter_ifndef_statement
|
109
|
-
visitor.enter_elif_statement
|
110
|
-
visitor.enter_else_statement
|
111
|
-
visitor.enter_endif_line
|
112
|
-
visitor.enter_user_include_line
|
113
|
-
visitor.enter_system_include_line
|
114
|
-
visitor.enter_object_like_define_line
|
115
|
-
visitor.enter_function_like_define_line
|
116
|
-
visitor.enter_va_function_like_define_line +=
|
117
|
-
visitor.enter_undef_line
|
118
|
-
visitor.enter_line_line
|
119
|
-
visitor.enter_error_line
|
120
|
-
visitor.enter_pragma_line
|
121
|
-
visitor.enter_null_directive
|
105
|
+
visitor = phase_ctxt[:cpp_visitor]
|
106
|
+
visitor.enter_if_statement += T(:extract_if)
|
107
|
+
visitor.enter_ifdef_statement += T(:extract_ifdef)
|
108
|
+
visitor.enter_ifndef_statement += T(:extract_ifndef)
|
109
|
+
visitor.enter_elif_statement += T(:extract_elif)
|
110
|
+
visitor.enter_else_statement += T(:extract_else)
|
111
|
+
visitor.enter_endif_line += T(:extract_endif)
|
112
|
+
visitor.enter_user_include_line += T(:extract_user_include)
|
113
|
+
visitor.enter_system_include_line += T(:extract_system_include)
|
114
|
+
visitor.enter_object_like_define_line += T(:extract_define)
|
115
|
+
visitor.enter_function_like_define_line += T(:extract_define)
|
116
|
+
visitor.enter_va_function_like_define_line += T(:extract_define)
|
117
|
+
visitor.enter_undef_line += T(:extract_undef)
|
118
|
+
visitor.enter_line_line += T(:extract_line)
|
119
|
+
visitor.enter_error_line += T(:extract_error)
|
120
|
+
visitor.enter_pragma_line += T(:extract_pragma)
|
121
|
+
visitor.enter_null_directive += T(:extract_null)
|
122
122
|
end
|
123
123
|
|
124
124
|
private
|
125
|
-
def do_prepare(
|
126
|
-
def do_execute(
|
125
|
+
def do_prepare(*) end
|
126
|
+
def do_execute(*) end
|
127
127
|
|
128
|
-
def extract_if(
|
129
|
-
PP_DIRECTIVE(
|
130
|
-
|
128
|
+
def extract_if(if_stmt)
|
129
|
+
PP_DIRECTIVE(if_stmt.location, if_stmt.keyword.value,
|
130
|
+
if_stmt.expression.to_s)
|
131
131
|
end
|
132
132
|
|
133
|
-
def extract_ifdef(
|
134
|
-
PP_DIRECTIVE(
|
135
|
-
|
133
|
+
def extract_ifdef(ifdef_stmt)
|
134
|
+
PP_DIRECTIVE(ifdef_stmt.location, ifdef_stmt.keyword.value,
|
135
|
+
ifdef_stmt.identifier.value)
|
136
136
|
end
|
137
137
|
|
138
|
-
def extract_ifndef(
|
139
|
-
PP_DIRECTIVE(
|
140
|
-
|
138
|
+
def extract_ifndef(ifndef_stmt)
|
139
|
+
PP_DIRECTIVE(ifndef_stmt.location, ifndef_stmt.keyword.value,
|
140
|
+
ifndef_stmt.identifier.value)
|
141
141
|
end
|
142
142
|
|
143
|
-
def extract_elif(
|
144
|
-
PP_DIRECTIVE(
|
145
|
-
|
143
|
+
def extract_elif(elif_stmt)
|
144
|
+
PP_DIRECTIVE(elif_stmt.location, elif_stmt.keyword.value,
|
145
|
+
elif_stmt.expression.to_s)
|
146
146
|
end
|
147
147
|
|
148
|
-
def extract_else(
|
149
|
-
PP_DIRECTIVE(
|
148
|
+
def extract_else(else_stmt)
|
149
|
+
PP_DIRECTIVE(else_stmt.location, else_stmt.keyword.value, nil)
|
150
150
|
end
|
151
151
|
|
152
152
|
def extract_endif(endif_line)
|
153
153
|
PP_DIRECTIVE(endif_line.location, endif_line.keyword.value, nil)
|
154
154
|
end
|
155
155
|
|
156
|
-
def extract_user_include(
|
157
|
-
PP_DIRECTIVE(
|
158
|
-
|
156
|
+
def extract_user_include(usr_include_line)
|
157
|
+
PP_DIRECTIVE(usr_include_line.location, usr_include_line.keyword.value,
|
158
|
+
usr_include_line.header_name.value)
|
159
159
|
end
|
160
160
|
|
161
|
-
def extract_system_include(
|
162
|
-
PP_DIRECTIVE(
|
163
|
-
|
164
|
-
system_include_line.header_name.value)
|
161
|
+
def extract_system_include(sys_include_line)
|
162
|
+
PP_DIRECTIVE(sys_include_line.location, sys_include_line.keyword.value,
|
163
|
+
sys_include_line.header_name.value)
|
165
164
|
end
|
166
165
|
|
167
166
|
def extract_define(define_line)
|
@@ -194,7 +193,6 @@ module CBuiltin #:nodoc:
|
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
197
|
-
|
198
196
|
end
|
199
197
|
end
|
200
198
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Code checkings (ld-phase) of adlint-exam-c_builtin package.
|
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
|
#
|
@@ -39,16 +39,16 @@ module CBuiltin #:nodoc:
|
|
39
39
|
class W0555 < PassiveCodeCheck
|
40
40
|
def_registrant_phase Ld::PreparePhase
|
41
41
|
|
42
|
-
def initialize(
|
42
|
+
def initialize(phase_ctxt)
|
43
43
|
super
|
44
|
-
|
44
|
+
phase_ctxt[:ld_function_traversal].on_definition += T(:check)
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
|
-
def check(
|
49
|
-
call_graph = @
|
50
|
-
if call_graph.indirect_callers_of(
|
51
|
-
W(
|
48
|
+
def check(fun)
|
49
|
+
call_graph = @phase_ctxt[:ld_function_call_graph]
|
50
|
+
if call_graph.indirect_callers_of(fun).include?(fun)
|
51
|
+
W(fun.location)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -56,16 +56,16 @@ module CBuiltin #:nodoc:
|
|
56
56
|
class W0586 < PassiveCodeCheck
|
57
57
|
def_registrant_phase Ld::PreparePhase
|
58
58
|
|
59
|
-
def initialize(
|
59
|
+
def initialize(phase_ctxt)
|
60
60
|
super
|
61
|
-
|
61
|
+
phase_ctxt[:ld_typedef_traversal].on_declaration += T(:check)
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
65
65
|
def check(typedef)
|
66
|
-
mapping = @
|
66
|
+
mapping = @phase_ctxt[:ld_typedef_mapping]
|
67
67
|
if mapping.lookup(typedef.name).any? { |td| td != typedef }
|
68
|
-
W(
|
68
|
+
W(typedef.location, typedef.name)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -73,32 +73,30 @@ module CBuiltin #:nodoc:
|
|
73
73
|
class W0589 < PassiveCodeCheck
|
74
74
|
def_registrant_phase Ld::PreparePhase
|
75
75
|
|
76
|
-
def initialize(
|
76
|
+
def initialize(phase_ctxt)
|
77
77
|
super
|
78
|
-
|
79
|
-
|
78
|
+
phase_ctxt[:ld_function_traversal].on_definition += T(:check_function)
|
79
|
+
phase_ctxt[:ld_variable_traversal].on_definition += T(:check_variable)
|
80
80
|
end
|
81
81
|
|
82
82
|
private
|
83
|
-
def check_function(
|
84
|
-
return unless
|
85
|
-
call_graph = @
|
86
|
-
direct_callers = call_graph.direct_callers_of(
|
83
|
+
def check_function(fun)
|
84
|
+
return unless fun.extern?
|
85
|
+
call_graph = @phase_ctxt[:ld_function_call_graph]
|
86
|
+
direct_callers = call_graph.direct_callers_of(fun)
|
87
87
|
if direct_callers.size == 1 &&
|
88
|
-
direct_callers.first.location.fpath ==
|
89
|
-
W(
|
90
|
-
function.signature, direct_callers.first.signature)
|
88
|
+
direct_callers.first.location.fpath == fun.location.fpath
|
89
|
+
W(fun.location, fun.signature, direct_callers.first.signature)
|
91
90
|
end
|
92
91
|
end
|
93
92
|
|
94
|
-
def check_variable(
|
95
|
-
return unless
|
96
|
-
|
97
|
-
direct_referrers =
|
93
|
+
def check_variable(var)
|
94
|
+
return unless var.extern?
|
95
|
+
ref_graph = @phase_ctxt[:ld_variable_reference_graph]
|
96
|
+
direct_referrers = ref_graph.direct_referrers_of(var)
|
98
97
|
if direct_referrers.size == 1 &&
|
99
|
-
direct_referrers.first.location.fpath ==
|
100
|
-
W(
|
101
|
-
variable.name, direct_referrers.first.signature)
|
98
|
+
direct_referrers.first.location.fpath == var.location.fpath
|
99
|
+
W(var.location, var.name, direct_referrers.first.signature)
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
@@ -106,20 +104,19 @@ module CBuiltin #:nodoc:
|
|
106
104
|
class W0591 < PassiveCodeCheck
|
107
105
|
def_registrant_phase Ld::PreparePhase
|
108
106
|
|
109
|
-
def initialize(
|
107
|
+
def initialize(phase_ctxt)
|
110
108
|
super
|
111
|
-
|
109
|
+
phase_ctxt[:ld_function_traversal].on_definition += T(:check)
|
112
110
|
end
|
113
111
|
|
114
112
|
private
|
115
|
-
def check(
|
116
|
-
return unless
|
117
|
-
call_graph = @
|
118
|
-
direct_callers = call_graph.direct_callers_of(
|
113
|
+
def check(fun)
|
114
|
+
return unless fun.extern?
|
115
|
+
call_graph = @phase_ctxt[:ld_function_call_graph]
|
116
|
+
direct_callers = call_graph.direct_callers_of(fun)
|
119
117
|
if !direct_callers.empty? &&
|
120
|
-
direct_callers.all? { |f|
|
121
|
-
|
122
|
-
W(:W0591, function.location, function.signature)
|
118
|
+
direct_callers.all? { |f| f.location.fpath == fun.location.fpath }
|
119
|
+
W(fun.location, fun.signature)
|
123
120
|
end
|
124
121
|
end
|
125
122
|
end
|
@@ -127,20 +124,19 @@ module CBuiltin #:nodoc:
|
|
127
124
|
class W0593 < PassiveCodeCheck
|
128
125
|
def_registrant_phase Ld::PreparePhase
|
129
126
|
|
130
|
-
def initialize(
|
127
|
+
def initialize(phase_ctxt)
|
131
128
|
super
|
132
|
-
|
129
|
+
phase_ctxt[:ld_variable_traversal].on_definition += T(:check)
|
133
130
|
end
|
134
131
|
|
135
132
|
private
|
136
|
-
def check(
|
137
|
-
return unless
|
138
|
-
|
139
|
-
direct_referrers =
|
133
|
+
def check(var)
|
134
|
+
return unless var.extern?
|
135
|
+
ref_graph = @phase_ctxt[:ld_variable_reference_graph]
|
136
|
+
direct_referrers = ref_graph.direct_referrers_of(var)
|
140
137
|
if !direct_referrers.empty? &&
|
141
|
-
direct_referrers.all? { |f|
|
142
|
-
|
143
|
-
W(:W0593, variable.location, variable.name)
|
138
|
+
direct_referrers.all? { |f| f.location.fpath == var.location.fpath }
|
139
|
+
W(var.location, var.name)
|
144
140
|
end
|
145
141
|
end
|
146
142
|
end
|
@@ -148,17 +144,17 @@ module CBuiltin #:nodoc:
|
|
148
144
|
class W0628 < PassiveCodeCheck
|
149
145
|
def_registrant_phase Ld::PreparePhase
|
150
146
|
|
151
|
-
def initialize(
|
147
|
+
def initialize(phase_ctxt)
|
152
148
|
super
|
153
|
-
|
149
|
+
phase_ctxt[:ld_function_traversal].on_definition += T(:check)
|
154
150
|
end
|
155
151
|
|
156
152
|
private
|
157
|
-
def check(
|
158
|
-
call_graph = @
|
159
|
-
unless
|
160
|
-
if call_graph.direct_callers_of(
|
161
|
-
W(
|
153
|
+
def check(fun)
|
154
|
+
call_graph = @phase_ctxt[:ld_function_call_graph]
|
155
|
+
unless fun.name == "main"
|
156
|
+
if call_graph.direct_callers_of(fun).empty?
|
157
|
+
W(fun.location, fun.signature)
|
162
158
|
end
|
163
159
|
end
|
164
160
|
end
|
@@ -169,48 +165,57 @@ module CBuiltin #:nodoc:
|
|
169
165
|
|
170
166
|
# NOTE: W0770 may be duplicative when function declarations of the same
|
171
167
|
# name appears twice or more in the project.
|
172
|
-
|
168
|
+
mark_as_unique
|
173
169
|
|
174
|
-
def initialize(
|
170
|
+
def initialize(phase_ctxt)
|
175
171
|
super
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
var_traversal.on_declaration
|
181
|
-
var_traversal.on_definition
|
172
|
+
fun_traversal = phase_ctxt[:ld_function_traversal]
|
173
|
+
var_traversal = phase_ctxt[:ld_variable_traversal]
|
174
|
+
fun_traversal.on_declaration += T(:check_function_declaration)
|
175
|
+
fun_traversal.on_definition += T(:check_function_definition)
|
176
|
+
var_traversal.on_declaration += T(:check_variable)
|
177
|
+
var_traversal.on_definition += T(:check_variable)
|
182
178
|
end
|
183
179
|
|
184
180
|
private
|
185
|
-
def
|
186
|
-
|
181
|
+
def check_function_declaration(fun_dcl)
|
182
|
+
if fun_dcl.extern? && fun_dcl.explicit?
|
183
|
+
check_function(fun_dcl)
|
184
|
+
end
|
185
|
+
end
|
187
186
|
|
188
|
-
|
189
|
-
|
187
|
+
def check_function_definition(fun_def)
|
188
|
+
if fun_def.extern?
|
189
|
+
check_function(fun_def)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def check_function(fun)
|
194
|
+
mapping = @phase_ctxt[:ld_function_mapping]
|
195
|
+
similar_dcls =
|
196
|
+
mapping.lookup_function_declarations(fun.name).select { |fun_dcl|
|
197
|
+
fun_dcl.explicit?
|
198
|
+
}
|
190
199
|
|
191
200
|
if similar_dcls.size > 1
|
192
|
-
W(
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
end
|
197
|
-
end
|
201
|
+
W(fun.location, fun.signature, *similar_dcls.map { |pair_dcl|
|
202
|
+
next if pair_dcl == fun
|
203
|
+
C(:C0001, pair_dcl.location, pair_dcl.signature)
|
204
|
+
}.compact)
|
198
205
|
end
|
199
206
|
end
|
200
207
|
|
201
208
|
def check_variable(var)
|
202
209
|
return unless var.extern?
|
203
210
|
|
204
|
-
mapping = @
|
211
|
+
mapping = @phase_ctxt[:ld_variable_mapping]
|
205
212
|
similar_dcls = mapping.lookup_variable_declarations(var.name)
|
206
213
|
|
207
214
|
if similar_dcls.size > 1
|
208
|
-
W(
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
end
|
213
|
-
end
|
215
|
+
W(var.location, var.name, *similar_dcls.map { |pair_dcl|
|
216
|
+
next if pair_dcl == var
|
217
|
+
C(:C0001, pair_dcl.location, pair_dcl.name)
|
218
|
+
}.compact)
|
214
219
|
end
|
215
220
|
end
|
216
221
|
end
|
@@ -220,44 +225,40 @@ module CBuiltin #:nodoc:
|
|
220
225
|
|
221
226
|
# NOTE: W0791 may be duplicative when definitions of the same name appears
|
222
227
|
# twice or more in the project.
|
223
|
-
|
228
|
+
mark_as_unique
|
224
229
|
|
225
|
-
def initialize(
|
230
|
+
def initialize(phase_ctxt)
|
226
231
|
super
|
227
|
-
|
228
|
-
|
232
|
+
phase_ctxt[:ld_function_traversal].on_definition += T(:check_function)
|
233
|
+
phase_ctxt[:ld_variable_traversal].on_definition += T(:check_variable)
|
229
234
|
end
|
230
235
|
|
231
236
|
private
|
232
|
-
def check_function(
|
233
|
-
return unless
|
234
|
-
|
235
|
-
mapping = @
|
236
|
-
|
237
|
-
|
238
|
-
if
|
239
|
-
W(
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
end
|
244
|
-
end
|
237
|
+
def check_function(fun)
|
238
|
+
return unless fun.extern?
|
239
|
+
|
240
|
+
mapping = @phase_ctxt[:ld_function_mapping]
|
241
|
+
similar_funs = mapping.lookup_functions(fun.name)
|
242
|
+
|
243
|
+
if similar_funs.size > 1
|
244
|
+
W(fun.location, fun.signature, *similar_funs.map { |pair_fun|
|
245
|
+
next if pair_fun == fun
|
246
|
+
C(:C0001, pair_fun.location, pair_fun.signature)
|
247
|
+
}.compact)
|
245
248
|
end
|
246
249
|
end
|
247
250
|
|
248
251
|
def check_variable(var)
|
249
252
|
return unless var.extern?
|
250
253
|
|
251
|
-
mapping = @
|
254
|
+
mapping = @phase_ctxt[:ld_variable_mapping]
|
252
255
|
similar_vars = mapping.lookup_variables(var.name)
|
253
256
|
|
254
257
|
if similar_vars.size > 1
|
255
|
-
W(
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
end
|
260
|
-
end
|
258
|
+
W(var.location, var.name, *similar_vars.map { |pair_var|
|
259
|
+
next if pair_var == var
|
260
|
+
C(:C0001, pair_var.location, pair_var.name)
|
261
|
+
}.compact)
|
261
262
|
end
|
262
263
|
end
|
263
264
|
end
|
@@ -267,41 +268,48 @@ module CBuiltin #:nodoc:
|
|
267
268
|
|
268
269
|
# NOTE: W1037 may be duplicative when declarations or definitions of the
|
269
270
|
# same name appears twice or more in the project.
|
270
|
-
|
271
|
+
mark_as_unique
|
271
272
|
|
272
|
-
def initialize(
|
273
|
+
def initialize(phase_ctxt)
|
273
274
|
super
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
var_traversal.on_declaration +=
|
279
|
-
var_traversal.on_definition
|
275
|
+
fun_traversal = phase_ctxt[:ld_function_traversal]
|
276
|
+
var_traversal = phase_ctxt[:ld_variable_traversal]
|
277
|
+
fun_traversal.on_declaration += T(:check_function_declaration)
|
278
|
+
fun_traversal.on_definition += T(:check_function_definition)
|
279
|
+
var_traversal.on_declaration += T(:check_variable)
|
280
|
+
var_traversal.on_definition += T(:check_variable)
|
280
281
|
end
|
281
282
|
|
282
283
|
private
|
283
|
-
def
|
284
|
-
|
285
|
-
|
286
|
-
mapping = @context[:ld_function_mapping]
|
287
|
-
similar_dcls_or_funcs =
|
288
|
-
(mapping.lookup_function_declarations(func.name) +
|
289
|
-
mapping.lookup_functions(func.name)).select { |dcl_or_func|
|
290
|
-
dcl_or_func.extern? && dcl_or_func.signature != func.signature
|
291
|
-
}
|
284
|
+
def check_function_declaration(fun)
|
285
|
+
check_function(fun) if fun.extern? && fun.explicit?
|
286
|
+
end
|
292
287
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
288
|
+
def check_function_definition(fun)
|
289
|
+
check_function(fun) if fun.extern?
|
290
|
+
end
|
291
|
+
|
292
|
+
def check_function(fun)
|
293
|
+
mapping = @phase_ctxt[:ld_function_mapping]
|
294
|
+
similar_dcls_or_funs =
|
295
|
+
mapping.lookup_function_declarations(fun.name).select { |dcl|
|
296
|
+
dcl.explicit? && dcl.extern? && dcl.signature != fun.signature
|
297
|
+
} + mapping.lookup_functions(fun.name).select { |mapped_fun|
|
298
|
+
mapped_fun.extern? && mapped_fun.signature != fun.signature
|
299
|
+
}
|
300
|
+
|
301
|
+
unless similar_dcls_or_funs.empty?
|
302
|
+
W(fun.location, fun.signature,
|
303
|
+
*similar_dcls_or_funs.map { |pair_dcl_or_fun|
|
304
|
+
C(:C0001, pair_dcl_or_fun.location, pair_dcl_or_fun.signature)
|
305
|
+
})
|
298
306
|
end
|
299
307
|
end
|
300
308
|
|
301
309
|
def check_variable(var)
|
302
310
|
return unless var.extern?
|
303
311
|
|
304
|
-
mapping = @
|
312
|
+
mapping = @phase_ctxt[:ld_variable_mapping]
|
305
313
|
similar_dcls_or_vars =
|
306
314
|
(mapping.lookup_variable_declarations(var.name) +
|
307
315
|
mapping.lookup_variables(var.name)).select { |dcl_or_var|
|
@@ -309,10 +317,9 @@ module CBuiltin #:nodoc:
|
|
309
317
|
}
|
310
318
|
|
311
319
|
unless similar_dcls_or_vars.empty?
|
312
|
-
W(
|
313
|
-
similar_dcls_or_vars.each do |pair_dcl_or_var|
|
320
|
+
W(var.location, var.name, *similar_dcls_or_vars.map { |pair_dcl_or_var|
|
314
321
|
C(:C0001, pair_dcl_or_var.location, pair_dcl_or_var.name)
|
315
|
-
|
322
|
+
})
|
316
323
|
end
|
317
324
|
end
|
318
325
|
end
|