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
data/lib/adlint/cpp/phase.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Analysis phases for C preprocessor 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,6 +30,7 @@
|
|
30
30
|
#++
|
31
31
|
|
32
32
|
require "adlint/phase"
|
33
|
+
require "adlint/annot"
|
33
34
|
require "adlint/cpp/lexer"
|
34
35
|
require "adlint/cpp/eval"
|
35
36
|
require "adlint/cpp/util"
|
@@ -38,28 +39,46 @@ module AdLint #:nodoc:
|
|
38
39
|
module Cpp #:nodoc:
|
39
40
|
|
40
41
|
class CppPhase < Phase
|
41
|
-
def initialize(
|
42
|
-
super(
|
42
|
+
def initialize(phase_ctxt, phase_name)
|
43
|
+
super(phase_ctxt, "cpp", phase_name)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
class Prepare1Phase < CppPhase
|
47
|
-
def initialize(
|
48
|
-
super(
|
48
|
+
def initialize(phase_ctxt)
|
49
|
+
super(phase_ctxt, "pr1")
|
49
50
|
end
|
50
51
|
|
51
52
|
private
|
52
|
-
def do_execute(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
def do_execute(phase_ctxt, *)
|
54
|
+
root_src = phase_ctxt[:sources].first
|
55
|
+
phase_ctxt[:cc1_source] = PreprocessedSource.new(root_src)
|
56
|
+
phase_ctxt[:cpp_macro_table] = MacroTable.new
|
57
|
+
phase_ctxt[:cpp_interpreter] = Preprocessor.new
|
58
|
+
phase_ctxt[:cpp_visitor] = SyntaxTreeMulticastVisitor.new
|
59
|
+
register_annotation_parser
|
60
|
+
end
|
61
|
+
|
62
|
+
def register_annotation_parser
|
63
|
+
parser = method(:parse_annotation)
|
64
|
+
@phase_ctxt[:cpp_interpreter].on_line_comment_found += parser
|
65
|
+
@phase_ctxt[:cpp_interpreter].on_block_comment_found += parser
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse_annotation(comment, loc)
|
69
|
+
if annot = Annotation.parse(comment, loc)
|
70
|
+
@phase_ctxt[:annotations].push(annot)
|
71
|
+
if annot.message_suppression_specifier? &&
|
72
|
+
traits.of_message.individual_suppression
|
73
|
+
@phase_ctxt[:suppressors].add(annot.create_suppressor)
|
74
|
+
end
|
75
|
+
end
|
57
76
|
end
|
58
77
|
end
|
59
78
|
|
60
79
|
class Prepare2Phase < CppPhase
|
61
|
-
def initialize(
|
62
|
-
super(
|
80
|
+
def initialize(phase_ctxt)
|
81
|
+
super(phase_ctxt, "pr2")
|
63
82
|
end
|
64
83
|
|
65
84
|
private
|
@@ -67,74 +86,76 @@ module Cpp #:nodoc:
|
|
67
86
|
end
|
68
87
|
|
69
88
|
class EvalPhase < CppPhase
|
70
|
-
def initialize(
|
71
|
-
super(
|
89
|
+
def initialize(phase_ctxt)
|
90
|
+
super(phase_ctxt, "cpp")
|
72
91
|
end
|
73
92
|
|
74
93
|
private
|
75
|
-
def do_execute(
|
76
|
-
|
77
|
-
process_cinit_header(
|
78
|
-
process_pinit_header(
|
79
|
-
process_target_source(
|
94
|
+
def do_execute(phase_ctxt, *)
|
95
|
+
pp_ctxt = PreprocessContext.new(phase_ctxt)
|
96
|
+
process_cinit_header(phase_ctxt, pp_ctxt)
|
97
|
+
process_pinit_header(phase_ctxt, pp_ctxt)
|
98
|
+
process_target_source(phase_ctxt, pp_ctxt)
|
80
99
|
end
|
81
100
|
|
82
|
-
def process_cinit_header(
|
83
|
-
if fpath =
|
84
|
-
|
101
|
+
def process_cinit_header(phase_ctxt, pp_ctxt)
|
102
|
+
if fpath = traits.of_compiler.initial_header
|
103
|
+
fenc = traits.of_project.file_encoding
|
104
|
+
init_header = Source.new(Pathname.new(fpath), fenc)
|
85
105
|
else
|
86
106
|
init_header = EmptySource.new
|
87
107
|
end
|
88
|
-
|
89
|
-
|
108
|
+
phase_ctxt[:cpp_syntax_tree] =
|
109
|
+
phase_ctxt[:cpp_interpreter].execute(pp_ctxt, init_header)
|
90
110
|
end
|
91
111
|
|
92
|
-
def process_pinit_header(
|
93
|
-
if fpath =
|
94
|
-
|
112
|
+
def process_pinit_header(phase_ctxt, pp_ctxt)
|
113
|
+
if fpath = traits.of_project.initial_header
|
114
|
+
fenc = traits.of_project.file_encoding
|
115
|
+
init_header = Source.new(Pathname.new(fpath), fenc)
|
95
116
|
else
|
96
117
|
init_header = EmptySource.new
|
97
118
|
end
|
98
|
-
|
99
|
-
|
119
|
+
phase_ctxt[:cpp_syntax_tree].concat(
|
120
|
+
phase_ctxt[:cpp_interpreter].execute(pp_ctxt, init_header))
|
100
121
|
end
|
101
122
|
|
102
|
-
def process_target_source(
|
103
|
-
|
104
|
-
|
105
|
-
|
123
|
+
def process_target_source(phase_ctxt, pp_ctxt)
|
124
|
+
root_src = phase_ctxt[:sources].first
|
125
|
+
phase_ctxt[:cpp_syntax_tree].concat(
|
126
|
+
phase_ctxt[:cpp_interpreter].execute(pp_ctxt, root_src))
|
106
127
|
end
|
107
128
|
end
|
108
129
|
|
109
130
|
class SubstPhase < CppPhase
|
110
|
-
def initialize(
|
111
|
-
super(
|
131
|
+
def initialize(phase_ctxt)
|
132
|
+
super(phase_ctxt, "sub")
|
112
133
|
end
|
113
134
|
|
114
135
|
private
|
115
|
-
def do_execute(
|
116
|
-
|
136
|
+
def do_execute(phase_ctxt, *)
|
137
|
+
phase_ctxt[:cc1_source].substitute_code_blocks(traits)
|
117
138
|
end
|
118
139
|
end
|
119
140
|
|
120
141
|
class ReviewPhase < CppPhase
|
121
|
-
def initialize(
|
122
|
-
super(
|
142
|
+
def initialize(phase_ctxt)
|
143
|
+
super(phase_ctxt, "rv1")
|
123
144
|
end
|
124
145
|
|
125
146
|
private
|
126
|
-
def do_execute(
|
127
|
-
|
147
|
+
def do_execute(phase_ctxt, *)
|
148
|
+
phase_ctxt[:cpp_syntax_tree].accept(phase_ctxt[:cpp_visitor])
|
128
149
|
end
|
129
150
|
end
|
130
151
|
|
131
152
|
class ExaminationPhase < CppPhase
|
132
|
-
def initialize(
|
133
|
-
super(
|
153
|
+
def initialize(phase_ctxt)
|
154
|
+
super(phase_ctxt, "ex1")
|
134
155
|
end
|
135
156
|
|
136
157
|
private
|
137
|
-
def do_execute(
|
158
|
+
def do_execute(phase_ctxt, *)
|
138
159
|
examinations.each { |exam| exam.execute }
|
139
160
|
end
|
140
161
|
end
|
data/lib/adlint/cpp/scanner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Scanner for C preprocessor 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
|
#
|
@@ -39,53 +39,50 @@ module Cpp #:nodoc:
|
|
39
39
|
# Scans CPP keyword.
|
40
40
|
#
|
41
41
|
# === PARAMETER
|
42
|
-
#
|
42
|
+
# _cont_:: StringContent -- Scanning source.
|
43
43
|
#
|
44
44
|
# === RETURN VALUE
|
45
45
|
# String -- Returns CPP keyword string if found at head of the content.
|
46
|
-
def scan_keyword(
|
47
|
-
|
46
|
+
def scan_keyword(cont)
|
47
|
+
cont.scan(/defined\b/)
|
48
48
|
end
|
49
49
|
|
50
50
|
# === DESCRIPTION
|
51
51
|
# Scans CPP punctuator.
|
52
52
|
#
|
53
53
|
# === PARAMETER
|
54
|
-
#
|
54
|
+
# _cont_:: StringContent -- Scanning source.
|
55
55
|
#
|
56
56
|
# === RETURN VALUE
|
57
57
|
# String -- Returns CPP punctuator string if found at head of the content.
|
58
|
-
def scan_punctuator(
|
59
|
-
|
60
|
-
return punctuator
|
61
|
-
end
|
62
|
-
content.scan(/##?/)
|
58
|
+
def scan_punctuator(cont)
|
59
|
+
Language::C.scan_punctuator(cont) or cont.scan(/##?/)
|
63
60
|
end
|
64
61
|
|
65
62
|
# === DESCRIPTION
|
66
63
|
# Scans CPP user header name.
|
67
64
|
#
|
68
65
|
# === PARAMETER
|
69
|
-
#
|
66
|
+
# _cont_:: StringContent -- Scanning source.
|
70
67
|
#
|
71
68
|
# === RETURN VALUE
|
72
69
|
# String -- Returns CPP user header name string if found at head of the
|
73
70
|
# content.
|
74
|
-
def scan_user_header_name(
|
75
|
-
|
71
|
+
def scan_user_header_name(cont)
|
72
|
+
cont.scan(/"[^"]*"/)
|
76
73
|
end
|
77
74
|
|
78
75
|
# === DESCRIPTION
|
79
76
|
# Scans CPP system header name.
|
80
77
|
#
|
81
78
|
# === PARAMETER
|
82
|
-
#
|
79
|
+
# _cont_:: StringContent -- Scanning source.
|
83
80
|
#
|
84
81
|
# === RETURN VALUE
|
85
82
|
# String -- Returns CPP system header name string if found at head of the
|
86
83
|
# content.
|
87
|
-
def scan_system_header_name(
|
88
|
-
|
84
|
+
def scan_system_header_name(cont)
|
85
|
+
cont.scan(/<[^>]*>/)
|
89
86
|
end
|
90
87
|
end
|
91
88
|
|
data/lib/adlint/cpp/source.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Preprocessed pure C language source.
|
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
|
#
|
@@ -29,7 +29,6 @@
|
|
29
29
|
#
|
30
30
|
#++
|
31
31
|
|
32
|
-
require "adlint/token"
|
33
32
|
require "adlint/util"
|
34
33
|
require "adlint/cpp/asm"
|
35
34
|
require "adlint/cpp/subst"
|
@@ -52,99 +51,95 @@ module Cpp #:nodoc:
|
|
52
51
|
|
53
52
|
attr_reader :root_fpath
|
54
53
|
|
55
|
-
def add_token(
|
56
|
-
@tokens.push(
|
54
|
+
def add_token(tok)
|
55
|
+
@tokens.push(tok)
|
57
56
|
end
|
58
57
|
|
59
58
|
def pp_tokens
|
60
|
-
@tokens.select { |
|
59
|
+
@tokens.select { |tok| tok.type == :PP_TOKEN }
|
61
60
|
end
|
62
61
|
|
63
|
-
def substitute_code_blocks
|
64
|
-
|
65
|
-
|
66
|
-
substitution = create_extension_substitution(pattern, replacement)
|
67
|
-
@tokens = substitution.execute(@tokens)
|
62
|
+
def substitute_code_blocks(traits)
|
63
|
+
traits.of_compiler.extension_substitutions.each do |ptn, repl|
|
64
|
+
@tokens = create_extension_substitution(ptn, repl).execute(@tokens)
|
68
65
|
end
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
substitution = create_arbitrary_substitution(pattern, replacement)
|
73
|
-
@tokens = substitution.execute(@tokens)
|
67
|
+
traits.of_compiler.arbitrary_substitutions.each do |ptn, repl|
|
68
|
+
@tokens = create_arbitrary_substitution(ptn, repl).execute(@tokens)
|
74
69
|
end
|
75
70
|
|
76
|
-
create_inline_assembly_substitutions(self).each do |
|
77
|
-
@tokens =
|
71
|
+
create_inline_assembly_substitutions(self).each do |sub|
|
72
|
+
@tokens = sub.execute(@tokens)
|
78
73
|
end
|
79
74
|
|
80
75
|
self
|
81
76
|
end
|
82
77
|
|
83
78
|
def to_s
|
79
|
+
@last_fpath = nil
|
80
|
+
@last_line_no = 0
|
81
|
+
@last_column_no = 1
|
82
|
+
@last_token = nil
|
84
83
|
@io = StringIO.new
|
85
84
|
@io.set_encoding(Encoding.default_external)
|
86
|
-
@
|
87
|
-
@last_line_no = 0
|
88
|
-
@last_column_no = 1
|
89
|
-
@last_token = nil
|
90
|
-
@tokens.each { |token| print(token) }
|
85
|
+
@tokens.each { |tok| print(tok) }
|
91
86
|
@io.string
|
92
87
|
end
|
93
88
|
|
94
89
|
private
|
95
|
-
def create_extension_substitution(
|
96
|
-
CodeSubstitution.new(
|
97
|
-
|
98
|
-
on_language_extension.invoke(
|
90
|
+
def create_extension_substitution(ptn, repl)
|
91
|
+
CodeSubstitution.new(ptn, repl).tap do |sub|
|
92
|
+
sub.on_substitution += lambda { |matched_toks|
|
93
|
+
on_language_extension.invoke(matched_toks)
|
99
94
|
}
|
100
95
|
end
|
101
96
|
end
|
102
97
|
|
103
|
-
def create_arbitrary_substitution(
|
104
|
-
CodeSubstitution.new(
|
98
|
+
def create_arbitrary_substitution(ptn, repl)
|
99
|
+
CodeSubstitution.new(ptn, repl)
|
105
100
|
end
|
106
101
|
|
107
|
-
def print(
|
108
|
-
return if @last_column_no == 1 &&
|
102
|
+
def print(tok)
|
103
|
+
return if @last_column_no == 1 && tok.type == :NEW_LINE
|
109
104
|
|
110
|
-
if
|
111
|
-
if @last_line_no <
|
112
|
-
if (
|
113
|
-
insert_line_marker(
|
105
|
+
if tok.location.fpath == @last_fpath
|
106
|
+
if @last_line_no < tok.location.line_no
|
107
|
+
if (vsp = tok.location.line_no - @last_line_no) > 3
|
108
|
+
insert_line_marker(tok)
|
114
109
|
else
|
115
|
-
|
110
|
+
vsp.times { @io.puts }
|
116
111
|
end
|
117
112
|
end
|
118
|
-
if (
|
119
|
-
@io.print(" " *
|
120
|
-
elsif need_hspace?(
|
113
|
+
if (hsp = tok.location.appearance_column_no - @last_column_no) > 0
|
114
|
+
@io.print(" " * hsp)
|
115
|
+
elsif need_hspace?(tok)
|
121
116
|
@io.print(" ")
|
122
117
|
end
|
123
|
-
if
|
118
|
+
if tok.type == :NEW_LINE
|
124
119
|
@io.puts
|
125
|
-
@last_line_no =
|
120
|
+
@last_line_no = tok.location.line_no + 1
|
126
121
|
@last_column_no = 1
|
127
122
|
else
|
128
|
-
@io.print(
|
129
|
-
@last_line_no =
|
123
|
+
@io.print(tok.value.to_default_external)
|
124
|
+
@last_line_no = tok.location.line_no
|
130
125
|
@last_column_no =
|
131
|
-
|
126
|
+
tok.location.appearance_column_no + tok.value.length
|
132
127
|
end
|
133
128
|
else
|
134
|
-
insert_line_marker(
|
135
|
-
print(
|
129
|
+
insert_line_marker(tok)
|
130
|
+
print(tok)
|
136
131
|
end
|
137
132
|
|
138
|
-
@last_token =
|
133
|
+
@last_token = tok
|
139
134
|
end
|
140
135
|
|
141
|
-
def need_hspace?(
|
136
|
+
def need_hspace?(tok)
|
142
137
|
return false unless @last_token
|
143
138
|
if keyword_or_identifier?(@last_token.value)
|
144
|
-
!start_with_punctuator?(
|
139
|
+
!start_with_punctuator?(tok.value)
|
145
140
|
else
|
146
141
|
!(end_with_punctuator?(@last_token.value) ||
|
147
|
-
start_with_punctuator?(
|
142
|
+
start_with_punctuator?(tok.value))
|
148
143
|
end
|
149
144
|
end
|
150
145
|
|
@@ -160,16 +155,15 @@ module Cpp #:nodoc:
|
|
160
155
|
str =~ /\A[a-z_][a-z_0-9]*\z/i
|
161
156
|
end
|
162
157
|
|
163
|
-
def insert_line_marker(
|
158
|
+
def insert_line_marker(tok)
|
164
159
|
if @last_column_no > 1
|
165
160
|
@io.puts
|
166
161
|
end
|
167
|
-
line_marker =
|
168
|
-
|
169
|
-
"\"#{token.location.fpath.to_s.to_default_external}\""
|
162
|
+
line_marker = "# #{tok.location.line_no.to_s.to_default_external} " +
|
163
|
+
"\"#{tok.location.fpath.to_s.to_default_external}\""
|
170
164
|
@io.puts(line_marker.to_default_external)
|
171
|
-
@last_fpath
|
172
|
-
@last_line_no
|
165
|
+
@last_fpath = tok.location.fpath
|
166
|
+
@last_line_no = tok.location.line_no
|
173
167
|
@last_column_no = 1
|
174
168
|
end
|
175
169
|
end
|