adlint 1.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 +27 -0
- data/COPYING +674 -0
- data/ChangeLog +820 -0
- data/INSTALL +78 -0
- data/MANIFEST +464 -0
- data/NEWS +38 -0
- data/README +74 -0
- data/Rakefile +167 -0
- data/TODO +29 -0
- data/bin/adlint +141 -0
- data/bin/adlint_chk +129 -0
- data/bin/adlint_cma +122 -0
- data/bin/adlint_sma +129 -0
- data/bin/adlintize +286 -0
- data/etc/conf.d/fallback/cinit.erb +11 -0
- data/etc/conf.d/fallback/traits.erb +216 -0
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +149 -0
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +227 -0
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +224 -0
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +226 -0
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +219 -0
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +224 -0
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +234 -0
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +226 -0
- data/etc/conf.d/noarch/GNUmakefile.erb +119 -0
- data/etc/conf.d/noarch/adlint_all_bat.erb +9 -0
- data/etc/conf.d/noarch/adlint_all_sh.erb +10 -0
- data/etc/conf.d/noarch/pinit.erb +11 -0
- data/etc/mesg.d/en_US/messages.yml +784 -0
- data/etc/mesg.d/ja_JP/messages.yml +784 -0
- data/lib/adlint/analyzer.rb +294 -0
- data/lib/adlint/c/branch.rb +251 -0
- data/lib/adlint/c/builtin.rb +92 -0
- data/lib/adlint/c/code.rb +490 -0
- data/lib/adlint/c/const.rb +465 -0
- data/lib/adlint/c/conv.rb +212 -0
- data/lib/adlint/c/ctrlexpr.rb +949 -0
- data/lib/adlint/c/domain.rb +7499 -0
- data/lib/adlint/c/environ.rb +133 -0
- data/lib/adlint/c/expr.rb +1725 -0
- data/lib/adlint/c/format.rb +3209 -0
- data/lib/adlint/c/interp.rb +1740 -0
- data/lib/adlint/c/lexer.rb +241 -0
- data/lib/adlint/c/mediator.rb +313 -0
- data/lib/adlint/c/message.rb +13597 -0
- data/lib/adlint/c/metric.rb +765 -0
- data/lib/adlint/c/object.rb +1018 -0
- data/lib/adlint/c/parser.rb +3800 -0
- data/lib/adlint/c/parser.y +2054 -0
- data/lib/adlint/c/phase.rb +712 -0
- data/lib/adlint/c/resolver.rb +270 -0
- data/lib/adlint/c/scanner.rb +248 -0
- data/lib/adlint/c/scope.rb +74 -0
- data/lib/adlint/c/syntax.rb +4279 -0
- data/lib/adlint/c/type.rb +7506 -0
- data/lib/adlint/c/util.rb +91 -0
- data/lib/adlint/c/value.rb +2310 -0
- data/lib/adlint/c.rb +56 -0
- data/lib/adlint/code.rb +500 -0
- data/lib/adlint/cpp/code.rb +189 -0
- data/lib/adlint/cpp/constexpr.rb +721 -0
- data/lib/adlint/cpp/constexpr.y +389 -0
- data/lib/adlint/cpp/eval.rb +1012 -0
- data/lib/adlint/cpp/lexer.rb +860 -0
- data/lib/adlint/cpp/macro.rb +637 -0
- data/lib/adlint/cpp/message.rb +992 -0
- data/lib/adlint/cpp/phase.rb +176 -0
- data/lib/adlint/cpp/scanner.rb +93 -0
- data/lib/adlint/cpp/source.rb +169 -0
- data/lib/adlint/cpp/subst.rb +300 -0
- data/lib/adlint/cpp/syntax.rb +1412 -0
- data/lib/adlint/cpp/util.rb +97 -0
- data/lib/adlint/cpp.rb +43 -0
- data/lib/adlint/driver.rb +147 -0
- data/lib/adlint/error.rb +179 -0
- data/lib/adlint/lang.rb +97 -0
- data/lib/adlint/ld/message.rb +259 -0
- data/lib/adlint/ld/metric.rb +57 -0
- data/lib/adlint/ld/object.rb +542 -0
- data/lib/adlint/ld/phase.rb +193 -0
- data/lib/adlint/ld/typedef.rb +109 -0
- data/lib/adlint/ld/util.rb +88 -0
- data/lib/adlint/ld.rb +37 -0
- data/lib/adlint/lexer.rb +293 -0
- data/lib/adlint/message.rb +368 -0
- data/lib/adlint/metric.rb +805 -0
- data/lib/adlint/monitor.rb +144 -0
- data/lib/adlint/phase.rb +90 -0
- data/lib/adlint/prelude.rb +314 -0
- data/lib/adlint/report.rb +617 -0
- data/lib/adlint/source.rb +155 -0
- data/lib/adlint/symbol.rb +127 -0
- data/lib/adlint/token.rb +215 -0
- data/lib/adlint/traits.rb +643 -0
- data/lib/adlint/util.rb +524 -0
- data/lib/adlint/version.rb +71 -0
- data/lib/adlint.rb +66 -0
- data/share/HEADER +45 -0
- data/share/demo/Makefile +110 -0
- data/share/demo/ambig_operator/ambig_operator.c +289 -0
- data/share/demo/arg_points_unset/arg_points_unset.c +37 -0
- data/share/demo/array_range/array_range.c +62 -0
- data/share/demo/bad_bitfields/bad_bitfields.c +74 -0
- data/share/demo/bad_brace/bad_brace.c +19 -0
- data/share/demo/bad_charset/abcde$.h +0 -0
- data/share/demo/bad_charset/bad_charset.c +22 -0
- data/share/demo/bad_comment/bad_comment.c +3 -0
- data/share/demo/bad_const/bad_const.c +19 -0
- data/share/demo/bad_conv/bad_conv.c +48 -0
- data/share/demo/bad_indent/bad_indent.c +50 -0
- data/share/demo/bad_init/bad_init.c +49 -0
- data/share/demo/bad_macro/bad_macro.c +97 -0
- data/share/demo/bitwise_expr/bitwise_expr.c +19 -0
- data/share/demo/call_by_value/call_by_value.c +26 -0
- data/share/demo/cross_ref/cross_ref.c +21 -0
- data/share/demo/dangling_else/dangling_else.c +20 -0
- data/share/demo/dead_code/dead_code.c +237 -0
- data/share/demo/deep_nest/deep_nest.c +57 -0
- data/share/demo/dense_switch/dense_switch.c +62 -0
- data/share/demo/direct_recur/direct_recur.c +15 -0
- data/share/demo/div_by_zero/div_by_zero.c +35 -0
- data/share/demo/dos_source/dos_source.c +7 -0
- data/share/demo/funptr_cast/funptr_cast.c +26 -0
- data/share/demo/goto_stmt/goto_stmt.c +19 -0
- data/share/demo/id_hiding/id_hiding.c +19 -0
- data/share/demo/ill_defined/ill_defined.c +13 -0
- data/share/demo/implicit_conv/implicit_conv.c +60 -0
- data/share/demo/implicit_int/implicit_int.c +14 -0
- data/share/demo/incomplete_type/incomplete_type.c +49 -0
- data/share/demo/indirect_recur/indirect_recur_1.c +14 -0
- data/share/demo/indirect_recur/indirect_recur_1.h +7 -0
- data/share/demo/indirect_recur/indirect_recur_2.c +12 -0
- data/share/demo/indirect_recur/indirect_recur_2.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.c +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_4.c +25 -0
- data/share/demo/intro_demo/intro_demo.c +76 -0
- data/share/demo/intro_demo/intro_demo.h +12 -0
- data/share/demo/intro_demo/useless_header.h +5 -0
- data/share/demo/invalid_call/invalid_call.c +32 -0
- data/share/demo/kandr_fundef/kandr_fundef.c +10 -0
- data/share/demo/line_comment/line_comment.c +12 -0
- data/share/demo/local_decl/local_decl.c +9 -0
- data/share/demo/logical_trick/logical_trick.c +36 -0
- data/share/demo/long_sym/long_sym.c +5 -0
- data/share/demo/loop_var/loop_var.c +92 -0
- data/share/demo/malloc_or_die/malloc_or_die.c +43 -0
- data/share/demo/may_be_null/may_be_null.c +52 -0
- data/share/demo/may_be_null_arith/may_be_null_arith.c +15 -0
- data/share/demo/may_be_unset/may_be_unset.c +34 -0
- data/share/demo/mmapped_io/mmapped_io.c +23 -0
- data/share/demo/multi_break/multi_break.c +33 -0
- data/share/demo/multi_decl/multi_decl_1.c +17 -0
- data/share/demo/multi_decl/multi_decl_1.h +6 -0
- data/share/demo/multi_decl/multi_decl_2.c +13 -0
- data/share/demo/multi_decl/multi_decl_2.h +6 -0
- data/share/demo/multi_decl/multi_decl_3.c +22 -0
- data/share/demo/multi_def/multi_def_1.c +36 -0
- data/share/demo/multi_def/multi_def_1.h +6 -0
- data/share/demo/multi_def/multi_def_2.c +22 -0
- data/share/demo/multi_def/multi_def_2.h +6 -0
- data/share/demo/multi_def/multi_def_3.c +6 -0
- data/share/demo/multi_typedef/multi_typedef.c +11 -0
- data/share/demo/multi_typedef/multi_typedef_1.h +1 -0
- data/share/demo/multi_typedef/multi_typedef_2.h +1 -0
- data/share/demo/must_be_false/must_be_false.c +53 -0
- data/share/demo/must_be_null/must_be_null.c +13 -0
- data/share/demo/must_be_null_arith/must_be_null_arith.c +14 -0
- data/share/demo/must_be_true/must_be_true.c +21 -0
- data/share/demo/no_eof_nl/no_eof_nl.c +4 -0
- data/share/demo/no_void_arg/no_void_arg.c +14 -0
- data/share/demo/null_stmt/null_stmt.c +19 -0
- data/share/demo/octal_const/octal_const.c +20 -0
- data/share/demo/output_by_param/output_by_param.c +17 -0
- data/share/demo/overflow/overflow.c +74 -0
- data/share/demo/press_release/press_release.c +40 -0
- data/share/demo/retn_lvar_addr/retn_lvar_addr.c +47 -0
- data/share/demo/shift_expr/shift_expr.c +14 -0
- data/share/demo/should_be_typedef/should_be_typedef.c +51 -0
- data/share/demo/static_paths/static_paths.c +153 -0
- data/share/demo/static_vars/static_vars.c +39 -0
- data/share/demo/tag_hiding/tag_hiding.c +18 -0
- data/share/demo/tricky_incdec/tricky_incdec.c +12 -0
- data/share/demo/undefined_macro/undefined_macro.c +17 -0
- data/share/demo/uninit_vars/uninit_vars.c +28 -0
- data/share/demo/union_type/union_type.c +23 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.c +12 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.c +10 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_3.c +7 -0
- data/share/demo/unmatch_paren_macro/unmatch_paren_macro.c +15 -0
- data/share/demo/unreachable/unreachable.c +34 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.c +14 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.h +1 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_2.c +6 -0
- data/share/demo/useless_exp_vars/useless_export_1.c +8 -0
- data/share/demo/useless_exp_vars/useless_export_1.h +1 -0
- data/share/demo/useless_exp_vars/useless_export_2.c +7 -0
- data/share/demo/useless_expr/useless_expr.c +17 -0
- data/share/demo/useless_funs/useless_funs_1.c +21 -0
- data/share/demo/useless_funs/useless_funs_1.h +8 -0
- data/share/demo/useless_funs/useless_funs_2.c +6 -0
- data/share/demo/useless_header/useless_header.c +9 -0
- data/share/demo/useless_header/useless_header_1.h +12 -0
- data/share/demo/useless_header/useless_header_2.h +6 -0
- data/share/demo/useless_header/useless_header_3.h +9 -0
- data/share/demo/useless_header/useless_header_4.h +3 -0
- data/share/demo/useless_vars/useless_vars.c +17 -0
- data/share/demo/va_funcall/va_funcall.c +25 -0
- data/share/demo/various_fundef/various_fundef.c +36 -0
- data/share/demo/wchar_wstring/wchar_wstring.c +7 -0
- data/share/demo/wrap_around/wrap_around.c +38 -0
- data/share/doc/Makefile +16 -0
- data/share/doc/adlint_on_adqua.png +0 -0
- data/share/doc/adlint_on_eclipse_en.png +0 -0
- data/share/doc/adlint_on_eclipse_ja.png +0 -0
- data/share/doc/adlint_on_vim_en.png +0 -0
- data/share/doc/adlint_on_vim_ja.png +0 -0
- data/share/doc/developers_guide_ja.html +171 -0
- data/share/doc/developers_guide_ja.texi +87 -0
- data/share/doc/gen_mesg_sections.rb +39 -0
- data/share/doc/samples/GNUmakefile +162 -0
- data/share/doc/samples/adlint_traits.yml +238 -0
- data/share/doc/texinfo.css +22 -0
- data/share/doc/users_guide_en.html +39975 -0
- data/share/doc/users_guide_en.texi +32640 -0
- data/share/doc/users_guide_ja.html +40505 -0
- data/share/doc/users_guide_ja.texi +33189 -0
- data/share/logo/adlint-110.png +0 -0
- data/share/logo/adlint-524.png +0 -0
- data/share/logo/adlint.svg +4637 -0
- data/share/sample/README +6 -0
- data/share/sample/bison-2.5/adlint/GNUmakefile +170 -0
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +225 -0
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +198 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +238 -0
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +166 -0
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +239 -0
- data/share/sample/ctags-5.8/adlint/GNUmakefile +169 -0
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +219 -0
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +13 -0
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +225 -0
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +140 -0
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +219 -0
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -0
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +314 -0
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +204 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +28 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +163 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +149 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +162 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +135 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +144 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +241 -0
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +162 -0
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +228 -0
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +21 -0
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +238 -0
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +185 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +25 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +250 -0
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +131 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +24 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +237 -0
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +146 -0
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +225 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +132 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +153 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +23 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +239 -0
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +147 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +144 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +239 -0
- data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
- metadata +532 -0
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
# Message detection classes for C preprocessor language.
|
|
2
|
+
#
|
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
|
+
#
|
|
7
|
+
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
8
|
+
|
|
9
|
+
#--
|
|
10
|
+
# ___ ____ __ ___ _________
|
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
|
15
|
+
#
|
|
16
|
+
# This file is part of AdLint.
|
|
17
|
+
#
|
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
21
|
+
# version.
|
|
22
|
+
#
|
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
26
|
+
#
|
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
#
|
|
30
|
+
#++
|
|
31
|
+
|
|
32
|
+
require "adlint/report"
|
|
33
|
+
require "adlint/message"
|
|
34
|
+
require "adlint/cpp/syntax"
|
|
35
|
+
|
|
36
|
+
module AdLint #:nodoc:
|
|
37
|
+
module Cpp #:nodoc:
|
|
38
|
+
|
|
39
|
+
class W0001 < PassiveMessageDetection
|
|
40
|
+
# NOTE: W0001 may be duplicative when the source file includes the same
|
|
41
|
+
# header which has the deeply grouped expression.
|
|
42
|
+
ensure_uniqueness_of :W0001
|
|
43
|
+
|
|
44
|
+
def initialize(context)
|
|
45
|
+
super
|
|
46
|
+
visitor = context[:cpp_visitor]
|
|
47
|
+
visitor.enter_grouped_expression += method(:enter_grouped_expression)
|
|
48
|
+
visitor.leave_grouped_expression += method(:leave_grouped_expression)
|
|
49
|
+
@group_depth = 0
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
def enter_grouped_expression(node)
|
|
54
|
+
@group_depth += 1
|
|
55
|
+
W(:W0001, node.location) if @group_depth == 32
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def leave_grouped_expression(node)
|
|
59
|
+
@group_depth -= 1
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class W0025 < PassiveMessageDetection
|
|
64
|
+
def initialize(context)
|
|
65
|
+
super
|
|
66
|
+
interp = context[:cpp_interpreter]
|
|
67
|
+
interp.on_user_header_included += method(:check_user_include)
|
|
68
|
+
interp.on_system_header_included += method(:check_system_include)
|
|
69
|
+
@user_header_fpaths = Set.new
|
|
70
|
+
@system_header_fpaths = Set.new
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
def check_user_include(user_include_line, user_header)
|
|
75
|
+
if @user_header_fpaths.include?(user_header.fpath)
|
|
76
|
+
W(:W0025, user_include_line.location)
|
|
77
|
+
else
|
|
78
|
+
if user_include_line.include_depth == 1
|
|
79
|
+
@user_header_fpaths.add(user_header.fpath)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def check_system_include(system_include_line, system_header)
|
|
85
|
+
if @system_header_fpaths.include?(system_header.fpath)
|
|
86
|
+
W(:W0025, system_include_line.location)
|
|
87
|
+
else
|
|
88
|
+
if system_include_line.include_depth == 1
|
|
89
|
+
@system_header_fpaths.add(system_header.fpath)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class W0026 < PassiveMessageDetection
|
|
96
|
+
def initialize(context)
|
|
97
|
+
super
|
|
98
|
+
interp = context[:cpp_interpreter]
|
|
99
|
+
interp.on_user_header_included += method(:check_user_include)
|
|
100
|
+
interp.on_system_header_included += method(:check_system_include)
|
|
101
|
+
@user_header_fpaths = Set.new
|
|
102
|
+
@system_header_fpaths = Set.new
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
private
|
|
106
|
+
def check_user_include(user_include_line, user_header)
|
|
107
|
+
if @user_header_fpaths.include?(user_header.fpath)
|
|
108
|
+
W(:W0026, user_include_line.location)
|
|
109
|
+
else
|
|
110
|
+
if user_include_line.include_depth > 1
|
|
111
|
+
@user_header_fpaths.add(user_header.fpath)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def check_system_include(system_include_line, system_header)
|
|
117
|
+
if @system_header_fpaths.include?(system_header.fpath)
|
|
118
|
+
W(:W0026, system_include_line.location)
|
|
119
|
+
else
|
|
120
|
+
if system_include_line.include_depth > 1
|
|
121
|
+
@system_header_fpaths.add(system_header.fpath)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class W0053 < PassiveMessageDetection
|
|
128
|
+
def initialize(context)
|
|
129
|
+
super
|
|
130
|
+
interp = context[:cpp_interpreter]
|
|
131
|
+
interp.on_user_header_included += method(:check_user_include)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
private
|
|
135
|
+
def check_user_include(user_include_line, user_header)
|
|
136
|
+
if user_include_line.include_depth == 7
|
|
137
|
+
W(:W0053, user_include_line.location, user_header.fpath)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
class W0054 < PassiveMessageDetection
|
|
143
|
+
def initialize(context)
|
|
144
|
+
super
|
|
145
|
+
visitor = context[:cpp_visitor]
|
|
146
|
+
visitor.enter_if_section += method(:enter_if_section)
|
|
147
|
+
visitor.leave_if_section += method(:leave_if_section)
|
|
148
|
+
@if_depth = 0
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
private
|
|
152
|
+
def enter_if_section(node)
|
|
153
|
+
@if_depth += 1
|
|
154
|
+
W(:W0054, node.location) if @if_depth == 9
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def leave_if_section(node)
|
|
158
|
+
@if_depth -= 1
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
class W0055 < PassiveMessageDetection
|
|
163
|
+
def initialize(context)
|
|
164
|
+
super
|
|
165
|
+
interp = context[:cpp_interpreter]
|
|
166
|
+
interp.on_object_like_macro_defined += method(:check)
|
|
167
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
168
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
169
|
+
@macro_num = 0
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
private
|
|
173
|
+
def check(define_line, macro)
|
|
174
|
+
unless in_initial_header?(define_line)
|
|
175
|
+
@macro_num += 1
|
|
176
|
+
W(:W0055, define_line.location) if @macro_num == 1025
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def in_initial_header?(node)
|
|
181
|
+
case
|
|
182
|
+
when pinit_fpath = Traits.instance.of_project.initial_header
|
|
183
|
+
File.identical?(node.location.fpath, pinit_fpath)
|
|
184
|
+
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
185
|
+
File.identical?(node.location.fpath, cinit_fpath)
|
|
186
|
+
else
|
|
187
|
+
false
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
class W0056 < PassiveMessageDetection
|
|
193
|
+
# NOTE: W0056 may be duplicative when the source file includes the same
|
|
194
|
+
# header which has macro definition with too many parameters.
|
|
195
|
+
ensure_uniqueness_of :W0056
|
|
196
|
+
|
|
197
|
+
def initialize(context)
|
|
198
|
+
super
|
|
199
|
+
interp = context[:cpp_interpreter]
|
|
200
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
201
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
private
|
|
205
|
+
def check(define_line, macro)
|
|
206
|
+
if macro.parameter_names.size > 31
|
|
207
|
+
W(:W0056, define_line.location)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
class W0057 < PassiveMessageDetection
|
|
213
|
+
# NOTE: W0057 may be duplicative when the source file includes the same
|
|
214
|
+
# header which has macro call with too many arguments.
|
|
215
|
+
ensure_uniqueness_of :W0057
|
|
216
|
+
|
|
217
|
+
def initialize(context)
|
|
218
|
+
super
|
|
219
|
+
macro_table = context[:cpp_macro_table]
|
|
220
|
+
macro_table.on_function_like_macro_replacement += method(:check)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
private
|
|
224
|
+
def check(macro, tokens)
|
|
225
|
+
W(:W0057, tokens.first.location) if macro.parameter_names.size > 31
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
class W0059 < PassiveMessageDetection
|
|
230
|
+
# NOTE: W0059 may be duplicative when the source file includes the same
|
|
231
|
+
# header which has carriage return at end of lines.
|
|
232
|
+
ensure_uniqueness_of :W0059
|
|
233
|
+
|
|
234
|
+
def initialize(context)
|
|
235
|
+
super
|
|
236
|
+
context[:cpp_interpreter].on_cr_at_eol_found +=
|
|
237
|
+
lambda { |location| W(:W0059, location) }
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
class W0060 < PassiveMessageDetection
|
|
242
|
+
# NOTE: W0060 may be duplicative when the source file includes the same
|
|
243
|
+
# header with the end-of-file mark.
|
|
244
|
+
ensure_uniqueness_of :W0060
|
|
245
|
+
|
|
246
|
+
def initialize(context)
|
|
247
|
+
super
|
|
248
|
+
context[:cpp_interpreter].on_eof_mark_at_eof_found +=
|
|
249
|
+
lambda { |location| W(:W0060, location) }
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
class W0061 < PassiveMessageDetection
|
|
254
|
+
# NOTE: W0061 may be duplicative when the source file includes the same
|
|
255
|
+
# header which has the token sequence of the compiler specific
|
|
256
|
+
# extension.
|
|
257
|
+
ensure_uniqueness_of :W0061
|
|
258
|
+
|
|
259
|
+
def initialize(context)
|
|
260
|
+
super
|
|
261
|
+
context[:c_source].on_language_extension +=
|
|
262
|
+
lambda { |location, matched| W(:W0061, location, matched) }
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
class W0069 < PassiveMessageDetection
|
|
267
|
+
# NOTE: W0069 may be duplicative when the source file includes the same
|
|
268
|
+
# header which has the nested block comment.
|
|
269
|
+
ensure_uniqueness_of :W0069
|
|
270
|
+
|
|
271
|
+
def initialize(context)
|
|
272
|
+
super
|
|
273
|
+
context[:cpp_interpreter].on_nested_block_comment_found +=
|
|
274
|
+
lambda { |location| W(:W0069, location) }
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
class W0072 < PassiveMessageDetection
|
|
279
|
+
# NOTE: W0072 may be duplicative when the source file includes the same
|
|
280
|
+
# header which has non basic-source-character in the #include
|
|
281
|
+
# directive.
|
|
282
|
+
ensure_uniqueness_of :W0072
|
|
283
|
+
|
|
284
|
+
def initialize(context)
|
|
285
|
+
super
|
|
286
|
+
visitor = context[:cpp_visitor]
|
|
287
|
+
visitor.enter_user_include_line += method(:check_user_include_line)
|
|
288
|
+
visitor.enter_system_include_line += method(:check_system_include_line)
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
private
|
|
292
|
+
def check_user_include_line(node)
|
|
293
|
+
unless BasicSourceCharacterSet.include?(node.header_name.value)
|
|
294
|
+
W(:W0072, node.header_name.location)
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def check_system_include_line(node)
|
|
299
|
+
unless BasicSourceCharacterSet.include?(node.header_name.value)
|
|
300
|
+
W(:W0072, node.header_name.location)
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
class W0073 < PassiveMessageDetection
|
|
306
|
+
# NOTE: W0073 may be duplicative when the source file includes the same
|
|
307
|
+
# header without the include-guard.
|
|
308
|
+
ensure_uniqueness_of :W0073
|
|
309
|
+
|
|
310
|
+
def initialize(context)
|
|
311
|
+
super
|
|
312
|
+
visitor = context[:cpp_visitor]
|
|
313
|
+
visitor.enter_user_include_line += method(:enter_include_line)
|
|
314
|
+
visitor.enter_system_include_line += method(:enter_include_line)
|
|
315
|
+
visitor.enter_text_line += method(:enter_text_line)
|
|
316
|
+
visitor.enter_if_section += method(:enter_if_section)
|
|
317
|
+
@main_fpath = context[:sources].first.fpath
|
|
318
|
+
@last_fpath = nil
|
|
319
|
+
@enclosed_by_if_section = false
|
|
320
|
+
@warned_files = Set.new
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
private
|
|
324
|
+
def enter_include_line(node)
|
|
325
|
+
unless node.location.fpath == @last_fpath
|
|
326
|
+
@enclosed_by_if_section = false
|
|
327
|
+
@last_fpath = node.location.fpath
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
return if in_initial_header?(node) || in_main_file?(node)
|
|
331
|
+
|
|
332
|
+
unless @enclosed_by_if_section || in_warned_file?(node)
|
|
333
|
+
W(:W0073, node.location)
|
|
334
|
+
@warned_files.add(node.location.fpath)
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def enter_text_line(node)
|
|
339
|
+
unless node.location.fpath == @last_fpath
|
|
340
|
+
@enclosed_by_if_section = false
|
|
341
|
+
@last_fpath = node.location.fpath
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
if empty_line?(node) || in_initial_header?(node) || in_main_file?(node)
|
|
345
|
+
return
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
unless @enclosed_by_if_section || in_warned_file?(node)
|
|
349
|
+
W(:W0073, node.location)
|
|
350
|
+
@warned_files.add(node.location.fpath)
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def enter_if_section(node)
|
|
355
|
+
@enclosed_by_if_section = true
|
|
356
|
+
@last_fpath = node.location.fpath
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
def empty_line?(node)
|
|
360
|
+
node.token.value.chomp.empty?
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def in_main_file?(node)
|
|
364
|
+
File.identical?(node.location.fpath, @main_fpath)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def in_initial_header?(node)
|
|
368
|
+
case
|
|
369
|
+
when pinit_fpath = Traits.instance.of_project.initial_header
|
|
370
|
+
File.identical?(node.location.fpath, pinit_fpath)
|
|
371
|
+
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
372
|
+
File.identical?(node.location.fpath, cinit_fpath)
|
|
373
|
+
else
|
|
374
|
+
false
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
def in_warned_file?(node)
|
|
379
|
+
@warned_files.include?(node.location.fpath)
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
class W0442 < PassiveMessageDetection
|
|
384
|
+
# NOTE: W0442 may be duplicative when the source file includes the same
|
|
385
|
+
# header which has function-like macro definitions.
|
|
386
|
+
ensure_uniqueness_of :W0442
|
|
387
|
+
|
|
388
|
+
def initialize(context)
|
|
389
|
+
super
|
|
390
|
+
interp = context[:cpp_interpreter]
|
|
391
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
392
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
private
|
|
396
|
+
def check(define_line, macro)
|
|
397
|
+
W(:W0442, define_line.location) unless in_initial_header?(define_line)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
def in_initial_header?(node)
|
|
401
|
+
case
|
|
402
|
+
when pinit_fpath = Traits.instance.of_project.initial_header
|
|
403
|
+
File.identical?(node.location.fpath, pinit_fpath)
|
|
404
|
+
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
405
|
+
File.identical?(node.location.fpath, cinit_fpath)
|
|
406
|
+
else
|
|
407
|
+
false
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
class W0443 < PassiveMessageDetection
|
|
413
|
+
# NOTE: W0443 may be duplicative when the source file includes the same
|
|
414
|
+
# header which has functionizable function-like macro definitions.
|
|
415
|
+
ensure_uniqueness_of :W0443
|
|
416
|
+
|
|
417
|
+
def initialize(context)
|
|
418
|
+
super
|
|
419
|
+
visitor = context[:cpp_visitor]
|
|
420
|
+
visitor.enter_function_like_define_line += method(:check)
|
|
421
|
+
visitor.enter_va_function_like_define_line += method(:check)
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
private
|
|
425
|
+
def check(node)
|
|
426
|
+
return if in_initial_header?(node)
|
|
427
|
+
return unless node.identifier_list
|
|
428
|
+
|
|
429
|
+
if replacement_list = node.replacement_list
|
|
430
|
+
should_be_function = replacement_list.tokens.all? { |pp_token|
|
|
431
|
+
if keyword_or_punctuator?(pp_token)
|
|
432
|
+
false
|
|
433
|
+
elsif type_specifier_or_type_qualifier?(pp_token)
|
|
434
|
+
false
|
|
435
|
+
else
|
|
436
|
+
true
|
|
437
|
+
end
|
|
438
|
+
}
|
|
439
|
+
W(:W0443, node.location) if should_be_function
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def in_initial_header?(node)
|
|
444
|
+
case
|
|
445
|
+
when pinit_fpath = Traits.instance.of_project.initial_header
|
|
446
|
+
File.identical?(node.location.fpath, pinit_fpath)
|
|
447
|
+
when cinit_fpath = Traits.instance.of_compiler.initial_header
|
|
448
|
+
File.identical?(node.location.fpath, cinit_fpath)
|
|
449
|
+
else
|
|
450
|
+
false
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
KEYWORDS = [
|
|
455
|
+
"sizeof", "typedef", "extern", "static", "auto", "register", "inline",
|
|
456
|
+
"restrict", "char", "short", "int", "long", "signed", "unsigned",
|
|
457
|
+
"float", "double", "const", "volatile", "void", "_Bool", "_Complex",
|
|
458
|
+
"_Imaginary", "struct", "union", "enum", "case", "default", "if",
|
|
459
|
+
"else", "switch", "while", "do", "for", "goto", "continue", "break",
|
|
460
|
+
"return"
|
|
461
|
+
].to_set.freeze
|
|
462
|
+
private_constant :KEYWORDS
|
|
463
|
+
|
|
464
|
+
def keyword_or_punctuator?(pp_token)
|
|
465
|
+
pp_token.value == "#" || pp_token.value == "##" ||
|
|
466
|
+
pp_token.value == "{" || pp_token.value == "}" ||
|
|
467
|
+
pp_token.value == ";" || KEYWORDS.include?(pp_token.value)
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
def type_specifier_or_type_qualifier?(pp_token)
|
|
471
|
+
pp_token.value == "const" || pp_token.value == "volatile" ||
|
|
472
|
+
pp_token.value == "restrict" ||
|
|
473
|
+
@context[:c_type_table].all_type_names.include?(pp_token.value)
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
class W0444 < PassiveMessageDetection
|
|
478
|
+
# NOTE: W0444 may be duplicative when the source file includes the same
|
|
479
|
+
# header which has the function-like macro definition with `#' and
|
|
480
|
+
# `##' operators.
|
|
481
|
+
ensure_uniqueness_of :W0444
|
|
482
|
+
|
|
483
|
+
def initialize(context)
|
|
484
|
+
super
|
|
485
|
+
interp = context[:cpp_interpreter]
|
|
486
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
487
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
private
|
|
491
|
+
def check(define_line, macro)
|
|
492
|
+
if replacement_list = macro.replacement_list
|
|
493
|
+
sharp_op_num = 0
|
|
494
|
+
sharpsharp_op_num = 0
|
|
495
|
+
|
|
496
|
+
replacement_list.tokens.each do |pp_token|
|
|
497
|
+
case pp_token.value
|
|
498
|
+
when "#"
|
|
499
|
+
sharp_op_num += 1
|
|
500
|
+
when "##"
|
|
501
|
+
sharpsharp_op_num += 1
|
|
502
|
+
end
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
if sharp_op_num > 0 && sharpsharp_op_num > 0
|
|
506
|
+
W(:W0444, define_line.location)
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
class W0445 < PassiveMessageDetection
|
|
513
|
+
# NOTE: W0445 may be duplicative when the source file includes the same
|
|
514
|
+
# header which has the function-like macro definition with two or
|
|
515
|
+
# more `##' operators.
|
|
516
|
+
ensure_uniqueness_of :W0445
|
|
517
|
+
|
|
518
|
+
def initialize(context)
|
|
519
|
+
super
|
|
520
|
+
interp = context[:cpp_interpreter]
|
|
521
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
522
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
private
|
|
526
|
+
def check(define_line, macro)
|
|
527
|
+
if replacement_list = macro.replacement_list
|
|
528
|
+
sharpsharp_op_num = 0
|
|
529
|
+
|
|
530
|
+
replacement_list.tokens.each do |pp_token|
|
|
531
|
+
if pp_token.value == "##"
|
|
532
|
+
sharpsharp_op_num += 1
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
if sharpsharp_op_num > 1
|
|
537
|
+
W(:W0445, define_line.location)
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
class W0477 < PassiveMessageDetection
|
|
544
|
+
# NOTE: W0477 may be duplicative when the source file includes the same
|
|
545
|
+
# header which has the macro definition with unbalanced grouping
|
|
546
|
+
# tokens.
|
|
547
|
+
ensure_uniqueness_of :W0477
|
|
548
|
+
|
|
549
|
+
def initialize(context)
|
|
550
|
+
super
|
|
551
|
+
interp = context[:cpp_interpreter]
|
|
552
|
+
interp.on_object_like_macro_defined += method(:check)
|
|
553
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
554
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
private
|
|
558
|
+
def check(define_line, macro)
|
|
559
|
+
if replacement_list = macro.replacement_list
|
|
560
|
+
paren_count = 0
|
|
561
|
+
brace_count = 0
|
|
562
|
+
bracket_count = 0
|
|
563
|
+
replacement_list.tokens.each do |pp_token|
|
|
564
|
+
case pp_token.value
|
|
565
|
+
when "("
|
|
566
|
+
paren_count += 1
|
|
567
|
+
when ")"
|
|
568
|
+
paren_count -= 1
|
|
569
|
+
when "{"
|
|
570
|
+
brace_count += 1
|
|
571
|
+
when "}"
|
|
572
|
+
brace_count -= 1
|
|
573
|
+
when "["
|
|
574
|
+
bracket_count += 1
|
|
575
|
+
when "]"
|
|
576
|
+
bracket_count -= 1
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
unless paren_count == 0 && brace_count == 0 && bracket_count == 0
|
|
581
|
+
W(:W0477, define_line.location)
|
|
582
|
+
end
|
|
583
|
+
end
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
class W0478 < PassiveMessageDetection
|
|
588
|
+
# NOTE: W0478 may be duplicative when the source file includes the same
|
|
589
|
+
# header which has this warning.
|
|
590
|
+
ensure_uniqueness_of :W0478
|
|
591
|
+
|
|
592
|
+
def initialize(context)
|
|
593
|
+
super
|
|
594
|
+
visitor = context[:cpp_visitor]
|
|
595
|
+
visitor.enter_object_like_define_line += method(:check)
|
|
596
|
+
visitor.enter_function_like_define_line += method(:check)
|
|
597
|
+
visitor.enter_va_function_like_define_line += method(:check)
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
private
|
|
601
|
+
def check(node)
|
|
602
|
+
replacement_list = node.replacement_list
|
|
603
|
+
if replacement_list && replacement_list.tokens.size > 1
|
|
604
|
+
unless replacement_list.may_represent_expression? ||
|
|
605
|
+
replacement_list.may_represent_initializer? ||
|
|
606
|
+
replacement_list.may_represent_block? ||
|
|
607
|
+
replacement_list.may_represent_do_while_zero_idiom? ||
|
|
608
|
+
replacement_list.may_represent_specifier_qualifier_list? ||
|
|
609
|
+
replacement_list.may_represent_declaration_specifiers_head?
|
|
610
|
+
W(:W0478, node.location)
|
|
611
|
+
end
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
class W0479 < PassiveMessageDetection
|
|
617
|
+
# NOTE: W0479 may be duplicative when the source file includes the same
|
|
618
|
+
# header which has typdef-able macro definition.
|
|
619
|
+
ensure_uniqueness_of :W0479
|
|
620
|
+
|
|
621
|
+
def initialize(context)
|
|
622
|
+
super
|
|
623
|
+
visitor = context[:cpp_visitor]
|
|
624
|
+
visitor.enter_object_like_define_line += method(:check)
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
private
|
|
628
|
+
def check(node)
|
|
629
|
+
if replacement_list = node.replacement_list
|
|
630
|
+
if replacement_list.may_represent_specifier_qualifier_list?
|
|
631
|
+
W(:W0479, node.location)
|
|
632
|
+
end
|
|
633
|
+
end
|
|
634
|
+
end
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
class W0480 < PassiveMessageDetection
|
|
638
|
+
# NOTE: W0480 may be duplicative when the source file includes the same
|
|
639
|
+
# header which has this warning.
|
|
640
|
+
ensure_uniqueness_of :W0480
|
|
641
|
+
|
|
642
|
+
def initialize(context)
|
|
643
|
+
super
|
|
644
|
+
visitor = context[:cpp_visitor]
|
|
645
|
+
visitor.enter_object_like_define_line += method(:check)
|
|
646
|
+
visitor.enter_function_like_define_line += method(:check)
|
|
647
|
+
visitor.enter_va_function_like_define_line += method(:check)
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
private
|
|
651
|
+
def check(node)
|
|
652
|
+
replacement_list = node.replacement_list
|
|
653
|
+
if replacement_list and
|
|
654
|
+
replacement_list.may_represent_punctuator? ||
|
|
655
|
+
replacement_list.may_represent_controlling_keyword?
|
|
656
|
+
W(:W0480, node.location)
|
|
657
|
+
end
|
|
658
|
+
end
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
class W0481 < PassiveMessageDetection
|
|
662
|
+
# NOTE: W0481 may be duplicative when the source file includes the same
|
|
663
|
+
# header which has this warning.
|
|
664
|
+
ensure_uniqueness_of :W0481
|
|
665
|
+
|
|
666
|
+
def initialize(context)
|
|
667
|
+
super
|
|
668
|
+
visitor = context[:cpp_visitor]
|
|
669
|
+
visitor.enter_object_like_define_line += method(:check)
|
|
670
|
+
visitor.enter_function_like_define_line += method(:check)
|
|
671
|
+
visitor.enter_va_function_like_define_line += method(:check)
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
private
|
|
675
|
+
def check(node)
|
|
676
|
+
replacement_list = node.replacement_list
|
|
677
|
+
if replacement_list && replacement_list.may_represent_block?
|
|
678
|
+
W(:W0481, node.location)
|
|
679
|
+
end
|
|
680
|
+
end
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
class W0482 < PassiveMessageDetection
|
|
684
|
+
# NOTE: W0482 may be duplicative when the source file includes the same
|
|
685
|
+
# header which has this warning.
|
|
686
|
+
ensure_uniqueness_of :W0482
|
|
687
|
+
|
|
688
|
+
def initialize(context)
|
|
689
|
+
super
|
|
690
|
+
visitor = context[:cpp_visitor]
|
|
691
|
+
visitor.enter_object_like_define_line += method(:check)
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
private
|
|
695
|
+
def check(node)
|
|
696
|
+
if replacement_list = node.replacement_list
|
|
697
|
+
return unless replacement_list.tokens.size == 1
|
|
698
|
+
if type_specifier?(replacement_list.tokens.first)
|
|
699
|
+
W(:W0482, node.location)
|
|
700
|
+
end
|
|
701
|
+
end
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
def type_specifier?(pp_token)
|
|
705
|
+
case pp_token.value
|
|
706
|
+
when "void", "char", "short", "int", "long", "float", "double"
|
|
707
|
+
true
|
|
708
|
+
when "signed", "unsigned"
|
|
709
|
+
true
|
|
710
|
+
when "struct", "union", "enum"
|
|
711
|
+
true
|
|
712
|
+
else
|
|
713
|
+
false
|
|
714
|
+
end
|
|
715
|
+
end
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
class W0483 < PassiveMessageDetection
|
|
719
|
+
# NOTE: W0483 may be duplicative when the source file includes the same
|
|
720
|
+
# header which has this warning.
|
|
721
|
+
ensure_uniqueness_of :W0483
|
|
722
|
+
|
|
723
|
+
def initialize(context)
|
|
724
|
+
super
|
|
725
|
+
visitor = context[:cpp_visitor]
|
|
726
|
+
visitor.enter_object_like_define_line += method(:check)
|
|
727
|
+
end
|
|
728
|
+
|
|
729
|
+
private
|
|
730
|
+
def check(node)
|
|
731
|
+
if replacement_list = node.replacement_list
|
|
732
|
+
if replacement_list.may_represent_declaration_specifiers_head?
|
|
733
|
+
W(:W0483, node.location)
|
|
734
|
+
end
|
|
735
|
+
end
|
|
736
|
+
end
|
|
737
|
+
end
|
|
738
|
+
|
|
739
|
+
class W0511 < PassiveMessageDetection
|
|
740
|
+
# NOTE: W0511 may be duplicative when the source file includes the same
|
|
741
|
+
# header which has line comments.
|
|
742
|
+
ensure_uniqueness_of :W0511
|
|
743
|
+
|
|
744
|
+
def initialize(context)
|
|
745
|
+
super
|
|
746
|
+
context[:cpp_interpreter].on_line_comment_found +=
|
|
747
|
+
lambda { |comment, location| W(:W0511, location) }
|
|
748
|
+
end
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
class W0528 < PassiveMessageDetection
|
|
752
|
+
# NOTE: W0528 may be duplicative when the source file includes the same
|
|
753
|
+
# header which has this warning.
|
|
754
|
+
ensure_uniqueness_of :W0528
|
|
755
|
+
|
|
756
|
+
def initialize(context)
|
|
757
|
+
super
|
|
758
|
+
interp = context[:cpp_interpreter]
|
|
759
|
+
interp.on_object_like_macro_defined += method(:check)
|
|
760
|
+
end
|
|
761
|
+
|
|
762
|
+
private
|
|
763
|
+
def check(define_line, macro)
|
|
764
|
+
if replacement_list = macro.replacement_list
|
|
765
|
+
octal_token = replacement_list.tokens.find { |pp_token|
|
|
766
|
+
pp_token.value =~ /\A0[0-9]+[UL]*\z/i
|
|
767
|
+
}
|
|
768
|
+
W(:W0528, octal_token.location) if octal_token
|
|
769
|
+
end
|
|
770
|
+
end
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
class W0549 < PassiveMessageDetection
|
|
774
|
+
# NOTE: W0549 may be duplicative when the source file includes the same
|
|
775
|
+
# header which has this warning.
|
|
776
|
+
ensure_uniqueness_of :W0549
|
|
777
|
+
|
|
778
|
+
def initialize(context)
|
|
779
|
+
super
|
|
780
|
+
interp = context[:cpp_interpreter]
|
|
781
|
+
interp.on_function_like_macro_defined += method(:check)
|
|
782
|
+
interp.on_va_function_like_macro_defined += method(:check)
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
private
|
|
786
|
+
def check(define_line, macro)
|
|
787
|
+
return unless macro.replacement_list
|
|
788
|
+
|
|
789
|
+
macro.parameter_names.each do |name|
|
|
790
|
+
macro.replacement_list.tokens.each_with_index do |pp_token, index|
|
|
791
|
+
next unless pp_token.value == name
|
|
792
|
+
|
|
793
|
+
prev_token = macro.replacement_list.tokens[[index - 1, 0].max]
|
|
794
|
+
next_token = macro.replacement_list.tokens[index + 1]
|
|
795
|
+
|
|
796
|
+
next if prev_token && prev_token.value =~ /\A##?\z/
|
|
797
|
+
next if next_token && next_token.value == "##"
|
|
798
|
+
|
|
799
|
+
unless prev_token && prev_token.value == "("
|
|
800
|
+
W(:W0549, pp_token.location)
|
|
801
|
+
next
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
unless next_token && next_token.value == ")"
|
|
805
|
+
W(:W0549, pp_token.location)
|
|
806
|
+
next
|
|
807
|
+
end
|
|
808
|
+
end
|
|
809
|
+
end
|
|
810
|
+
end
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
class W0554 < PassiveMessageDetection
|
|
814
|
+
# NOTE: W0554 may be duplicative when the source file includes the same
|
|
815
|
+
# header which has this warning.
|
|
816
|
+
ensure_uniqueness_of :W0554
|
|
817
|
+
|
|
818
|
+
def initialize(context)
|
|
819
|
+
super
|
|
820
|
+
interp = context[:cpp_interpreter]
|
|
821
|
+
interp.on_unknown_pragma_evaled += method(:check)
|
|
822
|
+
end
|
|
823
|
+
|
|
824
|
+
private
|
|
825
|
+
def check(pragma_line)
|
|
826
|
+
W(:W0554, pragma_line.location,
|
|
827
|
+
pragma_line.pp_tokens.tokens.map { |token| token.value }.join(" "))
|
|
828
|
+
end
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
class W0574 < PassiveMessageDetection
|
|
832
|
+
# NOTE: W0574 may be duplicative when the source file includes the same
|
|
833
|
+
# header which has this warning.
|
|
834
|
+
ensure_uniqueness_of :W0574
|
|
835
|
+
|
|
836
|
+
def initialize(context)
|
|
837
|
+
super
|
|
838
|
+
interp = context[:cpp_interpreter]
|
|
839
|
+
interp.on_pp_token_extracted += method(:check_pp_token)
|
|
840
|
+
interp.on_object_like_macro_defined += method(:check_macro)
|
|
841
|
+
interp.on_function_like_macro_defined += method(:check_macro)
|
|
842
|
+
interp.on_va_function_like_macro_defined += method(:check_macro)
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
private
|
|
846
|
+
def check_pp_token(pp_token)
|
|
847
|
+
if pp_token.value =~ /\AL?'(.*)'\z/
|
|
848
|
+
unless BasicSourceCharacterSet.include?($1)
|
|
849
|
+
W(:W0574, pp_token.location)
|
|
850
|
+
end
|
|
851
|
+
end
|
|
852
|
+
end
|
|
853
|
+
|
|
854
|
+
def check_macro(define_line, macro)
|
|
855
|
+
if replacement_list = macro.replacement_list
|
|
856
|
+
replacement_list.tokens.each { |pp_token| check_pp_token(pp_token) }
|
|
857
|
+
end
|
|
858
|
+
end
|
|
859
|
+
end
|
|
860
|
+
|
|
861
|
+
class W0575 < PassiveMessageDetection
|
|
862
|
+
# NOTE: W0575 may be duplicative when the source file includes the same
|
|
863
|
+
# header which has this warning.
|
|
864
|
+
ensure_uniqueness_of :W0575
|
|
865
|
+
|
|
866
|
+
def initialize(context)
|
|
867
|
+
super
|
|
868
|
+
interp = context[:cpp_interpreter]
|
|
869
|
+
interp.on_pp_token_extracted += method(:check_pp_token)
|
|
870
|
+
interp.on_object_like_macro_defined += method(:check_macro)
|
|
871
|
+
interp.on_function_like_macro_defined += method(:check_macro)
|
|
872
|
+
interp.on_va_function_like_macro_defined += method(:check_macro)
|
|
873
|
+
end
|
|
874
|
+
|
|
875
|
+
private
|
|
876
|
+
def check_pp_token(pp_token)
|
|
877
|
+
if pp_token.value =~ /\AL?"(.*)"\z/
|
|
878
|
+
unless BasicSourceCharacterSet.include?($1)
|
|
879
|
+
W(:W0575, pp_token.location)
|
|
880
|
+
end
|
|
881
|
+
end
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
def check_macro(define_line, macro)
|
|
885
|
+
if replacement_list = macro.replacement_list
|
|
886
|
+
replacement_list.tokens.each { |pp_token| check_pp_token(pp_token) }
|
|
887
|
+
end
|
|
888
|
+
end
|
|
889
|
+
end
|
|
890
|
+
|
|
891
|
+
class W0576 < PassiveMessageDetection
|
|
892
|
+
# NOTE: W0576 may be duplicative when the source file includes the same
|
|
893
|
+
# header which has this warning.
|
|
894
|
+
ensure_uniqueness_of :W0576
|
|
895
|
+
|
|
896
|
+
def initialize(context)
|
|
897
|
+
super
|
|
898
|
+
interp = context[:cpp_interpreter]
|
|
899
|
+
interp.on_block_comment_found += method(:check)
|
|
900
|
+
interp.on_line_comment_found += method(:check)
|
|
901
|
+
@warned_chars = Set.new
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
private
|
|
905
|
+
def check(comment, location)
|
|
906
|
+
not_adapted = BasicSourceCharacterSet.select_not_adapted(comment).to_set
|
|
907
|
+
new_chars = not_adapted - @warned_chars
|
|
908
|
+
|
|
909
|
+
unless new_chars.empty?
|
|
910
|
+
W(:W0576, location, location.fpath)
|
|
911
|
+
@warned_chars.merge(new_chars)
|
|
912
|
+
end
|
|
913
|
+
end
|
|
914
|
+
end
|
|
915
|
+
|
|
916
|
+
class W0577 < PassiveMessageDetection
|
|
917
|
+
# NOTE: W0577 may be duplicative when the source file includes the same
|
|
918
|
+
# header which has this warning.
|
|
919
|
+
ensure_uniqueness_of :W0577
|
|
920
|
+
|
|
921
|
+
def initialize(context)
|
|
922
|
+
super
|
|
923
|
+
interp = context[:cpp_interpreter]
|
|
924
|
+
interp.on_unlexable_char_found += method(:check)
|
|
925
|
+
@warned = false
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
private
|
|
929
|
+
def check(char, location)
|
|
930
|
+
unless @warned
|
|
931
|
+
W(:W0577, location, location.fpath)
|
|
932
|
+
@warned = true
|
|
933
|
+
end
|
|
934
|
+
end
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
class W0696 < PassiveMessageDetection
|
|
938
|
+
# NOTE: W0696 may be duplicative when the source file includes the same
|
|
939
|
+
# header which has references to the undefined macro.
|
|
940
|
+
ensure_uniqueness_of :W0696
|
|
941
|
+
|
|
942
|
+
def initialize(context)
|
|
943
|
+
super
|
|
944
|
+
interp = context[:cpp_interpreter]
|
|
945
|
+
interp.on_undefined_macro_referred +=
|
|
946
|
+
lambda { |token| W(:W0696, token.location, token.value) }
|
|
947
|
+
end
|
|
948
|
+
end
|
|
949
|
+
|
|
950
|
+
class W0804 < PassiveMessageDetection
|
|
951
|
+
# NOTE: W0804 may be duplicative when the source file includes the same
|
|
952
|
+
# header which has this warning.
|
|
953
|
+
ensure_uniqueness_of :W0804
|
|
954
|
+
|
|
955
|
+
def initialize(context)
|
|
956
|
+
super
|
|
957
|
+
context[:cpp_interpreter].on_illformed_defined_op_found +=
|
|
958
|
+
lambda { |location| W(:W0804, location) }
|
|
959
|
+
end
|
|
960
|
+
end
|
|
961
|
+
|
|
962
|
+
class W0831 < PassiveMessageDetection
|
|
963
|
+
# NOTE: W0831 may be duplicative when the source file includes the same
|
|
964
|
+
# header which has this warning.
|
|
965
|
+
ensure_uniqueness_of :W0831
|
|
966
|
+
|
|
967
|
+
def initialize(context)
|
|
968
|
+
super
|
|
969
|
+
interp = context[:cpp_interpreter]
|
|
970
|
+
interp.on_asm_section_evaled += method(:check)
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
private
|
|
974
|
+
def check(asm_section)
|
|
975
|
+
W(:W0831, asm_section.location)
|
|
976
|
+
end
|
|
977
|
+
end
|
|
978
|
+
|
|
979
|
+
class W9002 < PassiveMessageDetection
|
|
980
|
+
# NOTE: W9002 may be duplicative when the source file includes the same
|
|
981
|
+
# header which has no newline at end of the file.
|
|
982
|
+
ensure_uniqueness_of :W9002
|
|
983
|
+
|
|
984
|
+
def initialize(context)
|
|
985
|
+
super
|
|
986
|
+
context[:cpp_interpreter].on_eof_newline_not_found +=
|
|
987
|
+
lambda { |location| W(:W9002, location) }
|
|
988
|
+
end
|
|
989
|
+
end
|
|
990
|
+
|
|
991
|
+
end
|
|
992
|
+
end
|