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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Analysis phases for C language.
|
|
2
|
+
#
|
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
|
+
#
|
|
7
|
+
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
8
|
+
|
|
9
|
+
#--
|
|
10
|
+
# ___ ____ __ ___ _________
|
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
|
+
#
|
|
16
|
+
# This file is part of AdLint.
|
|
17
|
+
#
|
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
21
|
+
# version.
|
|
22
|
+
#
|
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
26
|
+
#
|
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
#
|
|
30
|
+
#++
|
|
31
|
+
|
|
32
|
+
require "adlint/phase"
|
|
33
|
+
require "adlint/error"
|
|
34
|
+
require "adlint/cc1/lexer"
|
|
35
|
+
require "adlint/cc1/parser"
|
|
36
|
+
require "adlint/cc1/syntax"
|
|
37
|
+
require "adlint/cc1/interp"
|
|
38
|
+
require "adlint/cc1/util"
|
|
39
|
+
|
|
40
|
+
module AdLint #:nodoc:
|
|
41
|
+
module Cc1 #:nodoc:
|
|
42
|
+
|
|
43
|
+
class CPhase < Phase
|
|
44
|
+
def initialize(phase_ctxt, phase_name)
|
|
45
|
+
super(phase_ctxt, "cc1", phase_name)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class Prepare1Phase < CPhase
|
|
50
|
+
def initialize(phase_ctxt)
|
|
51
|
+
super(phase_ctxt, "pr3")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
def do_execute(phase_ctxt, *)
|
|
56
|
+
phase_ctxt[:cc1_visitor] = SyntaxTreeMulticastVisitor.new
|
|
57
|
+
phase_ctxt[:cc1_parser] = Parser.new(phase_ctxt)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class ParsePhase < CPhase
|
|
62
|
+
def initialize(phase_ctxt)
|
|
63
|
+
super(phase_ctxt, "prs")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
def do_execute(phase_ctxt, *)
|
|
68
|
+
phase_ctxt[:cc1_syntax_tree] = phase_ctxt[:cc1_parser].execute
|
|
69
|
+
ensure
|
|
70
|
+
phase_ctxt[:cc1_token_array] = phase_ctxt[:cc1_parser].token_array
|
|
71
|
+
DebugUtil.dump_token_array(phase_ctxt)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class ResolvePhase < CPhase
|
|
76
|
+
def initialize(phase_ctxt)
|
|
77
|
+
super(phase_ctxt, "typ")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
def do_execute(phase_ctxt, *)
|
|
82
|
+
resolver = StaticTypeResolver.new(TypeTable.new(traits, monitor, logger))
|
|
83
|
+
phase_ctxt[:cc1_type_table] =
|
|
84
|
+
resolver.resolve(phase_ctxt[:cc1_syntax_tree])
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class Prepare2Phase < CPhase
|
|
89
|
+
def initialize(phase_ctxt)
|
|
90
|
+
super(phase_ctxt, "pr4")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
def do_execute(phase_ctxt, *)
|
|
95
|
+
phase_ctxt[:cc1_interpreter] =
|
|
96
|
+
Interpreter.new(phase_ctxt[:cc1_type_table])
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class InterpPhase < CPhase
|
|
101
|
+
def initialize(phase_ctxt)
|
|
102
|
+
super(phase_ctxt, "int")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
private
|
|
106
|
+
def do_execute(phase_ctxt, *)
|
|
107
|
+
Program.new(phase_ctxt[:cc1_interpreter],
|
|
108
|
+
phase_ctxt[:cc1_syntax_tree]).execute
|
|
109
|
+
ValueDomain.clear_memos
|
|
110
|
+
ensure
|
|
111
|
+
DebugUtil.dump_syntax_tree(phase_ctxt)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
class ReviewPhase < CPhase
|
|
116
|
+
def initialize(phase_ctxt)
|
|
117
|
+
super(phase_ctxt, "rv2")
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
private
|
|
121
|
+
def do_execute(phase_ctxt, *)
|
|
122
|
+
phase_ctxt[:cc1_syntax_tree].accept(phase_ctxt[:cc1_visitor])
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
class ExaminationPhase < CPhase
|
|
127
|
+
def initialize(phase_ctxt)
|
|
128
|
+
super(phase_ctxt, "ex2")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
private
|
|
132
|
+
def do_execute(phase_ctxt, *)
|
|
133
|
+
examinations.each { |exam| exam.execute }
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# C type resolver.
|
|
2
2
|
#
|
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
6
|
#
|
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
15
|
#
|
|
16
16
|
# This file is part of AdLint.
|
|
17
17
|
#
|
|
@@ -30,37 +30,35 @@
|
|
|
30
30
|
#++
|
|
31
31
|
|
|
32
32
|
require "adlint/monitor"
|
|
33
|
-
require "adlint/
|
|
34
|
-
require "adlint/
|
|
33
|
+
require "adlint/cc1/type"
|
|
34
|
+
require "adlint/cc1/syntax"
|
|
35
35
|
|
|
36
36
|
module AdLint #:nodoc:
|
|
37
|
-
module
|
|
37
|
+
module Cc1 #:nodoc:
|
|
38
38
|
|
|
39
39
|
class TypeResolver < SyntaxTreeVisitor
|
|
40
40
|
include MonitorUtil
|
|
41
41
|
|
|
42
|
-
def initialize(
|
|
43
|
-
@type_table =
|
|
42
|
+
def initialize(type_tbl)
|
|
43
|
+
@type_table = type_tbl
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
attr_reader :type_table
|
|
47
47
|
|
|
48
|
-
def resolve(
|
|
49
|
-
|
|
48
|
+
def resolve(ast)
|
|
49
|
+
ast.accept(self)
|
|
50
50
|
@type_table
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def visit_struct_type_declaration(node)
|
|
54
54
|
checkpoint(node.location)
|
|
55
|
-
node.struct_declarations.each { |
|
|
56
|
-
|
|
55
|
+
node.struct_declarations.each { |dcl| dcl.accept(self) }
|
|
57
56
|
node.type = @type_table.install_struct_type(node)
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
def visit_union_type_declaration(node)
|
|
61
60
|
checkpoint(node.location)
|
|
62
|
-
node.struct_declarations.each { |
|
|
63
|
-
|
|
61
|
+
node.struct_declarations.each { |dcl| dcl.accept(self) }
|
|
64
62
|
node.type = @type_table.install_union_type(node)
|
|
65
63
|
end
|
|
66
64
|
|
|
@@ -73,9 +71,9 @@ module C #:nodoc:
|
|
|
73
71
|
node.specifier_qualifier_list.accept(self)
|
|
74
72
|
node.struct_declarator.accept(self)
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
type = lookup_variable_type(
|
|
74
|
+
type_quals = node.specifier_qualifier_list.type_qualifiers
|
|
75
|
+
type_specs = node.specifier_qualifier_list.type_specifiers
|
|
76
|
+
type = lookup_variable_type(type_quals, type_specs,
|
|
79
77
|
node.struct_declarator.declarator)
|
|
80
78
|
type = @type_table.pointer_type(type) if type.function?
|
|
81
79
|
|
|
@@ -92,18 +90,15 @@ module C #:nodoc:
|
|
|
92
90
|
|
|
93
91
|
def visit_enum_type_declaration(node)
|
|
94
92
|
checkpoint(node.location)
|
|
95
|
-
type = @type_table.install_enum_type(node)
|
|
96
|
-
node.type = type
|
|
97
|
-
node.enumerators.each { |enum| enum.type = type }
|
|
93
|
+
node.type = @type_table.install_enum_type(node)
|
|
94
|
+
node.enumerators.each { |enum| enum.type = node.type }
|
|
98
95
|
end
|
|
99
96
|
|
|
100
97
|
def visit_typedef_declaration(node)
|
|
101
98
|
checkpoint(node.location)
|
|
102
99
|
node.declaration_specifiers.accept(self)
|
|
103
100
|
node.init_declarator.accept(self)
|
|
104
|
-
|
|
105
|
-
type = @type_table.install_user_type(node)
|
|
106
|
-
node.type = type
|
|
101
|
+
node.type = @type_table.install_user_type(node)
|
|
107
102
|
end
|
|
108
103
|
|
|
109
104
|
def visit_function_declaration(node)
|
|
@@ -111,15 +106,15 @@ module C #:nodoc:
|
|
|
111
106
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
112
107
|
node.init_declarator.accept(self)
|
|
113
108
|
|
|
114
|
-
if
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
if dcl_specs = node.declaration_specifiers
|
|
110
|
+
type_quals = dcl_specs.type_qualifiers
|
|
111
|
+
type_specs = dcl_specs.type_specifiers
|
|
117
112
|
else
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
type_quals = []
|
|
114
|
+
type_specs = []
|
|
120
115
|
end
|
|
121
116
|
|
|
122
|
-
node.type = lookup_variable_type(
|
|
117
|
+
node.type = lookup_variable_type(type_quals, type_specs,
|
|
123
118
|
node.init_declarator.declarator)
|
|
124
119
|
end
|
|
125
120
|
|
|
@@ -128,16 +123,15 @@ module C #:nodoc:
|
|
|
128
123
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
129
124
|
node.declarator.accept(self) if node.declarator
|
|
130
125
|
|
|
131
|
-
if
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
if dcl_specs = node.declaration_specifiers
|
|
127
|
+
type_quals = dcl_specs.type_qualifiers
|
|
128
|
+
type_specs = dcl_specs.type_specifiers
|
|
134
129
|
else
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
type_quals = []
|
|
131
|
+
type_specs = []
|
|
137
132
|
end
|
|
138
133
|
|
|
139
|
-
type = lookup_variable_type(
|
|
140
|
-
node.declarator)
|
|
134
|
+
type = lookup_variable_type(type_quals, type_specs, node.declarator)
|
|
141
135
|
|
|
142
136
|
if type.function?
|
|
143
137
|
node.type = @type_table.pointer_type(type)
|
|
@@ -151,16 +145,15 @@ module C #:nodoc:
|
|
|
151
145
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
152
146
|
node.declarator.accept(self)
|
|
153
147
|
|
|
154
|
-
if
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
if dcl_specs = node.declaration_specifiers
|
|
149
|
+
type_quals = dcl_specs.type_qualifiers
|
|
150
|
+
type_specs = dcl_specs.type_specifiers
|
|
157
151
|
else
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
type_quals = []
|
|
153
|
+
type_specs = []
|
|
160
154
|
end
|
|
161
155
|
|
|
162
|
-
type = lookup_variable_type(
|
|
163
|
-
node.declarator)
|
|
156
|
+
type = lookup_variable_type(type_quals, type_specs, node.declarator)
|
|
164
157
|
|
|
165
158
|
if type.function?
|
|
166
159
|
node.type = @type_table.pointer_type(type)
|
|
@@ -174,15 +167,15 @@ module C #:nodoc:
|
|
|
174
167
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
175
168
|
node.init_declarator.accept(self)
|
|
176
169
|
|
|
177
|
-
if
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
if dcl_specs = node.declaration_specifiers
|
|
171
|
+
type_quals = dcl_specs.type_qualifiers
|
|
172
|
+
type_specs = dcl_specs.type_specifiers
|
|
180
173
|
else
|
|
181
|
-
|
|
182
|
-
|
|
174
|
+
type_quals = []
|
|
175
|
+
type_specs = []
|
|
183
176
|
end
|
|
184
177
|
|
|
185
|
-
type = lookup_variable_type(
|
|
178
|
+
type = lookup_variable_type(type_quals, type_specs,
|
|
186
179
|
node.init_declarator.declarator)
|
|
187
180
|
|
|
188
181
|
if type.function?
|
|
@@ -217,9 +210,9 @@ module C #:nodoc:
|
|
|
217
210
|
def visit_type_name(node)
|
|
218
211
|
checkpoint(node.location)
|
|
219
212
|
super
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
node.type = lookup_variable_type(
|
|
213
|
+
type_quals = node.specifier_qualifier_list.type_qualifiers
|
|
214
|
+
type_specs = node.specifier_qualifier_list.type_specifiers
|
|
215
|
+
node.type = lookup_variable_type(type_quals, type_specs,
|
|
223
216
|
node.abstract_declarator)
|
|
224
217
|
end
|
|
225
218
|
|
|
@@ -230,42 +223,37 @@ module C #:nodoc:
|
|
|
230
223
|
end
|
|
231
224
|
|
|
232
225
|
private
|
|
233
|
-
def lookup_variable_type(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
declarator, interpreter)
|
|
237
|
-
type ? type : fallback_type
|
|
226
|
+
def lookup_variable_type(type_quals, type_specs, dcl)
|
|
227
|
+
@type_table.lookup_or_install_type(
|
|
228
|
+
type_quals, type_specs, dcl, interpreter) || fallback_type
|
|
238
229
|
end
|
|
239
230
|
|
|
240
|
-
def lookup_function_type(
|
|
241
|
-
|
|
242
|
-
type ? type : fallback_type
|
|
231
|
+
def lookup_function_type(fun_def)
|
|
232
|
+
@type_table.lookup_function_type(fun_def) || fallback_type
|
|
243
233
|
end
|
|
244
234
|
|
|
245
|
-
def compute_bitfield_width(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return object.value.unique_sample
|
|
235
|
+
def compute_bitfield_width(struct_dcl)
|
|
236
|
+
if expr = struct_dcl.expression
|
|
237
|
+
if interpreter
|
|
238
|
+
obj = interpreter.execute(expr)
|
|
239
|
+
else
|
|
240
|
+
obj = Interpreter.new(@type_table).execute(expr)
|
|
252
241
|
end
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return object.value.unique_sample
|
|
242
|
+
|
|
243
|
+
if obj.variable? && obj.value.scalar?
|
|
244
|
+
return obj.value.unique_sample
|
|
257
245
|
end
|
|
258
246
|
end
|
|
259
|
-
|
|
260
247
|
nil
|
|
261
248
|
end
|
|
249
|
+
|
|
250
|
+
extend Forwardable
|
|
251
|
+
|
|
252
|
+
def_delegator :@type_table, :monitor
|
|
253
|
+
private :monitor
|
|
262
254
|
end
|
|
263
255
|
|
|
264
256
|
class StaticTypeResolver < TypeResolver
|
|
265
|
-
def initialize
|
|
266
|
-
super(TypeTable.new)
|
|
267
|
-
end
|
|
268
|
-
|
|
269
257
|
private
|
|
270
258
|
def interpreter
|
|
271
259
|
nil
|
|
@@ -277,9 +265,9 @@ module C #:nodoc:
|
|
|
277
265
|
end
|
|
278
266
|
|
|
279
267
|
class DynamicTypeResolver < TypeResolver
|
|
280
|
-
def initialize(
|
|
281
|
-
super(
|
|
282
|
-
@interpreter =
|
|
268
|
+
def initialize(type_tbl, interp)
|
|
269
|
+
super(type_tbl)
|
|
270
|
+
@interpreter = interp
|
|
283
271
|
end
|
|
284
272
|
|
|
285
273
|
attr_reader :interpreter
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Scanner for C language.
|
|
2
2
|
#
|
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
6
|
#
|
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
15
|
#
|
|
16
16
|
# This file is part of AdLint.
|
|
17
17
|
#
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
#++
|
|
31
31
|
|
|
32
32
|
module AdLint #:nodoc:
|
|
33
|
-
module
|
|
33
|
+
module Cc1 #:nodoc:
|
|
34
34
|
|
|
35
35
|
# == DESCRIPTION
|
|
36
36
|
# Constants for scanning the C source code.
|
|
@@ -101,12 +101,12 @@ module C #:nodoc:
|
|
|
101
101
|
# Scans C identifier.
|
|
102
102
|
#
|
|
103
103
|
# === PARAMETER
|
|
104
|
-
#
|
|
104
|
+
# _cont_:: StringContent -- Scanning source.
|
|
105
105
|
#
|
|
106
106
|
# === RETURN VALUE
|
|
107
107
|
# String -- Returns C identifier string if found at head of the content.
|
|
108
|
-
def scan_identifier(
|
|
109
|
-
|
|
108
|
+
def scan_identifier(cont)
|
|
109
|
+
cont.scan(/[a-z_][a-z_0-9]*\b/i)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
KEYWORDS_RE = Regexp.new(KEYWORD_VALUES.map { |keyword|
|
|
@@ -118,16 +118,16 @@ module C #:nodoc:
|
|
|
118
118
|
# Scans C keyword.
|
|
119
119
|
#
|
|
120
120
|
# === PARAMETER
|
|
121
|
-
#
|
|
121
|
+
# _cont_:: StringContent -- Scanning source.
|
|
122
122
|
#
|
|
123
123
|
# === RETURN VALUE
|
|
124
124
|
# String -- Returns C keyword string if found at head of the content.
|
|
125
|
-
def scan_keyword(
|
|
126
|
-
|
|
125
|
+
def scan_keyword(cont)
|
|
126
|
+
cont.scan(KEYWORDS_RE)
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
PUNCTUATORS_RE = Regexp.new(PUNCTUATORS.sort { |
|
|
130
|
-
|
|
129
|
+
PUNCTUATORS_RE = Regexp.new(PUNCTUATORS.sort { |a, b|
|
|
130
|
+
b.length <=> a.length
|
|
131
131
|
}.map { |punct|
|
|
132
132
|
punct.each_char.map { |ch| '\\' + ch }.join
|
|
133
133
|
}.join("|")).freeze
|
|
@@ -137,63 +137,68 @@ module C #:nodoc:
|
|
|
137
137
|
# Scans C punctuator.
|
|
138
138
|
#
|
|
139
139
|
# === PARAMETER
|
|
140
|
-
#
|
|
140
|
+
# _cont_:: StringContent -- Scanning source.
|
|
141
141
|
#
|
|
142
142
|
# === RETURN VALUE
|
|
143
143
|
# String -- Returns C punctuator string if found at head of the content.
|
|
144
|
-
def scan_punctuator(
|
|
145
|
-
|
|
144
|
+
def scan_punctuator(cont)
|
|
145
|
+
cont.scan(PUNCTUATORS_RE)
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
# === DESCRIPTION
|
|
149
149
|
# Scans C integer constant.
|
|
150
150
|
#
|
|
151
151
|
# === PARAMETER
|
|
152
|
-
#
|
|
152
|
+
# _cont_:: StringContent -- Scanning source.
|
|
153
153
|
#
|
|
154
154
|
# === RETURN VALUE
|
|
155
155
|
# String -- Returns C integer constant string if found at head of the
|
|
156
156
|
# content.
|
|
157
|
-
def scan_integer_constant(
|
|
158
|
-
|
|
157
|
+
def scan_integer_constant(cont)
|
|
158
|
+
cont.scan(/(?:0x[0-9a-f]+|0b[01]+|[0-9]+)[UL]*/i)
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
+
FLOATING1_RE = /(?:[0-9]*\.[0-9]*E[+-]?[0-9]+|[0-9]+\.?E[+-]?[0-9]+)[FL]*/i
|
|
162
|
+
FLOATING2_RE = /(?:[0-9]*\.[0-9]+|[0-9]+\.)[FL]*/i
|
|
163
|
+
private_constant :FLOATING1_RE, :FLOATING2_RE
|
|
164
|
+
|
|
161
165
|
# === DESCRIPTION
|
|
162
166
|
# Scans C floating constant.
|
|
163
167
|
#
|
|
164
168
|
# === PARAMETER
|
|
165
|
-
#
|
|
169
|
+
# _cont_:: StringContent -- Scanning source.
|
|
166
170
|
#
|
|
167
171
|
# === RETURN VALUE
|
|
168
172
|
# String -- Returns C floating constant string if found at head of the
|
|
169
173
|
# content.
|
|
170
|
-
def scan_floating_constant(
|
|
171
|
-
|
|
172
|
-
/(?:[0-9]*\.[0-9]*E[+-]?[0-9]+|[0-9]+\.?E[+-]?[0-9]+)[FL]*/i) ||
|
|
173
|
-
content.scan(/(?:[0-9]*\.[0-9]+|[0-9]+\.)[FL]*/i)
|
|
174
|
+
def scan_floating_constant(cont)
|
|
175
|
+
cont.scan(FLOATING1_RE) || cont.scan(FLOATING2_RE)
|
|
174
176
|
end
|
|
175
177
|
|
|
176
178
|
# === DESCRIPTION
|
|
177
179
|
# Scans C character constant.
|
|
178
180
|
#
|
|
179
181
|
# === PARAMETER
|
|
180
|
-
#
|
|
182
|
+
# _cont_:: StringContent -- Scanning source.
|
|
181
183
|
#
|
|
182
184
|
# === RETURN VALUE
|
|
183
185
|
# String -- Returns C character constant string if found at head of the
|
|
184
186
|
# content.
|
|
185
|
-
def scan_char_constant(
|
|
186
|
-
scanned =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
def scan_char_constant(cont)
|
|
188
|
+
unless scanned = cont.scan(/L?'/i)
|
|
189
|
+
return nil
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
until cont.empty?
|
|
193
|
+
if str = cont.scan(/.*?(?=\\|')/m)
|
|
194
|
+
scanned << str
|
|
195
|
+
end
|
|
196
|
+
next if cont.scan(/\\[ \t]*\n/)
|
|
197
|
+
|
|
193
198
|
case
|
|
194
|
-
when
|
|
195
|
-
scanned <<
|
|
196
|
-
when quote =
|
|
199
|
+
when cont.check(/\\/)
|
|
200
|
+
scanned << cont.eat!(2)
|
|
201
|
+
when quote = cont.scan(/'/)
|
|
197
202
|
scanned << quote
|
|
198
203
|
break
|
|
199
204
|
end
|
|
@@ -206,23 +211,26 @@ module C #:nodoc:
|
|
|
206
211
|
# Scans C string literal.
|
|
207
212
|
#
|
|
208
213
|
# === PARAMETER
|
|
209
|
-
#
|
|
214
|
+
# _cont_:: StringContent -- Scanning source.
|
|
210
215
|
#
|
|
211
216
|
# === RETURN VALUE
|
|
212
217
|
# String -- Returns C string literal string if found at head of the
|
|
213
218
|
# content.
|
|
214
|
-
def scan_string_literal(
|
|
215
|
-
scanned =
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
def scan_string_literal(cont)
|
|
220
|
+
unless scanned = cont.scan(/L?"/i)
|
|
221
|
+
return nil
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
until cont.empty?
|
|
225
|
+
if str = cont.scan(/.*?(?=\\|")/m)
|
|
226
|
+
scanned << str
|
|
227
|
+
end
|
|
228
|
+
next if cont.scan(/\\[ \t]*\n/)
|
|
229
|
+
|
|
222
230
|
case
|
|
223
|
-
when
|
|
224
|
-
scanned <<
|
|
225
|
-
when quote =
|
|
231
|
+
when cont.check(/\\/)
|
|
232
|
+
scanned << cont.eat!(2)
|
|
233
|
+
when quote = cont.scan(/"/)
|
|
226
234
|
scanned << quote
|
|
227
235
|
break
|
|
228
236
|
end
|
|
@@ -235,12 +243,12 @@ module C #:nodoc:
|
|
|
235
243
|
# Scans C NULL constant.
|
|
236
244
|
#
|
|
237
245
|
# === PARAMETER
|
|
238
|
-
#
|
|
246
|
+
# _cont_:: StringContent -- Scanning source.
|
|
239
247
|
#
|
|
240
248
|
# === RETURN VALUE
|
|
241
249
|
# String -- Returns C NULL constant string if found at head of the content.
|
|
242
|
-
def scan_null_constant(
|
|
243
|
-
|
|
250
|
+
def scan_null_constant(cont)
|
|
251
|
+
cont.scan(/NULL\b/)
|
|
244
252
|
end
|
|
245
253
|
end
|
|
246
254
|
|