adlint 2.6.14 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Code checkings (cpp-phase) of adlint-exam-c_builtin package.
|
|
2
2
|
#
|
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
6
|
#
|
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
|
15
15
|
#
|
|
16
16
|
# This file is part of AdLint.
|
|
17
17
|
#
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
require "adlint/exam"
|
|
33
33
|
require "adlint/report"
|
|
34
|
+
require "adlint/traits"
|
|
34
35
|
require "adlint/cpp/phase"
|
|
35
36
|
require "adlint/cpp/util"
|
|
36
37
|
|
|
@@ -43,20 +44,20 @@ module CBuiltin #:nodoc:
|
|
|
43
44
|
|
|
44
45
|
# NOTE: W0001 may be duplicative when the same header which has the deeply
|
|
45
46
|
# grouped expression is included twice or more.
|
|
46
|
-
|
|
47
|
+
mark_as_unique
|
|
47
48
|
|
|
48
|
-
def initialize(
|
|
49
|
+
def initialize(phase_ctxt)
|
|
49
50
|
super
|
|
50
|
-
visitor =
|
|
51
|
-
visitor.enter_grouped_expression +=
|
|
52
|
-
visitor.leave_grouped_expression +=
|
|
51
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
52
|
+
visitor.enter_grouped_expression += T(:enter_grouped_expression)
|
|
53
|
+
visitor.leave_grouped_expression += T(:leave_grouped_expression)
|
|
53
54
|
@group_depth = 0
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
private
|
|
57
58
|
def enter_grouped_expression(node)
|
|
58
59
|
@group_depth += 1
|
|
59
|
-
W(
|
|
60
|
+
W(node.location) if @group_depth == 32
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
def leave_grouped_expression(node)
|
|
@@ -67,32 +68,32 @@ module CBuiltin #:nodoc:
|
|
|
67
68
|
class W0025 < PassiveCodeCheck
|
|
68
69
|
def_registrant_phase Cpp::Prepare2Phase
|
|
69
70
|
|
|
70
|
-
def initialize(
|
|
71
|
+
def initialize(phase_ctxt)
|
|
71
72
|
super
|
|
72
|
-
interp =
|
|
73
|
-
interp.on_user_header_included
|
|
74
|
-
interp.on_system_header_included +=
|
|
75
|
-
@
|
|
76
|
-
@
|
|
73
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
74
|
+
interp.on_user_header_included += T(:check_user_include)
|
|
75
|
+
interp.on_system_header_included += T(:check_system_include)
|
|
76
|
+
@usr_header_fpaths = Set.new
|
|
77
|
+
@sys_header_fpaths = Set.new
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
private
|
|
80
|
-
def check_user_include(
|
|
81
|
-
if @
|
|
82
|
-
W(
|
|
81
|
+
def check_user_include(usr_include_line, usr_header)
|
|
82
|
+
if @usr_header_fpaths.include?(usr_header.fpath)
|
|
83
|
+
W(usr_include_line.location, usr_include_line.fpath)
|
|
83
84
|
else
|
|
84
|
-
if
|
|
85
|
-
@
|
|
85
|
+
if usr_include_line.include_depth == 1
|
|
86
|
+
@usr_header_fpaths.add(usr_header.fpath)
|
|
86
87
|
end
|
|
87
88
|
end
|
|
88
89
|
end
|
|
89
90
|
|
|
90
|
-
def check_system_include(
|
|
91
|
-
if @
|
|
92
|
-
W(
|
|
91
|
+
def check_system_include(sys_include_line, sys_header)
|
|
92
|
+
if @sys_header_fpaths.include?(sys_header.fpath)
|
|
93
|
+
W(sys_include_line.location, sys_include_line.fpath)
|
|
93
94
|
else
|
|
94
|
-
if
|
|
95
|
-
@
|
|
95
|
+
if sys_include_line.include_depth == 1
|
|
96
|
+
@sys_header_fpaths.add(sys_header.fpath)
|
|
96
97
|
end
|
|
97
98
|
end
|
|
98
99
|
end
|
|
@@ -101,32 +102,32 @@ module CBuiltin #:nodoc:
|
|
|
101
102
|
class W0026 < PassiveCodeCheck
|
|
102
103
|
def_registrant_phase Cpp::Prepare2Phase
|
|
103
104
|
|
|
104
|
-
def initialize(
|
|
105
|
+
def initialize(phase_ctxt)
|
|
105
106
|
super
|
|
106
|
-
interp =
|
|
107
|
-
interp.on_user_header_included
|
|
108
|
-
interp.on_system_header_included +=
|
|
109
|
-
@
|
|
110
|
-
@
|
|
107
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
108
|
+
interp.on_user_header_included += T(:check_user_include)
|
|
109
|
+
interp.on_system_header_included += T(:check_system_include)
|
|
110
|
+
@usr_header_fpaths = Set.new
|
|
111
|
+
@sys_header_fpaths = Set.new
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
private
|
|
114
|
-
def check_user_include(
|
|
115
|
-
if @
|
|
116
|
-
W(
|
|
115
|
+
def check_user_include(usr_include_line, usr_header)
|
|
116
|
+
if @usr_header_fpaths.include?(usr_header.fpath)
|
|
117
|
+
W(usr_include_line.location, usr_include_line.fpath)
|
|
117
118
|
else
|
|
118
|
-
if
|
|
119
|
-
@
|
|
119
|
+
if usr_include_line.include_depth > 1
|
|
120
|
+
@usr_header_fpaths.add(usr_header.fpath)
|
|
120
121
|
end
|
|
121
122
|
end
|
|
122
123
|
end
|
|
123
124
|
|
|
124
|
-
def check_system_include(
|
|
125
|
-
if @
|
|
126
|
-
W(
|
|
125
|
+
def check_system_include(sys_include_line, sys_header)
|
|
126
|
+
if @sys_header_fpaths.include?(sys_header.fpath)
|
|
127
|
+
W(sys_include_line.location, sys_include_line.fpath)
|
|
127
128
|
else
|
|
128
|
-
if
|
|
129
|
-
@
|
|
129
|
+
if sys_include_line.include_depth > 1
|
|
130
|
+
@sys_header_fpaths.add(sys_header.fpath)
|
|
130
131
|
end
|
|
131
132
|
end
|
|
132
133
|
end
|
|
@@ -135,16 +136,16 @@ module CBuiltin #:nodoc:
|
|
|
135
136
|
class W0053 < PassiveCodeCheck
|
|
136
137
|
def_registrant_phase Cpp::Prepare2Phase
|
|
137
138
|
|
|
138
|
-
def initialize(
|
|
139
|
+
def initialize(phase_ctxt)
|
|
139
140
|
super
|
|
140
|
-
interp =
|
|
141
|
-
interp.on_user_header_included +=
|
|
141
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
142
|
+
interp.on_user_header_included += T(:check_user_include)
|
|
142
143
|
end
|
|
143
144
|
|
|
144
145
|
private
|
|
145
|
-
def check_user_include(
|
|
146
|
-
if
|
|
147
|
-
W(
|
|
146
|
+
def check_user_include(usr_include_line, usr_header)
|
|
147
|
+
if usr_include_line.include_depth == 7
|
|
148
|
+
W(usr_include_line.location, usr_header.fpath)
|
|
148
149
|
end
|
|
149
150
|
end
|
|
150
151
|
end
|
|
@@ -152,21 +153,21 @@ module CBuiltin #:nodoc:
|
|
|
152
153
|
class W0054 < PassiveCodeCheck
|
|
153
154
|
def_registrant_phase Cpp::Prepare2Phase
|
|
154
155
|
|
|
155
|
-
def initialize(
|
|
156
|
+
def initialize(phase_ctxt)
|
|
156
157
|
super
|
|
157
|
-
visitor =
|
|
158
|
-
visitor.enter_if_section +=
|
|
159
|
-
visitor.leave_if_section +=
|
|
158
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
159
|
+
visitor.enter_if_section += T(:enter_if_section)
|
|
160
|
+
visitor.leave_if_section += T(:leave_if_section)
|
|
160
161
|
@if_depth = 0
|
|
161
162
|
end
|
|
162
163
|
|
|
163
164
|
private
|
|
164
165
|
def enter_if_section(node)
|
|
165
166
|
@if_depth += 1
|
|
166
|
-
W(
|
|
167
|
+
W(node.location) if @if_depth == 9
|
|
167
168
|
end
|
|
168
169
|
|
|
169
|
-
def leave_if_section(
|
|
170
|
+
def leave_if_section(*)
|
|
170
171
|
@if_depth -= 1
|
|
171
172
|
end
|
|
172
173
|
end
|
|
@@ -174,33 +175,45 @@ module CBuiltin #:nodoc:
|
|
|
174
175
|
class W0055 < PassiveCodeCheck
|
|
175
176
|
def_registrant_phase Cpp::Prepare2Phase
|
|
176
177
|
|
|
177
|
-
def initialize(
|
|
178
|
+
def initialize(phase_ctxt)
|
|
178
179
|
super
|
|
179
|
-
interp =
|
|
180
|
-
interp.on_object_like_macro_defined
|
|
181
|
-
interp.on_function_like_macro_defined
|
|
182
|
-
interp.on_va_function_like_macro_defined +=
|
|
180
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
181
|
+
interp.on_object_like_macro_defined += T(:check)
|
|
182
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
183
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
183
184
|
@macro_num = 0
|
|
184
185
|
end
|
|
185
186
|
|
|
186
187
|
private
|
|
187
|
-
def check(define_line,
|
|
188
|
+
def check(define_line, *)
|
|
188
189
|
unless in_initial_header?(define_line)
|
|
189
190
|
@macro_num += 1
|
|
190
|
-
W(
|
|
191
|
+
W(define_line.location) if @macro_num == 1025
|
|
191
192
|
end
|
|
192
193
|
end
|
|
193
194
|
|
|
194
195
|
def in_initial_header?(node)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
node.location.fpath.identical?(pinit_fpath) ||
|
|
197
|
+
node.location.fpath.identical?(cinit_fpath)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def pinit_fpath
|
|
201
|
+
if fpath = traits.of_project.initial_header
|
|
202
|
+
Pathname.new(fpath)
|
|
200
203
|
else
|
|
201
|
-
|
|
204
|
+
nil
|
|
202
205
|
end
|
|
203
206
|
end
|
|
207
|
+
memoize :pinit_fpath
|
|
208
|
+
|
|
209
|
+
def cinit_fpath
|
|
210
|
+
if fpath = traits.of_compiler.initial_header
|
|
211
|
+
Pathname.new(fpath)
|
|
212
|
+
else
|
|
213
|
+
nil
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
memoize :cinit_fpath
|
|
204
217
|
end
|
|
205
218
|
|
|
206
219
|
class W0056 < PassiveCodeCheck
|
|
@@ -208,20 +221,18 @@ module CBuiltin #:nodoc:
|
|
|
208
221
|
|
|
209
222
|
# NOTE: W0056 may be duplicative when the same header which has macro
|
|
210
223
|
# definition with too many parameters is included twice or more.
|
|
211
|
-
|
|
224
|
+
mark_as_unique
|
|
212
225
|
|
|
213
|
-
def initialize(
|
|
226
|
+
def initialize(phase_ctxt)
|
|
214
227
|
super
|
|
215
|
-
interp =
|
|
216
|
-
interp.on_function_like_macro_defined
|
|
217
|
-
interp.on_va_function_like_macro_defined +=
|
|
228
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
229
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
230
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
218
231
|
end
|
|
219
232
|
|
|
220
233
|
private
|
|
221
234
|
def check(define_line, macro)
|
|
222
|
-
if macro.parameter_names.size > 31
|
|
223
|
-
W(:W0056, define_line.location)
|
|
224
|
-
end
|
|
235
|
+
W(define_line.location) if macro.parameter_names.size > 31
|
|
225
236
|
end
|
|
226
237
|
end
|
|
227
238
|
|
|
@@ -230,19 +241,17 @@ module CBuiltin #:nodoc:
|
|
|
230
241
|
|
|
231
242
|
# NOTE: W0057 may be duplicative when the same header which has macro call
|
|
232
243
|
# with too many arguments is included twice or more.
|
|
233
|
-
|
|
244
|
+
mark_as_unique
|
|
234
245
|
|
|
235
|
-
def initialize(
|
|
246
|
+
def initialize(phase_ctxt)
|
|
236
247
|
super
|
|
237
|
-
macro_table =
|
|
238
|
-
macro_table.on_function_like_macro_replacement +=
|
|
248
|
+
macro_table = phase_ctxt[:cpp_macro_table]
|
|
249
|
+
macro_table.on_function_like_macro_replacement += T(:check)
|
|
239
250
|
end
|
|
240
251
|
|
|
241
252
|
private
|
|
242
|
-
def check(macro,
|
|
243
|
-
if macro.parameter_names.size > 31
|
|
244
|
-
W(:W0057, replacing_tokens.first.location)
|
|
245
|
-
end
|
|
253
|
+
def check(macro, repl_toks, *)
|
|
254
|
+
W(repl_toks.first.location) if macro.parameter_names.size > 31
|
|
246
255
|
end
|
|
247
256
|
end
|
|
248
257
|
|
|
@@ -251,12 +260,20 @@ module CBuiltin #:nodoc:
|
|
|
251
260
|
|
|
252
261
|
# NOTE: W0059 may be duplicative when the same header which has carriage
|
|
253
262
|
# return at end of lines is included twice or more.
|
|
254
|
-
|
|
263
|
+
mark_as_unique
|
|
264
|
+
|
|
265
|
+
# NOTE: W0059 may be detected before evaluating the annotation for message
|
|
266
|
+
# suppression.
|
|
267
|
+
mark_as_deferred
|
|
255
268
|
|
|
256
|
-
def initialize(
|
|
269
|
+
def initialize(phase_ctxt)
|
|
257
270
|
super
|
|
258
|
-
|
|
259
|
-
|
|
271
|
+
phase_ctxt[:cpp_interpreter].on_cr_at_eol_found += M(:check)
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
private
|
|
275
|
+
def check(loc)
|
|
276
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
260
277
|
end
|
|
261
278
|
end
|
|
262
279
|
|
|
@@ -265,12 +282,20 @@ module CBuiltin #:nodoc:
|
|
|
265
282
|
|
|
266
283
|
# NOTE: W0060 may be duplicative when the same header which has the
|
|
267
284
|
# end-of-file mark is included twice or more.
|
|
268
|
-
|
|
285
|
+
mark_as_unique
|
|
269
286
|
|
|
270
|
-
|
|
287
|
+
# NOTE: W0060 may be detected before evaluating the annotation for message
|
|
288
|
+
# suppression.
|
|
289
|
+
mark_as_deferred
|
|
290
|
+
|
|
291
|
+
def initialize(phase_ctxt)
|
|
271
292
|
super
|
|
272
|
-
|
|
273
|
-
|
|
293
|
+
phase_ctxt[:cpp_interpreter].on_eof_mark_at_eof_found += M(:check)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
private
|
|
297
|
+
def check(loc)
|
|
298
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
274
299
|
end
|
|
275
300
|
end
|
|
276
301
|
|
|
@@ -280,21 +305,24 @@ module CBuiltin #:nodoc:
|
|
|
280
305
|
# NOTE: W0061 may be duplicative when the same header which has the token
|
|
281
306
|
# sequence of the compiler specific extension is included twice or
|
|
282
307
|
# more.
|
|
283
|
-
|
|
308
|
+
mark_as_unique
|
|
284
309
|
|
|
285
|
-
def initialize(
|
|
310
|
+
def initialize(phase_ctxt)
|
|
286
311
|
super
|
|
287
|
-
|
|
312
|
+
phase_ctxt[:cc1_source].on_language_extension += M(:check)
|
|
288
313
|
end
|
|
289
314
|
|
|
290
315
|
private
|
|
291
|
-
def check(
|
|
292
|
-
|
|
316
|
+
def check(matched_toks)
|
|
317
|
+
head_loc = matched_toks.first.location
|
|
318
|
+
if head_loc.in_analysis_target?(traits)
|
|
319
|
+
W(head_loc, tokens_to_str(matched_toks))
|
|
320
|
+
end
|
|
293
321
|
end
|
|
294
322
|
|
|
295
|
-
def tokens_to_str(
|
|
296
|
-
|
|
297
|
-
|
|
323
|
+
def tokens_to_str(toks)
|
|
324
|
+
toks.map { |tok|
|
|
325
|
+
tok.type == :NEW_LINE ? nil : tok.value
|
|
298
326
|
}.compact.join(" ")
|
|
299
327
|
end
|
|
300
328
|
end
|
|
@@ -304,12 +332,16 @@ module CBuiltin #:nodoc:
|
|
|
304
332
|
|
|
305
333
|
# NOTE: W0069 may be duplicative when the same header which has the nested
|
|
306
334
|
# block comment is included twice or more.
|
|
307
|
-
|
|
335
|
+
mark_as_unique
|
|
308
336
|
|
|
309
|
-
def initialize(
|
|
337
|
+
def initialize(phase_ctxt)
|
|
310
338
|
super
|
|
311
|
-
|
|
312
|
-
|
|
339
|
+
phase_ctxt[:cpp_interpreter].on_nested_block_comment_found += M(:check)
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
private
|
|
343
|
+
def check(loc)
|
|
344
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
313
345
|
end
|
|
314
346
|
end
|
|
315
347
|
|
|
@@ -319,25 +351,25 @@ module CBuiltin #:nodoc:
|
|
|
319
351
|
# NOTE: W0072 may be duplicative when the same header which has non
|
|
320
352
|
# basic-source-character in the #include directive is included twice
|
|
321
353
|
# or more.
|
|
322
|
-
|
|
354
|
+
mark_as_unique
|
|
323
355
|
|
|
324
|
-
def initialize(
|
|
356
|
+
def initialize(phase_ctxt)
|
|
325
357
|
super
|
|
326
|
-
visitor =
|
|
327
|
-
visitor.enter_user_include_line
|
|
328
|
-
visitor.enter_system_include_line +=
|
|
358
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
359
|
+
visitor.enter_user_include_line += T(:check_user_include_line)
|
|
360
|
+
visitor.enter_system_include_line += T(:check_system_include_line)
|
|
329
361
|
end
|
|
330
362
|
|
|
331
363
|
private
|
|
332
364
|
def check_user_include_line(node)
|
|
333
365
|
unless Cpp::BasicSourceCharacterSet.include?(node.header_name.value)
|
|
334
|
-
W(
|
|
366
|
+
W(node.header_name.location)
|
|
335
367
|
end
|
|
336
368
|
end
|
|
337
369
|
|
|
338
370
|
def check_system_include_line(node)
|
|
339
371
|
unless Cpp::BasicSourceCharacterSet.include?(node.header_name.value)
|
|
340
|
-
W(
|
|
372
|
+
W(node.header_name.location)
|
|
341
373
|
end
|
|
342
374
|
end
|
|
343
375
|
end
|
|
@@ -347,16 +379,16 @@ module CBuiltin #:nodoc:
|
|
|
347
379
|
|
|
348
380
|
# NOTE: W0073 may be duplicative when the same header without the
|
|
349
381
|
# include-guard is included twice or more.
|
|
350
|
-
|
|
382
|
+
mark_as_unique
|
|
351
383
|
|
|
352
|
-
def initialize(
|
|
384
|
+
def initialize(phase_ctxt)
|
|
353
385
|
super
|
|
354
|
-
visitor =
|
|
355
|
-
visitor.enter_user_include_line
|
|
356
|
-
visitor.enter_system_include_line +=
|
|
357
|
-
visitor.enter_text_line
|
|
358
|
-
visitor.enter_if_section
|
|
359
|
-
@main_fpath =
|
|
386
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
387
|
+
visitor.enter_user_include_line += T(:enter_include_line)
|
|
388
|
+
visitor.enter_system_include_line += T(:enter_include_line)
|
|
389
|
+
visitor.enter_text_line += T(:enter_text_line)
|
|
390
|
+
visitor.enter_if_section += T(:enter_if_section)
|
|
391
|
+
@main_fpath = phase_ctxt[:sources].first.fpath
|
|
360
392
|
@last_fpath = nil
|
|
361
393
|
@enclosed_by_if_section = false
|
|
362
394
|
@warned_files = Set.new
|
|
@@ -372,7 +404,7 @@ module CBuiltin #:nodoc:
|
|
|
372
404
|
return if in_initial_header?(node) || in_main_file?(node)
|
|
373
405
|
|
|
374
406
|
unless @enclosed_by_if_section || in_warned_file?(node)
|
|
375
|
-
W(
|
|
407
|
+
W(node.location)
|
|
376
408
|
@warned_files.add(node.location.fpath)
|
|
377
409
|
end
|
|
378
410
|
end
|
|
@@ -388,7 +420,7 @@ module CBuiltin #:nodoc:
|
|
|
388
420
|
end
|
|
389
421
|
|
|
390
422
|
unless @enclosed_by_if_section || in_warned_file?(node)
|
|
391
|
-
W(
|
|
423
|
+
W(node.location)
|
|
392
424
|
@warned_files.add(node.location.fpath)
|
|
393
425
|
end
|
|
394
426
|
end
|
|
@@ -403,23 +435,35 @@ module CBuiltin #:nodoc:
|
|
|
403
435
|
end
|
|
404
436
|
|
|
405
437
|
def in_main_file?(node)
|
|
406
|
-
|
|
438
|
+
node.location.fpath == @main_fpath
|
|
407
439
|
end
|
|
408
440
|
|
|
409
441
|
def in_initial_header?(node)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
File.identical?(node.location.fpath, pinit_fpath)
|
|
413
|
-
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
414
|
-
File.identical?(node.location.fpath, cinit_fpath)
|
|
415
|
-
else
|
|
416
|
-
false
|
|
417
|
-
end
|
|
442
|
+
node.location.fpath.identical?(pinit_fpath) ||
|
|
443
|
+
node.location.fpath.identical?(cinit_fpath)
|
|
418
444
|
end
|
|
419
445
|
|
|
420
446
|
def in_warned_file?(node)
|
|
421
447
|
@warned_files.include?(node.location.fpath)
|
|
422
448
|
end
|
|
449
|
+
|
|
450
|
+
def pinit_fpath
|
|
451
|
+
if fpath = traits.of_project.initial_header
|
|
452
|
+
Pathname.new(fpath)
|
|
453
|
+
else
|
|
454
|
+
nil
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
memoize :pinit_fpath
|
|
458
|
+
|
|
459
|
+
def cinit_fpath
|
|
460
|
+
if fpath = traits.of_compiler.initial_header
|
|
461
|
+
Pathname.new(fpath)
|
|
462
|
+
else
|
|
463
|
+
nil
|
|
464
|
+
end
|
|
465
|
+
end
|
|
466
|
+
memoize :cinit_fpath
|
|
423
467
|
end
|
|
424
468
|
|
|
425
469
|
class W0442 < PassiveCodeCheck
|
|
@@ -427,29 +471,18 @@ module CBuiltin #:nodoc:
|
|
|
427
471
|
|
|
428
472
|
# NOTE: W0442 may be duplicative when the same header which has
|
|
429
473
|
# function-like macro definitions is included twice or more.
|
|
430
|
-
|
|
474
|
+
mark_as_unique
|
|
431
475
|
|
|
432
|
-
def initialize(
|
|
476
|
+
def initialize(phase_ctxt)
|
|
433
477
|
super
|
|
434
|
-
interp =
|
|
435
|
-
interp.on_function_like_macro_defined
|
|
436
|
-
interp.on_va_function_like_macro_defined +=
|
|
478
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
479
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
480
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
437
481
|
end
|
|
438
482
|
|
|
439
483
|
private
|
|
440
|
-
def check(define_line,
|
|
441
|
-
W(
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
def in_initial_header?(node)
|
|
445
|
-
case
|
|
446
|
-
when pinit_fpath = Traits.instance.of_project.initial_header
|
|
447
|
-
File.identical?(node.location.fpath, pinit_fpath)
|
|
448
|
-
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
449
|
-
File.identical?(node.location.fpath, cinit_fpath)
|
|
450
|
-
else
|
|
451
|
-
false
|
|
452
|
-
end
|
|
484
|
+
def check(define_line, *)
|
|
485
|
+
W(define_line.location)
|
|
453
486
|
end
|
|
454
487
|
end
|
|
455
488
|
|
|
@@ -459,42 +492,30 @@ module CBuiltin #:nodoc:
|
|
|
459
492
|
# NOTE: W0443 may be duplicative when the same header which has
|
|
460
493
|
# functionizable function-like macro definitions is included twice or
|
|
461
494
|
# more.
|
|
462
|
-
|
|
495
|
+
mark_as_unique
|
|
463
496
|
|
|
464
|
-
def initialize(
|
|
497
|
+
def initialize(phase_ctxt)
|
|
465
498
|
super
|
|
466
|
-
visitor =
|
|
467
|
-
visitor.enter_function_like_define_line
|
|
468
|
-
visitor.enter_va_function_like_define_line +=
|
|
499
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
500
|
+
visitor.enter_function_like_define_line += T(:check)
|
|
501
|
+
visitor.enter_va_function_like_define_line += T(:check)
|
|
469
502
|
end
|
|
470
503
|
|
|
471
504
|
private
|
|
472
505
|
def check(node)
|
|
473
|
-
return if in_initial_header?(node)
|
|
474
506
|
return unless node.identifier_list
|
|
475
507
|
|
|
476
|
-
if
|
|
477
|
-
should_be_function =
|
|
478
|
-
if keyword_or_punctuator?(
|
|
508
|
+
if repl_lsit = node.replacement_list
|
|
509
|
+
should_be_function = repl_lsit.tokens.all? { |pp_tok|
|
|
510
|
+
if keyword_or_punctuator?(pp_tok)
|
|
479
511
|
false
|
|
480
|
-
elsif type_specifier_or_type_qualifier?(
|
|
512
|
+
elsif type_specifier_or_type_qualifier?(pp_tok)
|
|
481
513
|
false
|
|
482
514
|
else
|
|
483
515
|
true
|
|
484
516
|
end
|
|
485
517
|
}
|
|
486
|
-
W(
|
|
487
|
-
end
|
|
488
|
-
end
|
|
489
|
-
|
|
490
|
-
def in_initial_header?(node)
|
|
491
|
-
case
|
|
492
|
-
when pinit_fpath = Traits.instance.of_project.initial_header
|
|
493
|
-
File.identical?(node.location.fpath, pinit_fpath)
|
|
494
|
-
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
495
|
-
File.identical?(node.location.fpath, cinit_fpath)
|
|
496
|
-
else
|
|
497
|
-
false
|
|
518
|
+
W(node.location) if should_be_function
|
|
498
519
|
end
|
|
499
520
|
end
|
|
500
521
|
|
|
@@ -508,16 +529,16 @@ module CBuiltin #:nodoc:
|
|
|
508
529
|
].to_set.freeze
|
|
509
530
|
private_constant :KEYWORDS
|
|
510
531
|
|
|
511
|
-
def keyword_or_punctuator?(
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
532
|
+
def keyword_or_punctuator?(pp_tok)
|
|
533
|
+
pp_tok.value == "#" || pp_tok.value == "##" ||
|
|
534
|
+
pp_tok.value == "{" || pp_tok.value == "}" ||
|
|
535
|
+
pp_tok.value == ";" || KEYWORDS.include?(pp_tok.value)
|
|
515
536
|
end
|
|
516
537
|
|
|
517
|
-
def type_specifier_or_type_qualifier?(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
@
|
|
538
|
+
def type_specifier_or_type_qualifier?(pp_tok)
|
|
539
|
+
pp_tok.value == "const" || pp_tok.value == "volatile" ||
|
|
540
|
+
pp_tok.value == "restrict" ||
|
|
541
|
+
@phase_ctxt[:cc1_type_table].all_type_names.include?(pp_tok.value)
|
|
521
542
|
end
|
|
522
543
|
end
|
|
523
544
|
|
|
@@ -527,23 +548,23 @@ module CBuiltin #:nodoc:
|
|
|
527
548
|
# NOTE: W0444 may be duplicative when the same header which has the
|
|
528
549
|
# function-like macro definition with `#' and `##' operators is
|
|
529
550
|
# included twice or more.
|
|
530
|
-
|
|
551
|
+
mark_as_unique
|
|
531
552
|
|
|
532
|
-
def initialize(
|
|
553
|
+
def initialize(phase_ctxt)
|
|
533
554
|
super
|
|
534
|
-
interp =
|
|
535
|
-
interp.on_function_like_macro_defined
|
|
536
|
-
interp.on_va_function_like_macro_defined +=
|
|
555
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
556
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
557
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
537
558
|
end
|
|
538
559
|
|
|
539
560
|
private
|
|
540
561
|
def check(define_line, macro)
|
|
541
|
-
if
|
|
562
|
+
if repl_list = macro.replacement_list
|
|
542
563
|
sharp_op_num = 0
|
|
543
564
|
sharpsharp_op_num = 0
|
|
544
565
|
|
|
545
|
-
|
|
546
|
-
case
|
|
566
|
+
repl_list.tokens.each do |pp_tok|
|
|
567
|
+
case pp_tok.value
|
|
547
568
|
when "#"
|
|
548
569
|
sharp_op_num += 1
|
|
549
570
|
when "##"
|
|
@@ -551,9 +572,7 @@ module CBuiltin #:nodoc:
|
|
|
551
572
|
end
|
|
552
573
|
end
|
|
553
574
|
|
|
554
|
-
if sharp_op_num > 0 && sharpsharp_op_num > 0
|
|
555
|
-
W(:W0444, define_line.location)
|
|
556
|
-
end
|
|
575
|
+
W(define_line.location) if sharp_op_num > 0 && sharpsharp_op_num > 0
|
|
557
576
|
end
|
|
558
577
|
end
|
|
559
578
|
end
|
|
@@ -564,29 +583,27 @@ module CBuiltin #:nodoc:
|
|
|
564
583
|
# NOTE: W0445 may be duplicative when the same header which has the
|
|
565
584
|
# function-like macro definition with two or more `##' operators is
|
|
566
585
|
# included twice or more.
|
|
567
|
-
|
|
586
|
+
mark_as_unique
|
|
568
587
|
|
|
569
|
-
def initialize(
|
|
588
|
+
def initialize(phase_ctxt)
|
|
570
589
|
super
|
|
571
|
-
interp =
|
|
572
|
-
interp.on_function_like_macro_defined
|
|
573
|
-
interp.on_va_function_like_macro_defined +=
|
|
590
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
591
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
592
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
574
593
|
end
|
|
575
594
|
|
|
576
595
|
private
|
|
577
596
|
def check(define_line, macro)
|
|
578
|
-
if
|
|
597
|
+
if repl_list = macro.replacement_list
|
|
579
598
|
sharpsharp_op_num = 0
|
|
580
599
|
|
|
581
|
-
|
|
582
|
-
if
|
|
600
|
+
repl_list.tokens.each do |pp_tok|
|
|
601
|
+
if pp_tok.value == "##"
|
|
583
602
|
sharpsharp_op_num += 1
|
|
584
603
|
end
|
|
585
604
|
end
|
|
586
605
|
|
|
587
|
-
if sharpsharp_op_num > 1
|
|
588
|
-
W(:W0445, define_line.location)
|
|
589
|
-
end
|
|
606
|
+
W(define_line.location) if sharpsharp_op_num > 1
|
|
590
607
|
end
|
|
591
608
|
end
|
|
592
609
|
end
|
|
@@ -597,24 +614,24 @@ module CBuiltin #:nodoc:
|
|
|
597
614
|
# NOTE: W0477 may be duplicative when the same header which has the macro
|
|
598
615
|
# definition with unbalanced grouping tokens is included twice or
|
|
599
616
|
# more.
|
|
600
|
-
|
|
617
|
+
mark_as_unique
|
|
601
618
|
|
|
602
|
-
def initialize(
|
|
619
|
+
def initialize(phase_ctxt)
|
|
603
620
|
super
|
|
604
|
-
interp =
|
|
605
|
-
interp.on_object_like_macro_defined
|
|
606
|
-
interp.on_function_like_macro_defined
|
|
607
|
-
interp.on_va_function_like_macro_defined +=
|
|
621
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
622
|
+
interp.on_object_like_macro_defined += T(:check)
|
|
623
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
624
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
608
625
|
end
|
|
609
626
|
|
|
610
627
|
private
|
|
611
628
|
def check(define_line, macro)
|
|
612
|
-
if
|
|
629
|
+
if repl_list = macro.replacement_list
|
|
613
630
|
paren_count = 0
|
|
614
631
|
brace_count = 0
|
|
615
632
|
bracket_count = 0
|
|
616
|
-
|
|
617
|
-
case
|
|
633
|
+
repl_list.tokens.each do |pp_tok|
|
|
634
|
+
case pp_tok.value
|
|
618
635
|
when "("
|
|
619
636
|
paren_count += 1
|
|
620
637
|
when ")"
|
|
@@ -631,7 +648,7 @@ module CBuiltin #:nodoc:
|
|
|
631
648
|
end
|
|
632
649
|
|
|
633
650
|
unless paren_count == 0 && brace_count == 0 && bracket_count == 0
|
|
634
|
-
W(
|
|
651
|
+
W(define_line.location)
|
|
635
652
|
end
|
|
636
653
|
end
|
|
637
654
|
end
|
|
@@ -642,27 +659,26 @@ module CBuiltin #:nodoc:
|
|
|
642
659
|
|
|
643
660
|
# NOTE: W0478 may be duplicative when the same header which causes this
|
|
644
661
|
# warning is included twice or more.
|
|
645
|
-
|
|
662
|
+
mark_as_unique
|
|
646
663
|
|
|
647
|
-
def initialize(
|
|
664
|
+
def initialize(phase_ctxt)
|
|
648
665
|
super
|
|
649
|
-
visitor =
|
|
650
|
-
visitor.enter_object_like_define_line
|
|
651
|
-
visitor.enter_function_like_define_line
|
|
652
|
-
visitor.enter_va_function_like_define_line +=
|
|
666
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
667
|
+
visitor.enter_object_like_define_line += T(:check)
|
|
668
|
+
visitor.enter_function_like_define_line += T(:check)
|
|
669
|
+
visitor.enter_va_function_like_define_line += T(:check)
|
|
653
670
|
end
|
|
654
671
|
|
|
655
672
|
private
|
|
656
673
|
def check(node)
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
W(:W0478, node.location)
|
|
674
|
+
if repl_list = node.replacement_list and repl_list.tokens.size > 1
|
|
675
|
+
unless repl_list.may_represent_expression? ||
|
|
676
|
+
repl_list.may_represent_initializer? ||
|
|
677
|
+
repl_list.may_represent_block? ||
|
|
678
|
+
repl_list.may_represent_do_while_zero_idiom? ||
|
|
679
|
+
repl_list.may_represent_specifier_qualifier_list? ||
|
|
680
|
+
repl_list.may_represent_declaration_specifiers_head?
|
|
681
|
+
W(node.location)
|
|
666
682
|
end
|
|
667
683
|
end
|
|
668
684
|
end
|
|
@@ -673,19 +689,19 @@ module CBuiltin #:nodoc:
|
|
|
673
689
|
|
|
674
690
|
# NOTE: W0479 may be duplicative when the same header which has
|
|
675
691
|
# typedef-able macro definition is included twice or more.
|
|
676
|
-
|
|
692
|
+
mark_as_unique
|
|
677
693
|
|
|
678
|
-
def initialize(
|
|
694
|
+
def initialize(phase_ctxt)
|
|
679
695
|
super
|
|
680
|
-
visitor =
|
|
681
|
-
visitor.enter_object_like_define_line +=
|
|
696
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
697
|
+
visitor.enter_object_like_define_line += T(:check)
|
|
682
698
|
end
|
|
683
699
|
|
|
684
700
|
private
|
|
685
701
|
def check(node)
|
|
686
|
-
if
|
|
687
|
-
if
|
|
688
|
-
W(
|
|
702
|
+
if repl_list = node.replacement_list
|
|
703
|
+
if repl_list.may_represent_specifier_qualifier_list?
|
|
704
|
+
W(node.location)
|
|
689
705
|
end
|
|
690
706
|
end
|
|
691
707
|
end
|
|
@@ -696,23 +712,22 @@ module CBuiltin #:nodoc:
|
|
|
696
712
|
|
|
697
713
|
# NOTE: W0480 may be duplicative when the same header which causes this
|
|
698
714
|
# warning is included twice or more.
|
|
699
|
-
|
|
715
|
+
mark_as_unique
|
|
700
716
|
|
|
701
|
-
def initialize(
|
|
717
|
+
def initialize(phase_ctxt)
|
|
702
718
|
super
|
|
703
|
-
visitor =
|
|
704
|
-
visitor.enter_object_like_define_line
|
|
705
|
-
visitor.enter_function_like_define_line
|
|
706
|
-
visitor.enter_va_function_like_define_line +=
|
|
719
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
720
|
+
visitor.enter_object_like_define_line += T(:check)
|
|
721
|
+
visitor.enter_function_like_define_line += T(:check)
|
|
722
|
+
visitor.enter_va_function_like_define_line += T(:check)
|
|
707
723
|
end
|
|
708
724
|
|
|
709
725
|
private
|
|
710
726
|
def check(node)
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
W(:W0480, node.location)
|
|
727
|
+
if repl_list = node.replacement_list and
|
|
728
|
+
repl_list.may_represent_punctuator? ||
|
|
729
|
+
repl_list.may_represent_controlling_keyword?
|
|
730
|
+
W(node.location)
|
|
716
731
|
end
|
|
717
732
|
end
|
|
718
733
|
end
|
|
@@ -722,21 +737,20 @@ module CBuiltin #:nodoc:
|
|
|
722
737
|
|
|
723
738
|
# NOTE: W0481 may be duplicative when the same header which causes this
|
|
724
739
|
# warning is included twice or more.
|
|
725
|
-
|
|
740
|
+
mark_as_unique
|
|
726
741
|
|
|
727
|
-
def initialize(
|
|
742
|
+
def initialize(phase_ctxt)
|
|
728
743
|
super
|
|
729
|
-
visitor =
|
|
730
|
-
visitor.enter_object_like_define_line
|
|
731
|
-
visitor.enter_function_like_define_line
|
|
732
|
-
visitor.enter_va_function_like_define_line +=
|
|
744
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
745
|
+
visitor.enter_object_like_define_line += T(:check)
|
|
746
|
+
visitor.enter_function_like_define_line += T(:check)
|
|
747
|
+
visitor.enter_va_function_like_define_line += T(:check)
|
|
733
748
|
end
|
|
734
749
|
|
|
735
750
|
private
|
|
736
751
|
def check(node)
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
W(:W0481, node.location)
|
|
752
|
+
if repl_list = node.replacement_list and repl_list.may_represent_block?
|
|
753
|
+
W(node.location)
|
|
740
754
|
end
|
|
741
755
|
end
|
|
742
756
|
end
|
|
@@ -746,26 +760,26 @@ module CBuiltin #:nodoc:
|
|
|
746
760
|
|
|
747
761
|
# NOTE: W0482 may be duplicative when the same header which causes this
|
|
748
762
|
# warning is included twice or more.
|
|
749
|
-
|
|
763
|
+
mark_as_unique
|
|
750
764
|
|
|
751
|
-
def initialize(
|
|
765
|
+
def initialize(phase_ctxt)
|
|
752
766
|
super
|
|
753
|
-
visitor =
|
|
754
|
-
visitor.enter_object_like_define_line +=
|
|
767
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
768
|
+
visitor.enter_object_like_define_line += T(:check)
|
|
755
769
|
end
|
|
756
770
|
|
|
757
771
|
private
|
|
758
772
|
def check(node)
|
|
759
|
-
if
|
|
760
|
-
return unless
|
|
761
|
-
if type_specifier?(
|
|
762
|
-
W(
|
|
773
|
+
if repl_list = node.replacement_list
|
|
774
|
+
return unless repl_list.tokens.size == 1
|
|
775
|
+
if type_specifier?(repl_list.tokens.first)
|
|
776
|
+
W(node.location)
|
|
763
777
|
end
|
|
764
778
|
end
|
|
765
779
|
end
|
|
766
780
|
|
|
767
|
-
def type_specifier?(
|
|
768
|
-
case
|
|
781
|
+
def type_specifier?(pp_tok)
|
|
782
|
+
case pp_tok.value
|
|
769
783
|
when "void", "char", "short", "int", "long", "float", "double"
|
|
770
784
|
true
|
|
771
785
|
when "signed", "unsigned"
|
|
@@ -783,19 +797,19 @@ module CBuiltin #:nodoc:
|
|
|
783
797
|
|
|
784
798
|
# NOTE: W0483 may be duplicative when the same header which causes this
|
|
785
799
|
# warning is included twice or more.
|
|
786
|
-
|
|
800
|
+
mark_as_unique
|
|
787
801
|
|
|
788
|
-
def initialize(
|
|
802
|
+
def initialize(phase_ctxt)
|
|
789
803
|
super
|
|
790
|
-
visitor =
|
|
791
|
-
visitor.enter_object_like_define_line +=
|
|
804
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
805
|
+
visitor.enter_object_like_define_line += T(:check)
|
|
792
806
|
end
|
|
793
807
|
|
|
794
808
|
private
|
|
795
809
|
def check(node)
|
|
796
|
-
if
|
|
797
|
-
if
|
|
798
|
-
W(
|
|
810
|
+
if repl_list = node.replacement_list
|
|
811
|
+
if repl_list.may_represent_declaration_specifiers_head?
|
|
812
|
+
W(node.location)
|
|
799
813
|
end
|
|
800
814
|
end
|
|
801
815
|
end
|
|
@@ -806,12 +820,16 @@ module CBuiltin #:nodoc:
|
|
|
806
820
|
|
|
807
821
|
# NOTE: W0511 may be duplicative when the same header which causes this
|
|
808
822
|
# warning is included twice or more.
|
|
809
|
-
|
|
823
|
+
mark_as_unique
|
|
810
824
|
|
|
811
|
-
def initialize(
|
|
825
|
+
def initialize(phase_ctxt)
|
|
812
826
|
super
|
|
813
|
-
|
|
814
|
-
|
|
827
|
+
phase_ctxt[:cpp_interpreter].on_line_comment_found += M(:check)
|
|
828
|
+
end
|
|
829
|
+
|
|
830
|
+
private
|
|
831
|
+
def check(*, loc)
|
|
832
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
815
833
|
end
|
|
816
834
|
end
|
|
817
835
|
|
|
@@ -820,21 +838,21 @@ module CBuiltin #:nodoc:
|
|
|
820
838
|
|
|
821
839
|
# NOTE: W0528 may be duplicative when the same header which causes this
|
|
822
840
|
# warning is included twice or more.
|
|
823
|
-
|
|
841
|
+
mark_as_unique
|
|
824
842
|
|
|
825
|
-
def initialize(
|
|
843
|
+
def initialize(phase_ctxt)
|
|
826
844
|
super
|
|
827
|
-
interp =
|
|
828
|
-
interp.on_object_like_macro_defined +=
|
|
845
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
846
|
+
interp.on_object_like_macro_defined += T(:check)
|
|
829
847
|
end
|
|
830
848
|
|
|
831
849
|
private
|
|
832
|
-
def check(
|
|
833
|
-
if
|
|
834
|
-
|
|
835
|
-
|
|
850
|
+
def check(*, macro)
|
|
851
|
+
if repl_list = macro.replacement_list
|
|
852
|
+
octal_tok = repl_list.tokens.find { |pp_tok|
|
|
853
|
+
pp_tok.value =~ /\A0[0-9]+[UL]*\z/i
|
|
836
854
|
}
|
|
837
|
-
W(
|
|
855
|
+
W(octal_tok.location) if octal_tok
|
|
838
856
|
end
|
|
839
857
|
end
|
|
840
858
|
end
|
|
@@ -844,17 +862,18 @@ module CBuiltin #:nodoc:
|
|
|
844
862
|
|
|
845
863
|
# NOTE: W0541 may be duplicative when the same header which causes this
|
|
846
864
|
# warning is included twice or more.
|
|
847
|
-
|
|
865
|
+
mark_as_unique
|
|
848
866
|
|
|
849
|
-
def initialize(
|
|
867
|
+
def initialize(phase_ctxt)
|
|
850
868
|
super
|
|
851
|
-
|
|
869
|
+
phase_ctxt[:cc1_source].on_inline_assembly += M(:check)
|
|
852
870
|
end
|
|
853
871
|
|
|
854
872
|
private
|
|
855
|
-
def check(
|
|
856
|
-
|
|
857
|
-
|
|
873
|
+
def check(asm_toks)
|
|
874
|
+
head_loc = asm_toks.first.location
|
|
875
|
+
if head_loc.in_analysis_target?(traits)
|
|
876
|
+
W(head_loc) unless asm_toks.any? { |tok| tok.replaced? }
|
|
858
877
|
end
|
|
859
878
|
end
|
|
860
879
|
end
|
|
@@ -864,36 +883,36 @@ module CBuiltin #:nodoc:
|
|
|
864
883
|
|
|
865
884
|
# NOTE: W0549 may be duplicative when the same header which causes this
|
|
866
885
|
# warning is included twice or more.
|
|
867
|
-
|
|
886
|
+
mark_as_unique
|
|
868
887
|
|
|
869
|
-
def initialize(
|
|
888
|
+
def initialize(phase_ctxt)
|
|
870
889
|
super
|
|
871
|
-
interp =
|
|
872
|
-
interp.on_function_like_macro_defined
|
|
873
|
-
interp.on_va_function_like_macro_defined +=
|
|
890
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
891
|
+
interp.on_function_like_macro_defined += T(:check)
|
|
892
|
+
interp.on_va_function_like_macro_defined += T(:check)
|
|
874
893
|
end
|
|
875
894
|
|
|
876
895
|
private
|
|
877
|
-
def check(
|
|
896
|
+
def check(*, macro)
|
|
878
897
|
return unless macro.replacement_list
|
|
879
898
|
|
|
880
899
|
macro.parameter_names.each do |name|
|
|
881
|
-
macro.replacement_list.tokens.each_with_index do |
|
|
882
|
-
next unless
|
|
900
|
+
macro.replacement_list.tokens.each_with_index do |pp_tok, idx|
|
|
901
|
+
next unless pp_tok.value == name
|
|
883
902
|
|
|
884
|
-
|
|
885
|
-
|
|
903
|
+
prv_tok = macro.replacement_list.tokens[[idx - 1, 0].max]
|
|
904
|
+
nxt_tok = macro.replacement_list.tokens[idx + 1]
|
|
886
905
|
|
|
887
|
-
next if
|
|
888
|
-
next if
|
|
906
|
+
next if prv_tok && prv_tok.value =~ /\A##?\z/
|
|
907
|
+
next if nxt_tok && nxt_tok.value == "##"
|
|
889
908
|
|
|
890
|
-
unless
|
|
891
|
-
W(
|
|
909
|
+
unless prv_tok && prv_tok.value == "("
|
|
910
|
+
W(pp_tok.location)
|
|
892
911
|
next
|
|
893
912
|
end
|
|
894
913
|
|
|
895
|
-
unless
|
|
896
|
-
W(
|
|
914
|
+
unless nxt_tok && nxt_tok.value == ")"
|
|
915
|
+
W(pp_tok.location)
|
|
897
916
|
next
|
|
898
917
|
end
|
|
899
918
|
end
|
|
@@ -906,17 +925,17 @@ module CBuiltin #:nodoc:
|
|
|
906
925
|
|
|
907
926
|
# NOTE: W0554 may be duplicative when the same header which causes this
|
|
908
927
|
# warning is included twice or more.
|
|
909
|
-
|
|
928
|
+
mark_as_unique
|
|
910
929
|
|
|
911
|
-
def initialize(
|
|
930
|
+
def initialize(phase_ctxt)
|
|
912
931
|
super
|
|
913
|
-
interp =
|
|
914
|
-
interp.on_unknown_pragma_evaled +=
|
|
932
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
933
|
+
interp.on_unknown_pragma_evaled += T(:check)
|
|
915
934
|
end
|
|
916
935
|
|
|
917
936
|
private
|
|
918
937
|
def check(pragma_line)
|
|
919
|
-
W(
|
|
938
|
+
W(pragma_line.location,
|
|
920
939
|
pragma_line.pp_tokens ? pragma_line.pp_tokens.to_s : "")
|
|
921
940
|
end
|
|
922
941
|
end
|
|
@@ -926,29 +945,29 @@ module CBuiltin #:nodoc:
|
|
|
926
945
|
|
|
927
946
|
# NOTE: W0574 may be duplicative when the same header which causes this
|
|
928
947
|
# warning is included twice or more.
|
|
929
|
-
|
|
948
|
+
mark_as_unique
|
|
930
949
|
|
|
931
|
-
def initialize(
|
|
950
|
+
def initialize(phase_ctxt)
|
|
932
951
|
super
|
|
933
|
-
interp =
|
|
934
|
-
interp.on_pp_token_extracted
|
|
935
|
-
interp.on_object_like_macro_defined
|
|
936
|
-
interp.on_function_like_macro_defined
|
|
937
|
-
interp.on_va_function_like_macro_defined +=
|
|
952
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
953
|
+
interp.on_pp_token_extracted += T(:check_pp_token)
|
|
954
|
+
interp.on_object_like_macro_defined += T(:check_macro)
|
|
955
|
+
interp.on_function_like_macro_defined += T(:check_macro)
|
|
956
|
+
interp.on_va_function_like_macro_defined += T(:check_macro)
|
|
938
957
|
end
|
|
939
958
|
|
|
940
959
|
private
|
|
941
|
-
def check_pp_token(
|
|
942
|
-
if
|
|
960
|
+
def check_pp_token(pp_tok)
|
|
961
|
+
if pp_tok.value =~ /\AL?'(.*)'\z/
|
|
943
962
|
unless Cpp::BasicSourceCharacterSet.include?($1)
|
|
944
|
-
W(
|
|
963
|
+
W(pp_tok.location)
|
|
945
964
|
end
|
|
946
965
|
end
|
|
947
966
|
end
|
|
948
967
|
|
|
949
|
-
def check_macro(
|
|
950
|
-
if
|
|
951
|
-
|
|
968
|
+
def check_macro(*, macro)
|
|
969
|
+
if repl_lsit = macro.replacement_list
|
|
970
|
+
repl_lsit.tokens.each { |pp_tok| check_pp_token(pp_tok) }
|
|
952
971
|
end
|
|
953
972
|
end
|
|
954
973
|
end
|
|
@@ -958,29 +977,29 @@ module CBuiltin #:nodoc:
|
|
|
958
977
|
|
|
959
978
|
# NOTE: W0575 may be duplicative when the same header which causes this
|
|
960
979
|
# warning is included twice or more.
|
|
961
|
-
|
|
980
|
+
mark_as_unique
|
|
962
981
|
|
|
963
|
-
def initialize(
|
|
982
|
+
def initialize(phase_ctxt)
|
|
964
983
|
super
|
|
965
|
-
interp =
|
|
966
|
-
interp.on_pp_token_extracted
|
|
967
|
-
interp.on_object_like_macro_defined
|
|
968
|
-
interp.on_function_like_macro_defined
|
|
969
|
-
interp.on_va_function_like_macro_defined +=
|
|
984
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
985
|
+
interp.on_pp_token_extracted += T(:check_pp_token)
|
|
986
|
+
interp.on_object_like_macro_defined += T(:check_macro)
|
|
987
|
+
interp.on_function_like_macro_defined += T(:check_macro)
|
|
988
|
+
interp.on_va_function_like_macro_defined += T(:check_macro)
|
|
970
989
|
end
|
|
971
990
|
|
|
972
991
|
private
|
|
973
|
-
def check_pp_token(
|
|
974
|
-
if
|
|
992
|
+
def check_pp_token(pp_tok)
|
|
993
|
+
if pp_tok.value =~ /\AL?"(.*)"\z/
|
|
975
994
|
unless Cpp::BasicSourceCharacterSet.include?($1)
|
|
976
|
-
W(
|
|
995
|
+
W(pp_tok.location)
|
|
977
996
|
end
|
|
978
997
|
end
|
|
979
998
|
end
|
|
980
999
|
|
|
981
|
-
def check_macro(
|
|
982
|
-
if
|
|
983
|
-
|
|
1000
|
+
def check_macro(*, macro)
|
|
1001
|
+
if repl_list = macro.replacement_list
|
|
1002
|
+
repl_list.tokens.each { |pp_tok| check_pp_token(pp_tok) }
|
|
984
1003
|
end
|
|
985
1004
|
end
|
|
986
1005
|
end
|
|
@@ -990,25 +1009,25 @@ module CBuiltin #:nodoc:
|
|
|
990
1009
|
|
|
991
1010
|
# NOTE: W0576 may be duplicative when the same header which causes this
|
|
992
1011
|
# warning is included twice or more.
|
|
993
|
-
|
|
1012
|
+
mark_as_unique
|
|
994
1013
|
|
|
995
|
-
def initialize(
|
|
1014
|
+
def initialize(phase_ctxt)
|
|
996
1015
|
super
|
|
997
|
-
interp =
|
|
998
|
-
interp.on_block_comment_found +=
|
|
999
|
-
interp.on_line_comment_found
|
|
1016
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
1017
|
+
interp.on_block_comment_found += M(:check)
|
|
1018
|
+
interp.on_line_comment_found += M(:check)
|
|
1000
1019
|
@warned_chars = Set.new
|
|
1001
1020
|
end
|
|
1002
1021
|
|
|
1003
1022
|
private
|
|
1004
|
-
def check(comment,
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1023
|
+
def check(comment, loc)
|
|
1024
|
+
if loc.in_analysis_target?(traits)
|
|
1025
|
+
not_adapted = Cpp::BasicSourceCharacterSet.select_not_adapted(comment)
|
|
1026
|
+
new_chars = not_adapted.to_set - @warned_chars
|
|
1027
|
+
unless new_chars.empty?
|
|
1028
|
+
W(loc, loc.fpath)
|
|
1029
|
+
@warned_chars.merge(new_chars)
|
|
1030
|
+
end
|
|
1012
1031
|
end
|
|
1013
1032
|
end
|
|
1014
1033
|
end
|
|
@@ -1018,20 +1037,22 @@ module CBuiltin #:nodoc:
|
|
|
1018
1037
|
|
|
1019
1038
|
# NOTE: W0577 may be duplicative when the same header which causes this
|
|
1020
1039
|
# warning is included twice or more.
|
|
1021
|
-
|
|
1040
|
+
mark_as_unique
|
|
1022
1041
|
|
|
1023
|
-
def initialize(
|
|
1042
|
+
def initialize(phase_ctxt)
|
|
1024
1043
|
super
|
|
1025
|
-
interp =
|
|
1026
|
-
interp.on_unlexable_char_found +=
|
|
1044
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
1045
|
+
interp.on_unlexable_char_found += M(:check)
|
|
1027
1046
|
@warned = false
|
|
1028
1047
|
end
|
|
1029
1048
|
|
|
1030
1049
|
private
|
|
1031
|
-
def check(
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1050
|
+
def check(*, loc)
|
|
1051
|
+
if loc.in_analysis_target?(traits)
|
|
1052
|
+
unless @warned
|
|
1053
|
+
W(loc, loc.fpath)
|
|
1054
|
+
@warned = true
|
|
1055
|
+
end
|
|
1035
1056
|
end
|
|
1036
1057
|
end
|
|
1037
1058
|
end
|
|
@@ -1041,19 +1062,19 @@ module CBuiltin #:nodoc:
|
|
|
1041
1062
|
|
|
1042
1063
|
# NOTE: W0632 may be duplicative when the same header which has references
|
|
1043
1064
|
# to the undefined macro is included twice or more.
|
|
1044
|
-
|
|
1065
|
+
mark_as_unique
|
|
1045
1066
|
|
|
1046
|
-
def initialize(
|
|
1067
|
+
def initialize(phase_ctxt)
|
|
1047
1068
|
super
|
|
1048
|
-
visitor =
|
|
1049
|
-
visitor.enter_system_include_line
|
|
1050
|
-
visitor.enter_system_include_next_line +=
|
|
1069
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
1070
|
+
visitor.enter_system_include_line += T(:check)
|
|
1071
|
+
visitor.enter_system_include_next_line += T(:check)
|
|
1051
1072
|
end
|
|
1052
1073
|
|
|
1053
1074
|
private
|
|
1054
1075
|
def check(include_line)
|
|
1055
1076
|
if include_line.header_name.value =~ /['"]/
|
|
1056
|
-
W(
|
|
1077
|
+
W(include_line.location, include_line.header_name.value)
|
|
1057
1078
|
end
|
|
1058
1079
|
end
|
|
1059
1080
|
end
|
|
@@ -1063,19 +1084,19 @@ module CBuiltin #:nodoc:
|
|
|
1063
1084
|
|
|
1064
1085
|
# NOTE: W0633 may be duplicative when the same header which has references
|
|
1065
1086
|
# to the undefined macro is included twice or more.
|
|
1066
|
-
|
|
1087
|
+
mark_as_unique
|
|
1067
1088
|
|
|
1068
|
-
def initialize(
|
|
1089
|
+
def initialize(phase_ctxt)
|
|
1069
1090
|
super
|
|
1070
|
-
visitor =
|
|
1071
|
-
visitor.enter_user_include_line
|
|
1072
|
-
visitor.enter_user_include_next_line +=
|
|
1091
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
1092
|
+
visitor.enter_user_include_line += T(:check)
|
|
1093
|
+
visitor.enter_user_include_next_line += T(:check)
|
|
1073
1094
|
end
|
|
1074
1095
|
|
|
1075
1096
|
private
|
|
1076
1097
|
def check(include_line)
|
|
1077
1098
|
if include_line.header_name.value =~ /'/
|
|
1078
|
-
W(
|
|
1099
|
+
W(include_line.location, include_line.header_name.value)
|
|
1079
1100
|
end
|
|
1080
1101
|
end
|
|
1081
1102
|
end
|
|
@@ -1085,21 +1106,21 @@ module CBuiltin #:nodoc:
|
|
|
1085
1106
|
|
|
1086
1107
|
# NOTE: W0634 may be duplicative when the same header which has references
|
|
1087
1108
|
# to the undefined macro is included twice or more.
|
|
1088
|
-
|
|
1109
|
+
mark_as_unique
|
|
1089
1110
|
|
|
1090
|
-
def initialize(
|
|
1111
|
+
def initialize(phase_ctxt)
|
|
1091
1112
|
super
|
|
1092
|
-
visitor =
|
|
1093
|
-
visitor.enter_user_include_line
|
|
1094
|
-
visitor.enter_user_include_next_line
|
|
1095
|
-
visitor.enter_system_include_line
|
|
1096
|
-
visitor.enter_system_include_next_line +=
|
|
1113
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
1114
|
+
visitor.enter_user_include_line += T(:check)
|
|
1115
|
+
visitor.enter_user_include_next_line += T(:check)
|
|
1116
|
+
visitor.enter_system_include_line += T(:check)
|
|
1117
|
+
visitor.enter_system_include_next_line += T(:check)
|
|
1097
1118
|
end
|
|
1098
1119
|
|
|
1099
1120
|
private
|
|
1100
1121
|
def check(include_line)
|
|
1101
1122
|
if include_line.header_name.value.include?("\\")
|
|
1102
|
-
W(
|
|
1123
|
+
W(include_line.location)
|
|
1103
1124
|
end
|
|
1104
1125
|
end
|
|
1105
1126
|
end
|
|
@@ -1109,13 +1130,17 @@ module CBuiltin #:nodoc:
|
|
|
1109
1130
|
|
|
1110
1131
|
# NOTE: W0643 may be duplicative when the same header which has references
|
|
1111
1132
|
# to the undefined macro is included twice or more.
|
|
1112
|
-
|
|
1133
|
+
mark_as_unique
|
|
1113
1134
|
|
|
1114
|
-
def initialize(
|
|
1135
|
+
def initialize(phase_ctxt)
|
|
1115
1136
|
super
|
|
1116
|
-
macro_table =
|
|
1117
|
-
macro_table.on_last_backslash_ignored +=
|
|
1118
|
-
|
|
1137
|
+
macro_table = phase_ctxt[:cpp_macro_table]
|
|
1138
|
+
macro_table.on_last_backslash_ignored += T(:check)
|
|
1139
|
+
end
|
|
1140
|
+
|
|
1141
|
+
private
|
|
1142
|
+
def check(tok)
|
|
1143
|
+
W(tok.location)
|
|
1119
1144
|
end
|
|
1120
1145
|
end
|
|
1121
1146
|
|
|
@@ -1124,17 +1149,17 @@ module CBuiltin #:nodoc:
|
|
|
1124
1149
|
|
|
1125
1150
|
# NOTE: W0691 may be duplicative when the same header which has references
|
|
1126
1151
|
# to the undefined macro is included twice or more.
|
|
1127
|
-
|
|
1152
|
+
mark_as_unique
|
|
1128
1153
|
|
|
1129
|
-
def initialize(
|
|
1154
|
+
def initialize(phase_ctxt)
|
|
1130
1155
|
super
|
|
1131
|
-
macro_table =
|
|
1132
|
-
macro_table.on_sharpsharp_operator_evaled +=
|
|
1156
|
+
macro_table = phase_ctxt[:cpp_macro_table]
|
|
1157
|
+
macro_table.on_sharpsharp_operator_evaled += T(:check)
|
|
1133
1158
|
end
|
|
1134
1159
|
|
|
1135
1160
|
private
|
|
1136
|
-
def check(
|
|
1137
|
-
W(
|
|
1161
|
+
def check(*, new_toks)
|
|
1162
|
+
W(new_toks.first.location) if new_toks.size > 1
|
|
1138
1163
|
end
|
|
1139
1164
|
end
|
|
1140
1165
|
|
|
@@ -1143,19 +1168,19 @@ module CBuiltin #:nodoc:
|
|
|
1143
1168
|
|
|
1144
1169
|
# NOTE: W0692 may be duplicative when the same header which has references
|
|
1145
1170
|
# to the undefined macro is included twice or more.
|
|
1146
|
-
|
|
1171
|
+
mark_as_unique
|
|
1147
1172
|
|
|
1148
|
-
def initialize(
|
|
1173
|
+
def initialize(phase_ctxt)
|
|
1149
1174
|
super
|
|
1150
|
-
macro_table =
|
|
1151
|
-
macro_table.on_function_like_macro_replacement +=
|
|
1175
|
+
macro_table = phase_ctxt[:cpp_macro_table]
|
|
1176
|
+
macro_table.on_function_like_macro_replacement += T(:check)
|
|
1152
1177
|
end
|
|
1153
1178
|
|
|
1154
1179
|
private
|
|
1155
|
-
def check(macro,
|
|
1180
|
+
def check(macro, repl_toks, args, *)
|
|
1156
1181
|
unless macro.parameter_names.empty?
|
|
1157
1182
|
if args.any? { |arg| arg.empty? }
|
|
1158
|
-
W(
|
|
1183
|
+
W(repl_toks.first.location, macro.name.value)
|
|
1159
1184
|
end
|
|
1160
1185
|
end
|
|
1161
1186
|
end
|
|
@@ -1166,13 +1191,17 @@ module CBuiltin #:nodoc:
|
|
|
1166
1191
|
|
|
1167
1192
|
# NOTE: W0696 may be duplicative when the same header which has references
|
|
1168
1193
|
# to the undefined macro is included twice or more.
|
|
1169
|
-
|
|
1194
|
+
mark_as_unique
|
|
1170
1195
|
|
|
1171
|
-
def initialize(
|
|
1196
|
+
def initialize(phase_ctxt)
|
|
1172
1197
|
super
|
|
1173
|
-
interp =
|
|
1174
|
-
interp.on_undefined_macro_referred +=
|
|
1175
|
-
|
|
1198
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
1199
|
+
interp.on_undefined_macro_referred += T(:check)
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
private
|
|
1203
|
+
def check(tok)
|
|
1204
|
+
W(tok.location, tok.value)
|
|
1176
1205
|
end
|
|
1177
1206
|
end
|
|
1178
1207
|
|
|
@@ -1181,16 +1210,16 @@ module CBuiltin #:nodoc:
|
|
|
1181
1210
|
|
|
1182
1211
|
# NOTE: W0804 may be duplicative when the same header which causes this
|
|
1183
1212
|
# warning is included twice or more.
|
|
1184
|
-
|
|
1213
|
+
mark_as_unique
|
|
1185
1214
|
|
|
1186
|
-
def initialize(
|
|
1215
|
+
def initialize(phase_ctxt)
|
|
1187
1216
|
super
|
|
1188
|
-
|
|
1217
|
+
phase_ctxt[:cpp_interpreter].on_illformed_defined_op_found += M(:check)
|
|
1189
1218
|
end
|
|
1190
1219
|
|
|
1191
1220
|
private
|
|
1192
|
-
def check(
|
|
1193
|
-
W(
|
|
1221
|
+
def check(loc, *)
|
|
1222
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
1194
1223
|
end
|
|
1195
1224
|
end
|
|
1196
1225
|
|
|
@@ -1199,11 +1228,13 @@ module CBuiltin #:nodoc:
|
|
|
1199
1228
|
|
|
1200
1229
|
# NOTE: W0805 may be duplicative when the same header which causes this
|
|
1201
1230
|
# warning is included twice or more.
|
|
1202
|
-
|
|
1231
|
+
mark_as_unique
|
|
1203
1232
|
|
|
1204
1233
|
private
|
|
1205
|
-
def check(
|
|
1206
|
-
|
|
1234
|
+
def check(loc, no_args)
|
|
1235
|
+
if loc.in_analysis_target?(traits)
|
|
1236
|
+
W(loc) unless no_args
|
|
1237
|
+
end
|
|
1207
1238
|
end
|
|
1208
1239
|
end
|
|
1209
1240
|
|
|
@@ -1212,19 +1243,19 @@ module CBuiltin #:nodoc:
|
|
|
1212
1243
|
|
|
1213
1244
|
# NOTE: W0811 may be duplicative when the same header which causes this
|
|
1214
1245
|
# warning is included twice or more.
|
|
1215
|
-
|
|
1246
|
+
mark_as_unique
|
|
1216
1247
|
|
|
1217
|
-
def initialize(
|
|
1248
|
+
def initialize(phase_ctxt)
|
|
1218
1249
|
super
|
|
1219
|
-
macro_table =
|
|
1220
|
-
macro_table.on_object_like_macro_replacement
|
|
1221
|
-
macro_table.on_function_like_macro_replacement +=
|
|
1250
|
+
macro_table = phase_ctxt[:cpp_macro_table]
|
|
1251
|
+
macro_table.on_object_like_macro_replacement += T(:check)
|
|
1252
|
+
macro_table.on_function_like_macro_replacement += T(:check)
|
|
1222
1253
|
end
|
|
1223
1254
|
|
|
1224
1255
|
private
|
|
1225
|
-
def check(*,
|
|
1226
|
-
if
|
|
1227
|
-
W(
|
|
1256
|
+
def check(*, res_toks)
|
|
1257
|
+
if defined_tok = res_toks.find { |tok| tok.value == "defined" }
|
|
1258
|
+
W(defined_tok.location)
|
|
1228
1259
|
end
|
|
1229
1260
|
end
|
|
1230
1261
|
end
|
|
@@ -1234,17 +1265,17 @@ module CBuiltin #:nodoc:
|
|
|
1234
1265
|
|
|
1235
1266
|
# NOTE: W0831 may be duplicative when the same header which causes this
|
|
1236
1267
|
# warning is included twice or more.
|
|
1237
|
-
|
|
1268
|
+
mark_as_unique
|
|
1238
1269
|
|
|
1239
|
-
def initialize(
|
|
1270
|
+
def initialize(phase_ctxt)
|
|
1240
1271
|
super
|
|
1241
|
-
interp =
|
|
1242
|
-
interp.on_asm_section_evaled +=
|
|
1272
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
1273
|
+
interp.on_asm_section_evaled += T(:check)
|
|
1243
1274
|
end
|
|
1244
1275
|
|
|
1245
1276
|
private
|
|
1246
1277
|
def check(asm_section)
|
|
1247
|
-
W(
|
|
1278
|
+
W(asm_section.location)
|
|
1248
1279
|
end
|
|
1249
1280
|
end
|
|
1250
1281
|
|
|
@@ -1253,16 +1284,17 @@ module CBuiltin #:nodoc:
|
|
|
1253
1284
|
|
|
1254
1285
|
# NOTE: W0832 may be duplicative when the same header which causes this
|
|
1255
1286
|
# warning is included twice or more.
|
|
1256
|
-
|
|
1287
|
+
mark_as_unique
|
|
1257
1288
|
|
|
1258
|
-
def initialize(
|
|
1289
|
+
def initialize(phase_ctxt)
|
|
1259
1290
|
super
|
|
1260
|
-
|
|
1291
|
+
phase_ctxt[:cc1_source].on_inline_assembly += M(:check)
|
|
1261
1292
|
end
|
|
1262
1293
|
|
|
1263
1294
|
private
|
|
1264
|
-
def check(
|
|
1265
|
-
|
|
1295
|
+
def check(asm_toks)
|
|
1296
|
+
head_loc = asm_toks.first.location
|
|
1297
|
+
W(head_loc) if head_loc.in_analysis_target?(traits)
|
|
1266
1298
|
end
|
|
1267
1299
|
end
|
|
1268
1300
|
|
|
@@ -1271,17 +1303,18 @@ module CBuiltin #:nodoc:
|
|
|
1271
1303
|
|
|
1272
1304
|
# NOTE: W1040 may be duplicative when the same header which causes this
|
|
1273
1305
|
# warning is included twice or more.
|
|
1274
|
-
|
|
1306
|
+
mark_as_unique
|
|
1275
1307
|
|
|
1276
|
-
def initialize(
|
|
1308
|
+
def initialize(phase_ctxt)
|
|
1277
1309
|
super
|
|
1278
|
-
interp =
|
|
1279
|
-
interp.on_extra_tokens_found +=
|
|
1310
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
1311
|
+
interp.on_extra_tokens_found += M(:check)
|
|
1280
1312
|
end
|
|
1281
1313
|
|
|
1282
1314
|
private
|
|
1283
|
-
def check(
|
|
1284
|
-
|
|
1315
|
+
def check(extra_toks)
|
|
1316
|
+
head_loc = extra_toks.first.location
|
|
1317
|
+
W(head_loc) if head_loc.in_analysis_target?(traits)
|
|
1285
1318
|
end
|
|
1286
1319
|
end
|
|
1287
1320
|
|
|
@@ -1290,17 +1323,17 @@ module CBuiltin #:nodoc:
|
|
|
1290
1323
|
|
|
1291
1324
|
# NOTE: W1041 may be duplicative when the same header which causes this
|
|
1292
1325
|
# warning is included twice or more.
|
|
1293
|
-
|
|
1326
|
+
mark_as_unique
|
|
1294
1327
|
|
|
1295
|
-
def initialize(
|
|
1328
|
+
def initialize(phase_ctxt)
|
|
1296
1329
|
super
|
|
1297
|
-
visitor =
|
|
1298
|
-
visitor.enter_unknown_directive +=
|
|
1330
|
+
visitor = phase_ctxt[:cpp_visitor]
|
|
1331
|
+
visitor.enter_unknown_directive += T(:check)
|
|
1299
1332
|
end
|
|
1300
1333
|
|
|
1301
1334
|
private
|
|
1302
1335
|
def check(node)
|
|
1303
|
-
W(
|
|
1336
|
+
W(node.location, node.token.value.chomp.strip)
|
|
1304
1337
|
end
|
|
1305
1338
|
end
|
|
1306
1339
|
|
|
@@ -1309,13 +1342,17 @@ module CBuiltin #:nodoc:
|
|
|
1309
1342
|
|
|
1310
1343
|
# NOTE: W1046 may be duplicative when the same header which causes this
|
|
1311
1344
|
# warning is included twice or more.
|
|
1312
|
-
|
|
1345
|
+
mark_as_unique
|
|
1313
1346
|
|
|
1314
|
-
def initialize(
|
|
1347
|
+
def initialize(phase_ctxt)
|
|
1315
1348
|
super
|
|
1316
|
-
interp =
|
|
1317
|
-
interp.on_illformed_newline_escape_found +=
|
|
1318
|
-
|
|
1349
|
+
interp = phase_ctxt[:cpp_interpreter]
|
|
1350
|
+
interp.on_illformed_newline_escape_found += M(:check)
|
|
1351
|
+
end
|
|
1352
|
+
|
|
1353
|
+
private
|
|
1354
|
+
def check(loc)
|
|
1355
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
1319
1356
|
end
|
|
1320
1357
|
end
|
|
1321
1358
|
|
|
@@ -1324,12 +1361,20 @@ module CBuiltin #:nodoc:
|
|
|
1324
1361
|
|
|
1325
1362
|
# NOTE: W9002 may be duplicative when the same header which has no newline
|
|
1326
1363
|
# at end of the file is included twice or more.
|
|
1327
|
-
|
|
1364
|
+
mark_as_unique
|
|
1328
1365
|
|
|
1329
|
-
|
|
1366
|
+
# NOTE: W9002 may be detected before evaluating the annotation for message
|
|
1367
|
+
# suppression.
|
|
1368
|
+
mark_as_deferred
|
|
1369
|
+
|
|
1370
|
+
def initialize(phase_ctxt)
|
|
1330
1371
|
super
|
|
1331
|
-
|
|
1332
|
-
|
|
1372
|
+
phase_ctxt[:cpp_interpreter].on_eof_newline_not_found += M(:check)
|
|
1373
|
+
end
|
|
1374
|
+
|
|
1375
|
+
private
|
|
1376
|
+
def check(loc)
|
|
1377
|
+
W(loc) if loc.in_analysis_target?(traits)
|
|
1333
1378
|
end
|
|
1334
1379
|
end
|
|
1335
1380
|
|