adlint 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,241 @@
|
|
1
|
+
# Lexical analyzer which retokenizes pp-tokens into c-tokens.
|
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/lexer"
|
33
|
+
require "adlint/c/scanner"
|
34
|
+
require "adlint/c/scope"
|
35
|
+
|
36
|
+
module AdLint #:nodoc:
|
37
|
+
module C #:nodoc:
|
38
|
+
|
39
|
+
class Lexer < TokensRelexer
|
40
|
+
def initialize(c_source)
|
41
|
+
super(c_source.pp_tokens)
|
42
|
+
@translation_unit_fpath = c_source.root_fpath
|
43
|
+
|
44
|
+
@last_token = nil
|
45
|
+
@next_token = nil
|
46
|
+
@typedef_names = ScopedNameSet.new
|
47
|
+
@object_names = ScopedNameSet.new
|
48
|
+
@identifier_translation = true
|
49
|
+
end
|
50
|
+
|
51
|
+
attr_reader :translation_unit_fpath
|
52
|
+
|
53
|
+
def add_typedef_name(token)
|
54
|
+
@typedef_names.add(token.value)
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_object_name(token)
|
58
|
+
@object_names.add(token.value)
|
59
|
+
end
|
60
|
+
|
61
|
+
def enter_scope
|
62
|
+
@typedef_names.enter_scope
|
63
|
+
@object_names.enter_scope
|
64
|
+
end
|
65
|
+
|
66
|
+
def leave_scope
|
67
|
+
@typedef_names.leave_scope
|
68
|
+
@object_names.leave_scope
|
69
|
+
end
|
70
|
+
|
71
|
+
def start_identifier_translation
|
72
|
+
@identifier_translation = true
|
73
|
+
end
|
74
|
+
|
75
|
+
def stop_identifier_translation
|
76
|
+
@identifier_translation = false
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def create_context(token_array)
|
81
|
+
LexerContext.new(TokensContent.new(token_array))
|
82
|
+
end
|
83
|
+
|
84
|
+
def tokenize(context)
|
85
|
+
if @next_token
|
86
|
+
token = @next_token
|
87
|
+
@next_token = nil
|
88
|
+
else
|
89
|
+
until context.content.empty?
|
90
|
+
pp_token = context.content.next_token
|
91
|
+
|
92
|
+
if type_hint = pp_token.type_hint
|
93
|
+
token = pp_token.class.new(type_hint, pp_token.value,
|
94
|
+
pp_token.location)
|
95
|
+
else
|
96
|
+
token = retokenize_keyword(pp_token, context) ||
|
97
|
+
retokenize_constant(pp_token, context) ||
|
98
|
+
retokenize_string_literal(pp_token, context) ||
|
99
|
+
retokenize_null_constant(pp_token, context) ||
|
100
|
+
retokenize_identifier(pp_token, context) ||
|
101
|
+
retokenize_punctuator(pp_token, context)
|
102
|
+
end
|
103
|
+
|
104
|
+
break if token
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
if token
|
109
|
+
case token.type
|
110
|
+
when :IDENTIFIER
|
111
|
+
token = translate_identifier(token, context)
|
112
|
+
when :STRING_LITERAL
|
113
|
+
token = concat_contiguous_string_literals(token, context)
|
114
|
+
end
|
115
|
+
@last_token = token
|
116
|
+
else
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def translate_identifier(token, context)
|
122
|
+
if @identifier_translation
|
123
|
+
if token.type == :IDENTIFIER
|
124
|
+
return token if @object_names.include?(token.value)
|
125
|
+
if @typedef_names.include?(token.value)
|
126
|
+
unless @last_token and
|
127
|
+
@last_token.type == :STRUCT || @last_token.type == :UNION ||
|
128
|
+
@last_token.type == :ENUM ||
|
129
|
+
@last_token.type == "->" || @last_token.type == "."
|
130
|
+
token =
|
131
|
+
token.class.new(:TYPEDEF_NAME, token.value, token.location)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
token
|
137
|
+
end
|
138
|
+
|
139
|
+
def concat_contiguous_string_literals(token, context)
|
140
|
+
until context.content.empty?
|
141
|
+
next_token = tokenize(context)
|
142
|
+
if next_token.type == :STRING_LITERAL
|
143
|
+
return token.class.new(token.type, token.value.sub(/"\z/, "") +
|
144
|
+
next_token.value.sub(/\AL?"/, ""),
|
145
|
+
token.location)
|
146
|
+
else
|
147
|
+
@next_token = next_token
|
148
|
+
break
|
149
|
+
end
|
150
|
+
end
|
151
|
+
token
|
152
|
+
end
|
153
|
+
|
154
|
+
def retokenize_keyword(pp_token, context)
|
155
|
+
if keyword = Scanner::KEYWORDS[pp_token.value]
|
156
|
+
pp_token.class.new(keyword, pp_token.value, pp_token.location)
|
157
|
+
else
|
158
|
+
nil
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def retokenize_constant(pp_token, context)
|
163
|
+
# NOTE: For extended bit-access operators.
|
164
|
+
return nil if @last_token && @last_token.type == :IDENTIFIER
|
165
|
+
|
166
|
+
case pp_token.value
|
167
|
+
when /\AL?'.*'\z/,
|
168
|
+
/\A(?:[0-9]*\.[0-9]+|[0-9]+\.)[FL]*\z/i,
|
169
|
+
/\A(?:[0-9]*\.[0-9]*E[+-]?[0-9]+|[0-9]+\.?E[+-]?[0-9]+)[FL]*\z/i,
|
170
|
+
/\A(?:0x[0-9a-f]+|0b[01]+|[0-9]+)[UL]*\z/i
|
171
|
+
pp_token.class.new(:CONSTANT, pp_token.value, pp_token.location)
|
172
|
+
else
|
173
|
+
nil
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def retokenize_string_literal(pp_token, context)
|
178
|
+
if pp_token.value =~ /\AL?".*"\z/
|
179
|
+
pp_token.class.new(:STRING_LITERAL, pp_token.value, pp_token.location)
|
180
|
+
else
|
181
|
+
nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def retokenize_null_constant(pp_token, context)
|
186
|
+
if pp_token.value == "NULL"
|
187
|
+
pp_token.class.new(:NULL, pp_token.value, pp_token.location)
|
188
|
+
else
|
189
|
+
nil
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def retokenize_identifier(pp_token, context)
|
194
|
+
if pp_token.value =~ /\A[a-z_][a-z_0-9]*\z/i
|
195
|
+
pp_token.class.new(:IDENTIFIER, pp_token.value, pp_token.location)
|
196
|
+
else
|
197
|
+
nil
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def retokenize_punctuator(pp_token, context)
|
202
|
+
case pp_token.value
|
203
|
+
when "{", "}", "(", ")", "[", "]", ";", ",", "::", ":", "?", "||",
|
204
|
+
"|=", "|", "&&", "&=", "&", "^=", "^", "==", "=", "!=", "!",
|
205
|
+
"<<=", "<=", "<<", "<", ">>=", ">=", ">>", ">", "+=", "++", "+",
|
206
|
+
"->*", "->", "-=", "--", "-", "*=", "*", "/=", "/", "%=", "%",
|
207
|
+
"...", ".*", ".", "~"
|
208
|
+
pp_token.class.new(pp_token.value, pp_token.value, pp_token.location)
|
209
|
+
else
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
class ScopedNameSet
|
216
|
+
def initialize
|
217
|
+
@name_stack = [Set.new]
|
218
|
+
@scope_stack = [GlobalScope.new]
|
219
|
+
end
|
220
|
+
|
221
|
+
def enter_scope
|
222
|
+
@name_stack.push(Set.new)
|
223
|
+
@scope_stack.push(Scope.new(@scope_stack.size))
|
224
|
+
end
|
225
|
+
|
226
|
+
def leave_scope
|
227
|
+
@name_stack.pop
|
228
|
+
@scope_stack.pop
|
229
|
+
end
|
230
|
+
|
231
|
+
def add(name)
|
232
|
+
@name_stack.last.add(name)
|
233
|
+
end
|
234
|
+
|
235
|
+
def include?(name)
|
236
|
+
@name_stack.any? { |set| set.include?(name) }
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
end
|
@@ -0,0 +1,313 @@
|
|
1
|
+
# C interpreter mediator.
|
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/c/type"
|
33
|
+
require "adlint/c/object"
|
34
|
+
require "adlint/c/syntax"
|
35
|
+
|
36
|
+
module AdLint #:nodoc:
|
37
|
+
module C #:nodoc:
|
38
|
+
|
39
|
+
module TypeTableMediator
|
40
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
41
|
+
|
42
|
+
include StandardTypeCatalogAccessor
|
43
|
+
|
44
|
+
extend Forwardable
|
45
|
+
|
46
|
+
def_delegator :type_table, :lookup, :type_of
|
47
|
+
def_delegator :type_table, :undeclared_type
|
48
|
+
def_delegator :type_table, :wchar_type
|
49
|
+
def_delegator :type_table, :array_type
|
50
|
+
def_delegator :type_table, :function_type
|
51
|
+
def_delegator :type_table, :bitfield_type
|
52
|
+
def_delegator :type_table, :pointer_type
|
53
|
+
def_delegator :type_table, :qualified_type
|
54
|
+
|
55
|
+
private
|
56
|
+
def standard_type_catalog
|
57
|
+
type_table.standard_type_catalog
|
58
|
+
end
|
59
|
+
|
60
|
+
def type_table
|
61
|
+
# NOTE: Host class must respond to #type_table.
|
62
|
+
subclass_responsibility
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
module MemoryPoolMediator
|
67
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
68
|
+
|
69
|
+
extend Forwardable
|
70
|
+
|
71
|
+
def_delegator :memory_pool, :lookup, :memory_at
|
72
|
+
|
73
|
+
def pointee_of(pointer)
|
74
|
+
# FIXME: This method should return multiple objects, because domain of
|
75
|
+
# the pointer_value may have multiple address values.
|
76
|
+
#
|
77
|
+
# pointer.value.to_enum.map { |address|
|
78
|
+
# memory = memory_at(address) ? memory.binding.object : nil
|
79
|
+
# }.compact
|
80
|
+
|
81
|
+
pointer.value.to_enum.each do |address|
|
82
|
+
if memory = memory_at(address)
|
83
|
+
object = memory.binding.object
|
84
|
+
if object.variable? or
|
85
|
+
object.function? && pointer.type.unqualify.base_type.function?
|
86
|
+
return object
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
def memory_pool
|
95
|
+
# NOTE: Host class must respond to #memory_pool.
|
96
|
+
subclass_responsibility
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
module VariableTableMediator
|
101
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
102
|
+
|
103
|
+
extend Forwardable
|
104
|
+
|
105
|
+
def_delegator :variable_table, :lookup, :variable_named
|
106
|
+
def_delegator :variable_table, :declare, :declare_variable
|
107
|
+
def_delegator :variable_table, :define, :define_variable
|
108
|
+
|
109
|
+
def local_variables
|
110
|
+
variable_table.all_named_variables.select { |variable|
|
111
|
+
variable.scope.local?
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
def temporary_variable(type = undeclared_type,
|
116
|
+
value = type.undefined_value)
|
117
|
+
variable_table.define_temporary(type, value)
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
def variable_table
|
122
|
+
# NOTE: Host class must respond to #variable_table.
|
123
|
+
subclass_responsibility
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
module FunctionTableMediator
|
128
|
+
# NOTE: The host class of this module must include TypeTableMediator.
|
129
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
130
|
+
|
131
|
+
extend Forwardable
|
132
|
+
|
133
|
+
def_delegator :function_table, :lookup, :function_named
|
134
|
+
def_delegator :function_table, :define, :define_function
|
135
|
+
|
136
|
+
def define_explicit_function(function_declaration_or_definition)
|
137
|
+
define_function(ExplicitFunction.new(function_declaration_or_definition))
|
138
|
+
end
|
139
|
+
|
140
|
+
def define_implicit_function(name)
|
141
|
+
define_function(ImplicitFunction.new(default_function_type, name))
|
142
|
+
end
|
143
|
+
|
144
|
+
def define_anonymous_function(type)
|
145
|
+
define_function(AnonymousFunction.new(type))
|
146
|
+
end
|
147
|
+
|
148
|
+
private
|
149
|
+
def default_function_type
|
150
|
+
function_type(int_type, [])
|
151
|
+
end
|
152
|
+
|
153
|
+
def function_table
|
154
|
+
# NOTE: Host class must respond to #function_table.
|
155
|
+
subclass_responsibility
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
module EnumeratorTableMediator
|
160
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
161
|
+
|
162
|
+
extend Forwardable
|
163
|
+
|
164
|
+
def_delegator :enumerator_table, :lookup, :enumerator_named
|
165
|
+
def_delegator :enumerator_table, :define, :define_enumerator
|
166
|
+
|
167
|
+
private
|
168
|
+
def enumerator_table
|
169
|
+
# NOTE: Host class must respond to #enumerator_table.
|
170
|
+
subclass_responsibility
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
module NotifierMediator
|
175
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
176
|
+
|
177
|
+
extend Forwardable
|
178
|
+
|
179
|
+
def_delegator :interpreter, :notify_variable_initialized
|
180
|
+
def_delegator :interpreter, :notify_variable_defined
|
181
|
+
def_delegator :interpreter, :notify_function_declared
|
182
|
+
def_delegator :interpreter, :notify_variable_declared
|
183
|
+
def_delegator :interpreter, :notify_struct_declared
|
184
|
+
def_delegator :interpreter, :notify_union_declared
|
185
|
+
def_delegator :interpreter, :notify_enum_declared
|
186
|
+
def_delegator :interpreter, :notify_typedef_declared
|
187
|
+
def_delegator :interpreter, :notify_function_started
|
188
|
+
def_delegator :interpreter, :notify_function_ended
|
189
|
+
def_delegator :interpreter, :notify_parameter_defined
|
190
|
+
def_delegator :interpreter, :notify_variable_referred
|
191
|
+
def_delegator :interpreter, :notify_constant_referred
|
192
|
+
def_delegator :interpreter, :notify_variable_value_referred
|
193
|
+
def_delegator :interpreter, :notify_variable_value_updated
|
194
|
+
def_delegator :interpreter, :notify_function_referred
|
195
|
+
def_delegator :interpreter, :notify_sizeof_expr_evaled
|
196
|
+
def_delegator :interpreter, :notify_sizeof_type_expr_evaled
|
197
|
+
def_delegator :interpreter, :notify_explicit_conv_performed
|
198
|
+
def_delegator :interpreter, :notify_implicit_conv_performed
|
199
|
+
def_delegator :interpreter, :notify_array_subscript_expr_evaled
|
200
|
+
def_delegator :interpreter, :notify_function_call_expr_evaled
|
201
|
+
def_delegator :interpreter, :notify_unary_arithmetic_expr_evaled
|
202
|
+
def_delegator :interpreter, :notify_multiplicative_expr_evaled
|
203
|
+
def_delegator :interpreter, :notify_additive_expr_evaled
|
204
|
+
def_delegator :interpreter, :notify_shift_expr_evaled
|
205
|
+
def_delegator :interpreter, :notify_relational_expr_evaled
|
206
|
+
def_delegator :interpreter, :notify_equality_expr_evaled
|
207
|
+
def_delegator :interpreter, :notify_and_expr_evaled
|
208
|
+
def_delegator :interpreter, :notify_exclusive_or_expr_evaled
|
209
|
+
def_delegator :interpreter, :notify_inclusive_or_expr_evaled
|
210
|
+
def_delegator :interpreter, :notify_logical_and_expr_evaled
|
211
|
+
def_delegator :interpreter, :notify_logical_or_expr_evaled
|
212
|
+
def_delegator :interpreter, :notify_conditional_expr_evaled
|
213
|
+
def_delegator :interpreter, :notify_indirection_expr_evaled
|
214
|
+
def_delegator :interpreter, :notify_member_access_expr_evaled
|
215
|
+
def_delegator :interpreter, :notify_prefix_increment_expr_evaled
|
216
|
+
def_delegator :interpreter, :notify_postfix_increment_expr_evaled
|
217
|
+
def_delegator :interpreter, :notify_prefix_decrement_expr_evaled
|
218
|
+
def_delegator :interpreter, :notify_postfix_decrement_expr_evaled
|
219
|
+
def_delegator :interpreter, :notify_assignment_expr_evaled
|
220
|
+
def_delegator :interpreter, :notify_while_stmt_started
|
221
|
+
def_delegator :interpreter, :notify_while_stmt_ended
|
222
|
+
def_delegator :interpreter, :notify_do_stmt_started
|
223
|
+
def_delegator :interpreter, :notify_do_stmt_ended
|
224
|
+
def_delegator :interpreter, :notify_for_stmt_started
|
225
|
+
def_delegator :interpreter, :notify_for_stmt_ended
|
226
|
+
def_delegator :interpreter, :notify_c99_for_stmt_started
|
227
|
+
def_delegator :interpreter, :notify_c99_for_stmt_ended
|
228
|
+
def_delegator :interpreter, :notify_goto_stmt_evaled
|
229
|
+
def_delegator :interpreter, :notify_return_stmt_evaled
|
230
|
+
def_delegator :interpreter, :notify_if_ctrlexpr_evaled
|
231
|
+
def_delegator :interpreter, :notify_if_else_ctrlexpr_evaled
|
232
|
+
def_delegator :interpreter, :notify_while_ctrlexpr_evaled
|
233
|
+
def_delegator :interpreter, :notify_do_ctrlexpr_evaled
|
234
|
+
def_delegator :interpreter, :notify_for_ctrlexpr_evaled
|
235
|
+
def_delegator :interpreter, :notify_c99_for_ctrlexpr_evaled
|
236
|
+
def_delegator :interpreter, :notify_label_defined
|
237
|
+
def_delegator :interpreter, :notify_block_started
|
238
|
+
def_delegator :interpreter, :notify_block_ended
|
239
|
+
def_delegator :interpreter, :notify_branch_started
|
240
|
+
def_delegator :interpreter, :notify_branch_ended
|
241
|
+
def_delegator :interpreter, :notify_translation_unit_started
|
242
|
+
def_delegator :interpreter, :notify_translation_unit_ended
|
243
|
+
|
244
|
+
private
|
245
|
+
def interpreter
|
246
|
+
# NOTE: Host class must respond to #interpreter.
|
247
|
+
subclass_responsibility
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
module InterpreterMediator
|
252
|
+
# NOTE: This module works like a CRTP base entity in C++.
|
253
|
+
|
254
|
+
include TypeTableMediator
|
255
|
+
include MemoryPoolMediator
|
256
|
+
include VariableTableMediator
|
257
|
+
include FunctionTableMediator
|
258
|
+
include EnumeratorTableMediator
|
259
|
+
|
260
|
+
def interpret(node, *options)
|
261
|
+
interpreter.execute(node, *options)
|
262
|
+
end
|
263
|
+
|
264
|
+
def reset_environment
|
265
|
+
environment.reset
|
266
|
+
end
|
267
|
+
|
268
|
+
extend Forwardable
|
269
|
+
|
270
|
+
def_delegator :interpreter, :object_to_variable
|
271
|
+
def_delegator :interpreter, :value_of
|
272
|
+
def_delegator :interpreter, :pointer_value_of
|
273
|
+
|
274
|
+
private
|
275
|
+
def scoped_eval(&block)
|
276
|
+
environment.enter_scope
|
277
|
+
yield
|
278
|
+
ensure
|
279
|
+
environment.leave_scope
|
280
|
+
end
|
281
|
+
|
282
|
+
def branched_eval(expression = nil, *options, &block)
|
283
|
+
current_branch = environment.enter_branch(*options)
|
284
|
+
interpreter.notify_branch_started(current_branch)
|
285
|
+
current_branch.execute(interpreter, expression, &block)
|
286
|
+
ensure
|
287
|
+
interpreter.notify_branch_ended(current_branch)
|
288
|
+
environment.leave_branch_group if current_branch.final?
|
289
|
+
environment.leave_branch
|
290
|
+
end
|
291
|
+
|
292
|
+
def resolve_unresolved_type(node)
|
293
|
+
interpreter.type_resolver.resolve(node) if node.type.unresolved?
|
294
|
+
end
|
295
|
+
|
296
|
+
extend Forwardable
|
297
|
+
|
298
|
+
def_delegator :interpreter, :environment
|
299
|
+
|
300
|
+
def_delegator :environment, :type_table
|
301
|
+
def_delegator :environment, :memory_pool
|
302
|
+
def_delegator :environment, :variable_table
|
303
|
+
def_delegator :environment, :function_table
|
304
|
+
def_delegator :environment, :enumerator_table
|
305
|
+
|
306
|
+
def interpreter
|
307
|
+
# NOTE: Host class must respond to #interpreter.
|
308
|
+
subclass_responsibility
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
end
|