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
data/lib/adlint/cpp/macro.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# C preprocessor macros.
|
|
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,6 +39,8 @@ module AdLint #:nodoc:
|
|
|
39
39
|
module Cpp #:nodoc:
|
|
40
40
|
|
|
41
41
|
class Macro
|
|
42
|
+
include LocationHolder
|
|
43
|
+
|
|
42
44
|
def initialize(define_line)
|
|
43
45
|
@define_line = define_line
|
|
44
46
|
end
|
|
@@ -57,8 +59,8 @@ module Cpp #:nodoc:
|
|
|
57
59
|
@define_line.location
|
|
58
60
|
end
|
|
59
61
|
|
|
60
|
-
def expand(
|
|
61
|
-
@define_line.mark_as_referred_by(
|
|
62
|
+
def expand(toks, macro_tbl, repl_ctxt)
|
|
63
|
+
@define_line.mark_as_referred_by(toks.first)
|
|
62
64
|
end
|
|
63
65
|
|
|
64
66
|
def function_like?
|
|
@@ -67,28 +69,28 @@ module Cpp #:nodoc:
|
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
class ObjectLikeMacro < Macro
|
|
70
|
-
def replaceable_size(
|
|
71
|
-
if
|
|
72
|
+
def replaceable_size(toks)
|
|
73
|
+
if toks.first.value == "NULL" then
|
|
72
74
|
0
|
|
73
75
|
else
|
|
74
|
-
name.value ==
|
|
76
|
+
name.value == toks.first.value ? 1 : 0
|
|
75
77
|
end
|
|
76
78
|
end
|
|
77
79
|
|
|
78
|
-
def expand(
|
|
80
|
+
def expand(toks, macro_tbl, repl_ctxt)
|
|
79
81
|
super
|
|
80
82
|
|
|
81
|
-
if replacement_list
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ReplacedToken.new(
|
|
83
|
+
if repl_list = self.replacement_list
|
|
84
|
+
loc = toks.first.location
|
|
85
|
+
res_toks = repl_list.tokens.map { |tok|
|
|
86
|
+
ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, false)
|
|
85
87
|
}
|
|
86
88
|
else
|
|
87
|
-
|
|
89
|
+
res_toks = []
|
|
88
90
|
end
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
macro_tbl.notify_object_like_macro_replacement(self, toks, res_toks)
|
|
93
|
+
res_toks
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
def function_like?; false end
|
|
@@ -98,7 +100,7 @@ module Cpp #:nodoc:
|
|
|
98
100
|
def initialize(define_line)
|
|
99
101
|
super
|
|
100
102
|
if params = define_line.identifier_list
|
|
101
|
-
@parameter_names = params.identifiers.map { |
|
|
103
|
+
@parameter_names = params.identifiers.map { |tok| tok.value }
|
|
102
104
|
else
|
|
103
105
|
@parameter_names = []
|
|
104
106
|
end
|
|
@@ -106,137 +108,137 @@ module Cpp #:nodoc:
|
|
|
106
108
|
|
|
107
109
|
attr_reader :parameter_names
|
|
108
110
|
|
|
109
|
-
def replaceable_size(
|
|
110
|
-
return 0 unless name.value ==
|
|
111
|
-
args,
|
|
111
|
+
def replaceable_size(toks)
|
|
112
|
+
return 0 unless name.value == toks.first.value
|
|
113
|
+
args, idx = parse_arguments(toks, 1)
|
|
112
114
|
case
|
|
113
115
|
when args && @parameter_names.empty?
|
|
114
|
-
|
|
116
|
+
idx + 1
|
|
115
117
|
when args && @parameter_names.size >= args.size
|
|
116
|
-
|
|
118
|
+
idx + 1
|
|
117
119
|
else
|
|
118
120
|
0
|
|
119
121
|
end
|
|
120
122
|
end
|
|
121
123
|
|
|
122
|
-
def expand(
|
|
124
|
+
def expand(toks, macro_tbl, repl_ctxt)
|
|
123
125
|
super
|
|
124
126
|
|
|
125
|
-
args, * = parse_arguments(
|
|
127
|
+
args, * = parse_arguments(toks, 1)
|
|
126
128
|
args = [] if @parameter_names.empty?
|
|
127
129
|
args_hash =
|
|
128
|
-
@parameter_names.zip(args).each_with_object({}) { |(
|
|
129
|
-
hash[
|
|
130
|
+
@parameter_names.zip(args).each_with_object({}) { |(param, arg), hash|
|
|
131
|
+
hash[param] = arg
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
res_toks = expand_replacement_list(args_hash, toks.first.location,
|
|
135
|
+
macro_tbl, repl_ctxt)
|
|
136
|
+
macro_tbl.notify_function_like_macro_replacement(self, toks, args,
|
|
137
|
+
res_toks)
|
|
138
|
+
res_toks
|
|
137
139
|
end
|
|
138
140
|
|
|
139
141
|
def function_like?; true end
|
|
140
142
|
|
|
141
143
|
private
|
|
142
|
-
def parse_arguments(
|
|
143
|
-
while
|
|
144
|
+
def parse_arguments(toks, idx)
|
|
145
|
+
while tok = toks[idx]
|
|
144
146
|
case
|
|
145
|
-
when
|
|
146
|
-
|
|
147
|
-
when
|
|
148
|
-
|
|
147
|
+
when tok.type == :NEW_LINE
|
|
148
|
+
idx += 1
|
|
149
|
+
when tok.value == "("
|
|
150
|
+
idx += 1
|
|
149
151
|
break
|
|
150
152
|
else
|
|
151
|
-
return nil,
|
|
153
|
+
return nil, idx
|
|
152
154
|
end
|
|
153
155
|
end
|
|
154
|
-
return nil,
|
|
156
|
+
return nil, idx unless tok
|
|
155
157
|
|
|
156
158
|
args = []
|
|
157
159
|
loop do
|
|
158
|
-
arg,
|
|
160
|
+
arg, idx, lst = parse_one_argument(toks, idx)
|
|
159
161
|
args.push(arg)
|
|
160
|
-
break if
|
|
162
|
+
break if lst
|
|
161
163
|
end
|
|
162
|
-
return args,
|
|
164
|
+
return args, idx
|
|
163
165
|
end
|
|
164
166
|
|
|
165
|
-
def parse_one_argument(
|
|
167
|
+
def parse_one_argument(toks, idx)
|
|
166
168
|
arg = []
|
|
167
169
|
paren_depth = 0
|
|
168
|
-
while
|
|
169
|
-
case
|
|
170
|
+
while tok = toks[idx]
|
|
171
|
+
case tok.value
|
|
170
172
|
when "("
|
|
171
|
-
arg.push(
|
|
173
|
+
arg.push(tok)
|
|
172
174
|
paren_depth += 1
|
|
173
175
|
when ")"
|
|
174
176
|
paren_depth -= 1
|
|
175
177
|
if paren_depth >= 0
|
|
176
|
-
arg.push(
|
|
178
|
+
arg.push(tok)
|
|
177
179
|
else
|
|
178
|
-
return arg,
|
|
180
|
+
return arg, idx, true
|
|
179
181
|
end
|
|
180
182
|
when ","
|
|
181
183
|
if paren_depth > 0
|
|
182
|
-
arg.push(
|
|
184
|
+
arg.push(tok)
|
|
183
185
|
else
|
|
184
|
-
return arg,
|
|
186
|
+
return arg, idx + 1, false
|
|
185
187
|
end
|
|
186
188
|
when "\n"
|
|
187
189
|
;
|
|
188
190
|
else
|
|
189
|
-
arg.push(
|
|
191
|
+
arg.push(tok)
|
|
190
192
|
end
|
|
191
|
-
|
|
193
|
+
idx += 1
|
|
192
194
|
end
|
|
193
|
-
return arg,
|
|
195
|
+
return arg, idx, true # NOTREACHED
|
|
194
196
|
end
|
|
195
197
|
|
|
196
|
-
def expand_replacement_list(args,
|
|
197
|
-
|
|
198
|
+
def expand_replacement_list(args, loc, macro_tbl, repl_ctxt)
|
|
199
|
+
unless repl_list = self.replacement_list
|
|
200
|
+
return []
|
|
201
|
+
end
|
|
198
202
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
while
|
|
202
|
-
|
|
203
|
+
res_toks = []
|
|
204
|
+
idx = 0
|
|
205
|
+
while cur_tok = repl_list.tokens[idx]
|
|
206
|
+
nxt_tok = repl_list.tokens[idx + 1]
|
|
203
207
|
|
|
204
208
|
case
|
|
205
|
-
when arg = args[
|
|
206
|
-
substitute_argument(
|
|
207
|
-
|
|
208
|
-
when
|
|
209
|
-
if
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
index += 1
|
|
209
|
+
when arg = args[cur_tok.value]
|
|
210
|
+
substitute_argument(cur_tok, nxt_tok, arg, loc, res_toks, macro_tbl,
|
|
211
|
+
repl_ctxt)
|
|
212
|
+
when cur_tok.value == "#"
|
|
213
|
+
if nxt_tok
|
|
214
|
+
tok = stringize_argument(args[nxt_tok.value], loc, macro_tbl)
|
|
215
|
+
res_toks.push(tok)
|
|
216
|
+
idx += 1
|
|
214
217
|
end
|
|
215
|
-
when
|
|
216
|
-
if
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
index += 2
|
|
218
|
+
when cur_tok.value == "##" && nxt_tok.value == "#"
|
|
219
|
+
if nxt_nxt_tok = repl_list.tokens[idx + 2]
|
|
220
|
+
tok = stringize_argument(args[nxt_nxt_tok.value], loc, macro_tbl)
|
|
221
|
+
concat_with_last_token([tok], loc, res_toks, macro_tbl)
|
|
222
|
+
idx += 2
|
|
221
223
|
end
|
|
222
|
-
when
|
|
223
|
-
if
|
|
224
|
-
concat_with_last_token(arg,
|
|
224
|
+
when cur_tok.value == "##"
|
|
225
|
+
if nxt_tok and arg = args[nxt_tok.value]
|
|
226
|
+
concat_with_last_token(arg, loc, res_toks, macro_tbl)
|
|
225
227
|
else
|
|
226
|
-
concat_with_last_token([
|
|
228
|
+
concat_with_last_token([nxt_tok], loc, res_toks, macro_tbl)
|
|
227
229
|
end
|
|
228
|
-
|
|
230
|
+
idx += 1
|
|
229
231
|
else
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
res_toks.push(ReplacedToken.new(cur_tok.type, cur_tok.value, loc,
|
|
233
|
+
cur_tok.type_hint, false))
|
|
232
234
|
end
|
|
233
|
-
|
|
235
|
+
idx += 1
|
|
234
236
|
end
|
|
235
|
-
|
|
237
|
+
res_toks
|
|
236
238
|
end
|
|
237
239
|
|
|
238
|
-
def substitute_argument(
|
|
239
|
-
|
|
240
|
+
def substitute_argument(param_tok, nxt_tok, arg, loc, res_toks, macro_tbl,
|
|
241
|
+
repl_ctxt)
|
|
240
242
|
# NOTE: The ISO C99 standard says;
|
|
241
243
|
#
|
|
242
244
|
# 6.10.3.1 Argument substitution
|
|
@@ -250,19 +252,19 @@ module Cpp #:nodoc:
|
|
|
250
252
|
# tokens are completely macro replaced as if they formed the rest of
|
|
251
253
|
# the preprocessing file; no other preprocessing tokens are available.
|
|
252
254
|
|
|
253
|
-
if
|
|
254
|
-
|
|
255
|
-
ReplacedToken.new(
|
|
255
|
+
if nxt_tok && nxt_tok.value == "##"
|
|
256
|
+
res_toks.concat(arg.map { |tok|
|
|
257
|
+
ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, false)
|
|
256
258
|
})
|
|
257
259
|
else
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
ReplacedToken.new(
|
|
260
|
+
macro_tbl.replace(arg, repl_ctxt)
|
|
261
|
+
res_toks.concat(arg.map { |tok|
|
|
262
|
+
ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, true)
|
|
261
263
|
})
|
|
262
264
|
end
|
|
263
265
|
end
|
|
264
266
|
|
|
265
|
-
def stringize_argument(arg,
|
|
267
|
+
def stringize_argument(arg, expansion_loc, macro_tbl)
|
|
266
268
|
# NOTE: The ISO C99 standard says;
|
|
267
269
|
#
|
|
268
270
|
# 6.10.3.2 The # operator
|
|
@@ -298,18 +300,17 @@ module Cpp #:nodoc:
|
|
|
298
300
|
# NOTE: This code does not concern about contents of the string literal.
|
|
299
301
|
# But, it is enough for analysis.
|
|
300
302
|
|
|
301
|
-
str = arg.map { |
|
|
303
|
+
str = arg.map { |tok| tok.value }.join
|
|
302
304
|
if str =~ /((:?\\*))\\\z/ && $1.length.even?
|
|
303
305
|
str.chop!
|
|
304
|
-
|
|
306
|
+
macro_tbl.notify_last_backslash_ignored(arg.last)
|
|
305
307
|
end
|
|
306
308
|
|
|
307
309
|
ReplacedToken.new(:PP_TOKEN, "\"#{str.gsub(/["\\]/) { "\\" + $& }}\"",
|
|
308
|
-
|
|
310
|
+
expansion_loc, :STRING_LITERAL, false)
|
|
309
311
|
end
|
|
310
312
|
|
|
311
|
-
def concat_with_last_token(
|
|
312
|
-
macro_table)
|
|
313
|
+
def concat_with_last_token(arg_toks, expansion_loc, res_toks, macro_tbl)
|
|
313
314
|
# NOTE: The ISO C99 standard says;
|
|
314
315
|
#
|
|
315
316
|
# 6.10.3.3 The ## operator
|
|
@@ -341,28 +342,27 @@ module Cpp #:nodoc:
|
|
|
341
342
|
# The resulting token is available for further macro replacement. The
|
|
342
343
|
# order of evaluation of ## operators is unspecified.
|
|
343
344
|
|
|
344
|
-
if lhs =
|
|
345
|
-
if rhs =
|
|
345
|
+
if lhs = res_toks.pop
|
|
346
|
+
if rhs = arg_toks.first
|
|
346
347
|
# NOTE: To avoid syntax error when the concatenated token can be
|
|
347
348
|
# retokenize to two or more tokens.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
ReplacedToken.new(
|
|
351
|
-
|
|
349
|
+
new_toks = StringToPPTokensLexer.new(lhs.value + rhs.value).execute
|
|
350
|
+
new_toks.map! do |tok|
|
|
351
|
+
ReplacedToken.new(tok.type, tok.value, expansion_loc,
|
|
352
|
+
tok.type_hint, false)
|
|
352
353
|
end
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
ReplacedToken.new(
|
|
356
|
-
|
|
354
|
+
res_toks.concat(new_toks)
|
|
355
|
+
res_toks.concat(arg_toks[1..-1].map { |tok|
|
|
356
|
+
ReplacedToken.new(tok.type, tok.value, expansion_loc,
|
|
357
|
+
tok.type_hint, false)
|
|
357
358
|
})
|
|
358
359
|
else
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
result_tokens.concat(new_tokens)
|
|
360
|
+
new_toks = [ReplacedToken.new(lhs.type, lhs.value, expansion_loc,
|
|
361
|
+
lhs.type_hint, false)]
|
|
362
|
+
res_toks.concat(new_toks)
|
|
363
363
|
end
|
|
364
364
|
|
|
365
|
-
|
|
365
|
+
macro_tbl.notify_sharpsharp_operator_evaled(lhs, rhs, new_toks)
|
|
366
366
|
end
|
|
367
367
|
end
|
|
368
368
|
end
|
|
@@ -375,13 +375,13 @@ module Cpp #:nodoc:
|
|
|
375
375
|
|
|
376
376
|
attr_reader :replacement_list
|
|
377
377
|
|
|
378
|
-
def expand(
|
|
379
|
-
@replacement_list = generate_replacement_list(
|
|
378
|
+
def expand(toks, macro_tbl, repl_ctxt)
|
|
379
|
+
@replacement_list = generate_replacement_list(toks.first)
|
|
380
380
|
super
|
|
381
381
|
end
|
|
382
382
|
|
|
383
383
|
private
|
|
384
|
-
def generate_replacement_list(
|
|
384
|
+
def generate_replacement_list(tok)
|
|
385
385
|
subclass_responsibility
|
|
386
386
|
end
|
|
387
387
|
end
|
|
@@ -392,9 +392,9 @@ module Cpp #:nodoc:
|
|
|
392
392
|
end
|
|
393
393
|
|
|
394
394
|
private
|
|
395
|
-
def generate_replacement_list(
|
|
395
|
+
def generate_replacement_list(tok)
|
|
396
396
|
date = Time.now.strftime("%h %d %Y")
|
|
397
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "\"#{date}\"",
|
|
397
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "\"#{date}\"", tok.location,
|
|
398
398
|
:STRING_LITERAL))
|
|
399
399
|
end
|
|
400
400
|
end
|
|
@@ -405,9 +405,9 @@ module Cpp #:nodoc:
|
|
|
405
405
|
end
|
|
406
406
|
|
|
407
407
|
private
|
|
408
|
-
def generate_replacement_list(
|
|
408
|
+
def generate_replacement_list(tok)
|
|
409
409
|
PPTokens.new.push(
|
|
410
|
-
Token.new(:PP_TOKEN, "\"#{
|
|
410
|
+
Token.new(:PP_TOKEN, "\"#{tok.location.fpath}\"", tok.location,
|
|
411
411
|
:STRING_LITERAL))
|
|
412
412
|
end
|
|
413
413
|
end
|
|
@@ -418,9 +418,9 @@ module Cpp #:nodoc:
|
|
|
418
418
|
end
|
|
419
419
|
|
|
420
420
|
private
|
|
421
|
-
def generate_replacement_list(
|
|
421
|
+
def generate_replacement_list(tok)
|
|
422
422
|
PPTokens.new.push(
|
|
423
|
-
Token.new(:PP_TOKEN, "#{
|
|
423
|
+
Token.new(:PP_TOKEN, "#{tok.location.line_no}", tok.location,
|
|
424
424
|
:STRING_LITERAL))
|
|
425
425
|
end
|
|
426
426
|
end
|
|
@@ -431,8 +431,8 @@ module Cpp #:nodoc:
|
|
|
431
431
|
end
|
|
432
432
|
|
|
433
433
|
private
|
|
434
|
-
def generate_replacement_list(
|
|
435
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
434
|
+
def generate_replacement_list(tok)
|
|
435
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
436
436
|
end
|
|
437
437
|
end
|
|
438
438
|
|
|
@@ -442,8 +442,8 @@ module Cpp #:nodoc:
|
|
|
442
442
|
end
|
|
443
443
|
|
|
444
444
|
private
|
|
445
|
-
def generate_replacement_list(
|
|
446
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
445
|
+
def generate_replacement_list(tok)
|
|
446
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
447
447
|
end
|
|
448
448
|
end
|
|
449
449
|
|
|
@@ -453,8 +453,8 @@ module Cpp #:nodoc:
|
|
|
453
453
|
end
|
|
454
454
|
|
|
455
455
|
private
|
|
456
|
-
def generate_replacement_list(
|
|
457
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
456
|
+
def generate_replacement_list(tok)
|
|
457
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
458
458
|
end
|
|
459
459
|
end
|
|
460
460
|
|
|
@@ -464,8 +464,8 @@ module Cpp #:nodoc:
|
|
|
464
464
|
end
|
|
465
465
|
|
|
466
466
|
private
|
|
467
|
-
def generate_replacement_list(
|
|
468
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "199901L",
|
|
467
|
+
def generate_replacement_list(tok)
|
|
468
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "199901L", tok.location,
|
|
469
469
|
:CONSTANT))
|
|
470
470
|
end
|
|
471
471
|
end
|
|
@@ -476,9 +476,9 @@ module Cpp #:nodoc:
|
|
|
476
476
|
end
|
|
477
477
|
|
|
478
478
|
private
|
|
479
|
-
def generate_replacement_list(
|
|
479
|
+
def generate_replacement_list(tok)
|
|
480
480
|
time = Time.now.strftime("%H:%M:%S")
|
|
481
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "\"#{time}\"",
|
|
481
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "\"#{time}\"", tok.location,
|
|
482
482
|
:STRING_LITERAL))
|
|
483
483
|
end
|
|
484
484
|
end
|
|
@@ -489,8 +489,8 @@ module Cpp #:nodoc:
|
|
|
489
489
|
end
|
|
490
490
|
|
|
491
491
|
private
|
|
492
|
-
def generate_replacement_list(
|
|
493
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "0",
|
|
492
|
+
def generate_replacement_list(tok)
|
|
493
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "0", tok.location, :CONSTANT))
|
|
494
494
|
end
|
|
495
495
|
end
|
|
496
496
|
|
|
@@ -500,8 +500,8 @@ module Cpp #:nodoc:
|
|
|
500
500
|
end
|
|
501
501
|
|
|
502
502
|
private
|
|
503
|
-
def generate_replacement_list(
|
|
504
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "0",
|
|
503
|
+
def generate_replacement_list(tok)
|
|
504
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "0", tok.location, :CONSTANT))
|
|
505
505
|
end
|
|
506
506
|
end
|
|
507
507
|
|
|
@@ -511,8 +511,8 @@ module Cpp #:nodoc:
|
|
|
511
511
|
end
|
|
512
512
|
|
|
513
513
|
private
|
|
514
|
-
def generate_replacement_list(
|
|
515
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "199712L",
|
|
514
|
+
def generate_replacement_list(tok)
|
|
515
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "199712L", tok.location,
|
|
516
516
|
:CONSTANT))
|
|
517
517
|
end
|
|
518
518
|
end
|
|
@@ -522,7 +522,7 @@ module Cpp #:nodoc:
|
|
|
522
522
|
super(PseudoFunctionLikeDefineLine.new("_Pragma", ["str"]))
|
|
523
523
|
end
|
|
524
524
|
|
|
525
|
-
def expand(
|
|
525
|
+
def expand(toks, macro_tbl, repl_ctxt)
|
|
526
526
|
# TODO: Should implement pragma handling feature.
|
|
527
527
|
[]
|
|
528
528
|
end
|
|
@@ -534,8 +534,8 @@ module Cpp #:nodoc:
|
|
|
534
534
|
end
|
|
535
535
|
|
|
536
536
|
private
|
|
537
|
-
def generate_replacement_list(
|
|
538
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
537
|
+
def generate_replacement_list(tok)
|
|
538
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
539
539
|
end
|
|
540
540
|
end
|
|
541
541
|
|
|
@@ -545,8 +545,8 @@ module Cpp #:nodoc:
|
|
|
545
545
|
end
|
|
546
546
|
|
|
547
547
|
private
|
|
548
|
-
def generate_replacement_list(
|
|
549
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
548
|
+
def generate_replacement_list(tok)
|
|
549
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
550
550
|
end
|
|
551
551
|
end
|
|
552
552
|
|
|
@@ -556,8 +556,8 @@ module Cpp #:nodoc:
|
|
|
556
556
|
end
|
|
557
557
|
|
|
558
558
|
private
|
|
559
|
-
def generate_replacement_list(
|
|
560
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
559
|
+
def generate_replacement_list(tok)
|
|
560
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
561
561
|
end
|
|
562
562
|
end
|
|
563
563
|
|
|
@@ -567,8 +567,8 @@ module Cpp #:nodoc:
|
|
|
567
567
|
end
|
|
568
568
|
|
|
569
569
|
private
|
|
570
|
-
def generate_replacement_list(
|
|
571
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
570
|
+
def generate_replacement_list(tok)
|
|
571
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
572
572
|
end
|
|
573
573
|
end
|
|
574
574
|
|
|
@@ -578,8 +578,8 @@ module Cpp #:nodoc:
|
|
|
578
578
|
end
|
|
579
579
|
|
|
580
580
|
private
|
|
581
|
-
def generate_replacement_list(
|
|
582
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
581
|
+
def generate_replacement_list(tok)
|
|
582
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
583
583
|
end
|
|
584
584
|
end
|
|
585
585
|
|
|
@@ -589,8 +589,8 @@ module Cpp #:nodoc:
|
|
|
589
589
|
end
|
|
590
590
|
|
|
591
591
|
private
|
|
592
|
-
def generate_replacement_list(
|
|
593
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
592
|
+
def generate_replacement_list(tok)
|
|
593
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
594
594
|
end
|
|
595
595
|
end
|
|
596
596
|
|
|
@@ -600,8 +600,8 @@ module Cpp #:nodoc:
|
|
|
600
600
|
end
|
|
601
601
|
|
|
602
602
|
private
|
|
603
|
-
def generate_replacement_list(
|
|
604
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
603
|
+
def generate_replacement_list(tok)
|
|
604
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
605
605
|
end
|
|
606
606
|
end
|
|
607
607
|
|
|
@@ -611,25 +611,25 @@ module Cpp #:nodoc:
|
|
|
611
611
|
end
|
|
612
612
|
|
|
613
613
|
private
|
|
614
|
-
def generate_replacement_list(
|
|
615
|
-
PPTokens.new.push(Token.new(:PP_TOKEN, "1",
|
|
614
|
+
def generate_replacement_list(tok)
|
|
615
|
+
PPTokens.new.push(Token.new(:PP_TOKEN, "1", tok.location, :CONSTANT))
|
|
616
616
|
end
|
|
617
617
|
end
|
|
618
618
|
|
|
619
619
|
class MacroReplacementContext
|
|
620
620
|
def initialize
|
|
621
|
-
@hide_sets = Hash.new { |
|
|
621
|
+
@hide_sets = Hash.new { |hash, key| hash[key] = Set.new }
|
|
622
622
|
end
|
|
623
623
|
|
|
624
|
-
def add_to_hide_set(
|
|
625
|
-
|
|
626
|
-
@hide_sets[
|
|
627
|
-
@hide_sets[
|
|
624
|
+
def add_to_hide_set(org_tok, new_toks, macro_name)
|
|
625
|
+
new_toks.each do |new_tok|
|
|
626
|
+
@hide_sets[new_tok].merge(@hide_sets[org_tok])
|
|
627
|
+
@hide_sets[new_tok].add(macro_name)
|
|
628
628
|
end
|
|
629
629
|
end
|
|
630
630
|
|
|
631
|
-
def hidden?(
|
|
632
|
-
@hide_sets[
|
|
631
|
+
def hidden?(tok, macro_name)
|
|
632
|
+
@hide_sets[tok].include?(macro_name)
|
|
633
633
|
end
|
|
634
634
|
end
|
|
635
635
|
|
|
@@ -660,12 +660,12 @@ module Cpp #:nodoc:
|
|
|
660
660
|
@macros[name_str]
|
|
661
661
|
end
|
|
662
662
|
|
|
663
|
-
def replace(
|
|
663
|
+
def replace(toks, repl_ctxt = nil)
|
|
664
664
|
replaced = false
|
|
665
|
-
|
|
665
|
+
idx = 0
|
|
666
666
|
|
|
667
|
-
while
|
|
668
|
-
case
|
|
667
|
+
while tok = toks[idx]
|
|
668
|
+
case tok.value
|
|
669
669
|
when "defined"
|
|
670
670
|
in_defined = true
|
|
671
671
|
when "(", ")"
|
|
@@ -674,53 +674,51 @@ module Cpp #:nodoc:
|
|
|
674
674
|
if in_defined
|
|
675
675
|
in_defined = false
|
|
676
676
|
else
|
|
677
|
-
if
|
|
678
|
-
|
|
677
|
+
if new_idx = do_replace(toks, idx, repl_ctxt)
|
|
678
|
+
idx = new_idx
|
|
679
679
|
replaced = true
|
|
680
680
|
end
|
|
681
681
|
end
|
|
682
682
|
end
|
|
683
|
-
|
|
683
|
+
idx += 1
|
|
684
684
|
end
|
|
685
685
|
|
|
686
686
|
replaced
|
|
687
687
|
end
|
|
688
688
|
|
|
689
|
-
def notify_object_like_macro_replacement(macro,
|
|
690
|
-
|
|
691
|
-
on_object_like_macro_replacement.invoke(macro, replacing_tokens,
|
|
692
|
-
result_tokens)
|
|
689
|
+
def notify_object_like_macro_replacement(macro, replacing_toks, res_toks)
|
|
690
|
+
on_object_like_macro_replacement.invoke(macro, replacing_toks, res_toks)
|
|
693
691
|
end
|
|
694
692
|
|
|
695
|
-
def notify_function_like_macro_replacement(macro,
|
|
696
|
-
|
|
697
|
-
on_function_like_macro_replacement.invoke(macro,
|
|
698
|
-
|
|
693
|
+
def notify_function_like_macro_replacement(macro, replacing_toks, args,
|
|
694
|
+
res_toks)
|
|
695
|
+
on_function_like_macro_replacement.invoke(macro, replacing_toks, args,
|
|
696
|
+
res_toks)
|
|
699
697
|
end
|
|
700
698
|
|
|
701
|
-
def notify_sharpsharp_operator_evaled(
|
|
702
|
-
on_sharpsharp_operator_evaled.invoke(
|
|
699
|
+
def notify_sharpsharp_operator_evaled(lhs_tok, rhs_tok, new_toks)
|
|
700
|
+
on_sharpsharp_operator_evaled.invoke(lhs_tok, rhs_tok, new_toks)
|
|
703
701
|
end
|
|
704
702
|
|
|
705
|
-
def notify_last_backslash_ignored(
|
|
706
|
-
on_last_backslash_ignored.invoke(
|
|
703
|
+
def notify_last_backslash_ignored(tok)
|
|
704
|
+
on_last_backslash_ignored.invoke(tok)
|
|
707
705
|
end
|
|
708
706
|
|
|
709
707
|
private
|
|
710
|
-
def do_replace(
|
|
711
|
-
|
|
708
|
+
def do_replace(toks, idx, repl_ctxt)
|
|
709
|
+
repl_ctxt ||= MacroReplacementContext.new
|
|
712
710
|
|
|
713
|
-
return nil unless
|
|
714
|
-
return nil if
|
|
711
|
+
return nil unless tok = toks[idx] and macro = lookup(tok.value)
|
|
712
|
+
return nil if repl_ctxt.hidden?(tok, macro.name.value)
|
|
715
713
|
|
|
716
|
-
size = macro.replaceable_size(
|
|
714
|
+
size = macro.replaceable_size(toks[idx..-1])
|
|
717
715
|
|
|
718
|
-
if
|
|
716
|
+
if toks[idx, size].all? { |t| t.need_no_further_replacement? }
|
|
719
717
|
return nil
|
|
720
718
|
end
|
|
721
719
|
|
|
722
|
-
expanded = macro.expand(
|
|
723
|
-
|
|
720
|
+
expanded = macro.expand(toks[idx, size], self, repl_ctxt)
|
|
721
|
+
repl_ctxt.add_to_hide_set(toks[idx], expanded, macro.name.value)
|
|
724
722
|
|
|
725
723
|
# NOTE: The ISO C99 standard says;
|
|
726
724
|
#
|
|
@@ -740,10 +738,10 @@ module Cpp #:nodoc:
|
|
|
740
738
|
# tokens are no longer available for further replacement even if they
|
|
741
739
|
# are later (re)examined in contexts in which that macro name
|
|
742
740
|
# preprocessing token whould otherwise have been replaced.
|
|
743
|
-
while replace(expanded,
|
|
744
|
-
|
|
741
|
+
while replace(expanded, repl_ctxt); end
|
|
742
|
+
toks[idx, size] = expanded
|
|
745
743
|
|
|
746
|
-
|
|
744
|
+
idx + expanded.size - 1
|
|
747
745
|
end
|
|
748
746
|
|
|
749
747
|
def predefine_special_macros
|