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,270 @@
|
|
1
|
+
# C type resolver.
|
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/monitor"
|
33
|
+
require "adlint/c/type"
|
34
|
+
require "adlint/c/syntax"
|
35
|
+
|
36
|
+
module AdLint #:nodoc:
|
37
|
+
module C #:nodoc:
|
38
|
+
|
39
|
+
class TypeResolver < SyntaxTreeVisitor
|
40
|
+
include MonitorUtil
|
41
|
+
|
42
|
+
def initialize(type_table)
|
43
|
+
@type_table = type_table
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_reader :type_table
|
47
|
+
|
48
|
+
def resolve(syntax_tree)
|
49
|
+
syntax_tree.accept(self)
|
50
|
+
@type_table
|
51
|
+
end
|
52
|
+
|
53
|
+
def visit_struct_type_declaration(node)
|
54
|
+
checkpoint(node.location)
|
55
|
+
node.struct_declarations.each { |decl| decl.accept(self) }
|
56
|
+
|
57
|
+
node.type = @type_table.install_struct_type(node)
|
58
|
+
end
|
59
|
+
|
60
|
+
def visit_union_type_declaration(node)
|
61
|
+
checkpoint(node.location)
|
62
|
+
node.struct_declarations.each { |decl| decl.accept(self) }
|
63
|
+
|
64
|
+
node.type = @type_table.install_union_type(node)
|
65
|
+
end
|
66
|
+
|
67
|
+
def visit_struct_declaration(node)
|
68
|
+
node.items.each { |item| item.accept(self) }
|
69
|
+
end
|
70
|
+
|
71
|
+
def visit_member_declaration(node)
|
72
|
+
checkpoint(node.location)
|
73
|
+
node.specifier_qualifier_list.accept(self)
|
74
|
+
node.struct_declarator.accept(self)
|
75
|
+
|
76
|
+
type_qualifiers = node.specifier_qualifier_list.type_qualifiers
|
77
|
+
type_specifiers = node.specifier_qualifier_list.type_specifiers
|
78
|
+
type = lookup_variable_type(type_qualifiers, type_specifiers,
|
79
|
+
node.struct_declarator.declarator)
|
80
|
+
type = @type_table.pointer_type(type) if type.function?
|
81
|
+
|
82
|
+
if node.struct_declarator.bitfield?
|
83
|
+
if bit_width = compute_bitfield_width(node.struct_declarator)
|
84
|
+
type = @type_table.bitfield_type(type, bit_width)
|
85
|
+
else
|
86
|
+
type = fallback_type
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
node.type = type
|
91
|
+
end
|
92
|
+
|
93
|
+
def visit_enum_type_declaration(node)
|
94
|
+
checkpoint(node.location)
|
95
|
+
type = @type_table.install_enum_type(node)
|
96
|
+
node.type = type
|
97
|
+
end
|
98
|
+
|
99
|
+
def visit_typedef_declaration(node)
|
100
|
+
checkpoint(node.location)
|
101
|
+
node.declaration_specifiers.accept(self)
|
102
|
+
node.init_declarator.accept(self)
|
103
|
+
|
104
|
+
type = @type_table.install_user_type(node)
|
105
|
+
node.type = type
|
106
|
+
end
|
107
|
+
|
108
|
+
def visit_function_declaration(node)
|
109
|
+
checkpoint(node.location)
|
110
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
111
|
+
node.init_declarator.accept(self)
|
112
|
+
|
113
|
+
if declaration_specifiers = node.declaration_specifiers
|
114
|
+
type_qualifiers = declaration_specifiers.type_qualifiers
|
115
|
+
type_specifiers = declaration_specifiers.type_specifiers
|
116
|
+
else
|
117
|
+
type_qualifiers = []
|
118
|
+
type_specifiers = []
|
119
|
+
end
|
120
|
+
|
121
|
+
node.type = lookup_variable_type(type_qualifiers, type_specifiers,
|
122
|
+
node.init_declarator.declarator)
|
123
|
+
end
|
124
|
+
|
125
|
+
def visit_variable_declaration(node)
|
126
|
+
checkpoint(node.location)
|
127
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
128
|
+
node.declarator.accept(self)
|
129
|
+
|
130
|
+
if declaration_specifiers = node.declaration_specifiers
|
131
|
+
type_qualifiers = declaration_specifiers.type_qualifiers
|
132
|
+
type_specifiers = declaration_specifiers.type_specifiers
|
133
|
+
else
|
134
|
+
type_qualifiers = []
|
135
|
+
type_specifiers = []
|
136
|
+
end
|
137
|
+
|
138
|
+
type = lookup_variable_type(type_qualifiers, type_specifiers,
|
139
|
+
node.declarator)
|
140
|
+
|
141
|
+
if type.function?
|
142
|
+
node.type = @type_table.pointer_type(type)
|
143
|
+
else
|
144
|
+
node.type = type
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def visit_variable_definition(node)
|
149
|
+
checkpoint(node.location)
|
150
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
151
|
+
node.init_declarator.accept(self)
|
152
|
+
|
153
|
+
if declaration_specifiers = node.declaration_specifiers
|
154
|
+
type_qualifiers = declaration_specifiers.type_qualifiers
|
155
|
+
type_specifiers = declaration_specifiers.type_specifiers
|
156
|
+
else
|
157
|
+
type_qualifiers = []
|
158
|
+
type_specifiers = []
|
159
|
+
end
|
160
|
+
|
161
|
+
type = lookup_variable_type(type_qualifiers, type_specifiers,
|
162
|
+
node.init_declarator.declarator)
|
163
|
+
|
164
|
+
if type.function?
|
165
|
+
node.type = @type_table.pointer_type(type)
|
166
|
+
else
|
167
|
+
node.type = type
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def visit_ansi_function_definition(node)
|
172
|
+
checkpoint(node.location)
|
173
|
+
super
|
174
|
+
node.type = lookup_function_type(node)
|
175
|
+
end
|
176
|
+
|
177
|
+
def visit_kandr_function_definition(node)
|
178
|
+
checkpoint(node.location)
|
179
|
+
super
|
180
|
+
node.type = lookup_function_type(node)
|
181
|
+
end
|
182
|
+
|
183
|
+
def visit_parameter_definition(node)
|
184
|
+
checkpoint(node.location)
|
185
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
186
|
+
node.declarator.accept(self) if node.declarator
|
187
|
+
|
188
|
+
type = @type_table.lookup_parameter_type(node, interpreter)
|
189
|
+
type = @type_table.pointer_type(type) if type.function?
|
190
|
+
node.type = type
|
191
|
+
end
|
192
|
+
|
193
|
+
def visit_type_name(node)
|
194
|
+
checkpoint(node.location)
|
195
|
+
super
|
196
|
+
type_qualifiers = node.specifier_qualifier_list.type_qualifiers
|
197
|
+
type_specifiers = node.specifier_qualifier_list.type_specifiers
|
198
|
+
node.type = lookup_variable_type(type_qualifiers, type_specifiers,
|
199
|
+
node.abstract_declarator)
|
200
|
+
end
|
201
|
+
|
202
|
+
def visit_compound_statement(node)
|
203
|
+
@type_table.enter_scope
|
204
|
+
super
|
205
|
+
@type_table.leave_scope
|
206
|
+
end
|
207
|
+
|
208
|
+
private
|
209
|
+
def lookup_variable_type(type_qualifiers, type_specifiers, declarator)
|
210
|
+
type = @type_table.lookup_or_install_type(type_qualifiers,
|
211
|
+
type_specifiers,
|
212
|
+
declarator, interpreter)
|
213
|
+
type ? type : fallback_type
|
214
|
+
end
|
215
|
+
|
216
|
+
def lookup_function_type(function_definition)
|
217
|
+
type = @type_table.lookup_function_type(function_definition)
|
218
|
+
type ? type : fallback_type
|
219
|
+
end
|
220
|
+
|
221
|
+
def compute_bitfield_width(struct_declarator)
|
222
|
+
return nil unless expression = struct_declarator.expression
|
223
|
+
|
224
|
+
if interpreter
|
225
|
+
object = interpreter.execute(expression)
|
226
|
+
if object.variable? && object.value.scalar?
|
227
|
+
return object.value.unique_sample
|
228
|
+
end
|
229
|
+
else
|
230
|
+
object = Interpreter.new(@type_table).execute(expression)
|
231
|
+
if object.variable? && object.value.scalar?
|
232
|
+
return object.value.unique_sample
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
nil
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
class StaticTypeResolver < TypeResolver
|
241
|
+
def initialize
|
242
|
+
super(TypeTable.new)
|
243
|
+
end
|
244
|
+
|
245
|
+
private
|
246
|
+
def interpreter
|
247
|
+
nil
|
248
|
+
end
|
249
|
+
|
250
|
+
def fallback_type
|
251
|
+
type_table.unresolved_type
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
class DynamicTypeResolver < TypeResolver
|
256
|
+
def initialize(type_table, interpreter)
|
257
|
+
super(type_table)
|
258
|
+
@interpreter = interpreter
|
259
|
+
end
|
260
|
+
|
261
|
+
attr_reader :interpreter
|
262
|
+
|
263
|
+
private
|
264
|
+
def fallback_type
|
265
|
+
type_table.undeclared_type
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,248 @@
|
|
1
|
+
# Scanner for C 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
|
+
module AdLint #:nodoc:
|
33
|
+
module C #:nodoc:
|
34
|
+
|
35
|
+
# == DESCRIPTION
|
36
|
+
# Constants for scanning the C source code.
|
37
|
+
module ScannerConstants
|
38
|
+
# === DESCRIPTION
|
39
|
+
# C keywords table.
|
40
|
+
KEYWORDS = {
|
41
|
+
"sizeof" => :SIZEOF,
|
42
|
+
"typedef" => :TYPEDEF,
|
43
|
+
"extern" => :EXTERN,
|
44
|
+
"static" => :STATIC,
|
45
|
+
"auto" => :AUTO,
|
46
|
+
"register" => :REGISTER,
|
47
|
+
"inline" => :INLINE,
|
48
|
+
"restrict" => :RESTRICT,
|
49
|
+
"char" => :CHAR,
|
50
|
+
"short" => :SHORT,
|
51
|
+
"int" => :INT,
|
52
|
+
"long" => :LONG,
|
53
|
+
"signed" => :SIGNED,
|
54
|
+
"unsigned" => :UNSIGNED,
|
55
|
+
"float" => :FLOAT,
|
56
|
+
"double" => :DOUBLE,
|
57
|
+
"const" => :CONST,
|
58
|
+
"volatile" => :VOLATILE,
|
59
|
+
"void" => :VOID,
|
60
|
+
"_Bool" => :BOOL,
|
61
|
+
"_Complex" => :COMPLEX,
|
62
|
+
"_Imaginary" => :IMAGINARY,
|
63
|
+
"struct" => :STRUCT,
|
64
|
+
"union" => :UNION,
|
65
|
+
"enum" => :ENUM,
|
66
|
+
"case" => :CASE,
|
67
|
+
"default" => :DEFAULT,
|
68
|
+
"if" => :IF,
|
69
|
+
"else" => :ELSE,
|
70
|
+
"switch" => :SWITCH,
|
71
|
+
"while" => :WHILE,
|
72
|
+
"do" => :DO,
|
73
|
+
"for" => :FOR,
|
74
|
+
"goto" => :GOTO,
|
75
|
+
"continue" => :CONTINUE,
|
76
|
+
"break" => :BREAK,
|
77
|
+
"return" => :RETURN,
|
78
|
+
"__typeof__" => :TYPEOF,
|
79
|
+
"__alignof__" => :ALIGNOF
|
80
|
+
}.freeze
|
81
|
+
|
82
|
+
KEYWORD_VALUES = KEYWORDS.keys.to_set.freeze
|
83
|
+
|
84
|
+
# === DESCRIPTION
|
85
|
+
# C punctuators table.
|
86
|
+
PUNCTUATORS = [
|
87
|
+
"{", "}", "(", ")", "[", "]", ";", ",", "::", ":", "?", "||",
|
88
|
+
"|=", "|", "&&", "&=", "&", "^=", "^", "==", "=", "!=", "!",
|
89
|
+
"<<=", "<=", "<<", "<", ">>=", ">=", ">>", ">", "+=", "++", "+",
|
90
|
+
"->*", "->", "-=", "--", "-", "*=", "*", "/=", "/", "%=", "%",
|
91
|
+
"...", ".*", ".", "~",
|
92
|
+
].to_set.freeze
|
93
|
+
end
|
94
|
+
|
95
|
+
# == DESCRIPTION
|
96
|
+
# Utility module for scanning the C source code.
|
97
|
+
module Scanner
|
98
|
+
include ScannerConstants
|
99
|
+
|
100
|
+
# === DESCRIPTION
|
101
|
+
# Scans C identifier.
|
102
|
+
#
|
103
|
+
# === PARAMETER
|
104
|
+
# _content_:: StringContent -- Scanning source.
|
105
|
+
#
|
106
|
+
# === RETURN VALUE
|
107
|
+
# String -- Returns C identifier string if found at head of the content.
|
108
|
+
def scan_identifier(content)
|
109
|
+
content.scan(/[a-z_][a-z_0-9]*\b/i)
|
110
|
+
end
|
111
|
+
|
112
|
+
KEYWORDS_RE = Regexp.new(KEYWORD_VALUES.map { |keyword|
|
113
|
+
"#{keyword}\\b"
|
114
|
+
}.join("|")).freeze
|
115
|
+
private_constant :KEYWORDS_RE
|
116
|
+
|
117
|
+
# === DESCRIPTION
|
118
|
+
# Scans C keyword.
|
119
|
+
#
|
120
|
+
# === PARAMETER
|
121
|
+
# _content_:: StringContent -- Scanning source.
|
122
|
+
#
|
123
|
+
# === RETURN VALUE
|
124
|
+
# String -- Returns C keyword string if found at head of the content.
|
125
|
+
def scan_keyword(content)
|
126
|
+
content.scan(KEYWORDS_RE)
|
127
|
+
end
|
128
|
+
|
129
|
+
PUNCTUATORS_RE = Regexp.new(PUNCTUATORS.sort { |l, r|
|
130
|
+
r.length <=> l.length
|
131
|
+
}.map { |punct|
|
132
|
+
punct.each_char.map { |ch| '\\' + ch }.join
|
133
|
+
}.join("|")).freeze
|
134
|
+
private_constant :PUNCTUATORS_RE
|
135
|
+
|
136
|
+
# === DESCRIPTION
|
137
|
+
# Scans C punctuator.
|
138
|
+
#
|
139
|
+
# === PARAMETER
|
140
|
+
# _content_:: StringContent -- Scanning source.
|
141
|
+
#
|
142
|
+
# === RETURN VALUE
|
143
|
+
# String -- Returns C punctuator string if found at head of the content.
|
144
|
+
def scan_punctuator(content)
|
145
|
+
content.scan(PUNCTUATORS_RE)
|
146
|
+
end
|
147
|
+
|
148
|
+
# === DESCRIPTION
|
149
|
+
# Scans C integer constant.
|
150
|
+
#
|
151
|
+
# === PARAMETER
|
152
|
+
# _content_:: StringContent -- Scanning source.
|
153
|
+
#
|
154
|
+
# === RETURN VALUE
|
155
|
+
# String -- Returns C integer constant string if found at head of the
|
156
|
+
# content.
|
157
|
+
def scan_integer_constant(content)
|
158
|
+
content.scan(/(?:0x[0-9a-f]+|0b[01]+|[0-9]+)[UL]*/i)
|
159
|
+
end
|
160
|
+
|
161
|
+
# === DESCRIPTION
|
162
|
+
# Scans C floating constant.
|
163
|
+
#
|
164
|
+
# === PARAMETER
|
165
|
+
# _content_:: StringContent -- Scanning source.
|
166
|
+
#
|
167
|
+
# === RETURN VALUE
|
168
|
+
# String -- Returns C floating constant string if found at head of the
|
169
|
+
# content.
|
170
|
+
def scan_floating_constant(content)
|
171
|
+
content.scan(
|
172
|
+
/(?:[0-9]*\.[0-9]*E[+-]?[0-9]+|[0-9]+\.?E[+-]?[0-9]+)[FL]*/i) ||
|
173
|
+
content.scan(/(?:[0-9]*\.[0-9]+|[0-9]+\.)[FL]*/i)
|
174
|
+
end
|
175
|
+
|
176
|
+
# === DESCRIPTION
|
177
|
+
# Scans C character constant.
|
178
|
+
#
|
179
|
+
# === PARAMETER
|
180
|
+
# _content_:: StringContent -- Scanning source.
|
181
|
+
#
|
182
|
+
# === RETURN VALUE
|
183
|
+
# String -- Returns C character constant string if found at head of the
|
184
|
+
# content.
|
185
|
+
def scan_char_constant(content)
|
186
|
+
scanned = content.scan(/L?'/i)
|
187
|
+
return nil unless scanned
|
188
|
+
|
189
|
+
until content.empty?
|
190
|
+
str = content.scan(/.*?(?=\\|')/m)
|
191
|
+
scanned << str if str
|
192
|
+
next if content.scan(/\\[ \t]*\n/)
|
193
|
+
case
|
194
|
+
when content.check(/\\/)
|
195
|
+
scanned << content.eat!(2)
|
196
|
+
when quote = content.scan(/'/)
|
197
|
+
scanned << quote
|
198
|
+
break
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
scanned
|
203
|
+
end
|
204
|
+
|
205
|
+
# === DESCRIPTION
|
206
|
+
# Scans C string literal.
|
207
|
+
#
|
208
|
+
# === PARAMETER
|
209
|
+
# _content_:: StringContent -- Scanning source.
|
210
|
+
#
|
211
|
+
# === RETURN VALUE
|
212
|
+
# String -- Returns C string literal string if found at head of the
|
213
|
+
# content.
|
214
|
+
def scan_string_literal(content)
|
215
|
+
scanned = content.scan(/L?"/i)
|
216
|
+
return nil unless scanned
|
217
|
+
|
218
|
+
until content.empty?
|
219
|
+
str = content.scan(/.*?(?=\\|")/m)
|
220
|
+
scanned << str if str
|
221
|
+
next if content.scan(/\\[ \t]*\n/)
|
222
|
+
case
|
223
|
+
when content.check(/\\/)
|
224
|
+
scanned << content.eat!(2)
|
225
|
+
when quote = content.scan(/"/)
|
226
|
+
scanned << quote
|
227
|
+
break
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
scanned
|
232
|
+
end
|
233
|
+
|
234
|
+
# === DESCRIPTION
|
235
|
+
# Scans C NULL constant.
|
236
|
+
#
|
237
|
+
# === PARAMETER
|
238
|
+
# _content_:: StringContent -- Scanning source.
|
239
|
+
#
|
240
|
+
# === RETURN VALUE
|
241
|
+
# String -- Returns C NULL constant string if found at head of the content.
|
242
|
+
def scan_null_constant(content)
|
243
|
+
content.scan(/NULL\b/)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# C runtime scope.
|
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
|
+
module AdLint #:nodoc:
|
33
|
+
module C #:nodoc:
|
34
|
+
|
35
|
+
class Scope
|
36
|
+
def initialize(depth)
|
37
|
+
@depth = depth
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_reader :depth
|
41
|
+
|
42
|
+
def global?
|
43
|
+
@depth == 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def local?
|
47
|
+
@depth > 0
|
48
|
+
end
|
49
|
+
|
50
|
+
def inner_scope
|
51
|
+
Scope.new(@depth + 1)
|
52
|
+
end
|
53
|
+
|
54
|
+
def outer_scope
|
55
|
+
Scope.new(@depth - 1)
|
56
|
+
end
|
57
|
+
|
58
|
+
def eql?(rhs)
|
59
|
+
@depth == rhs.depth
|
60
|
+
end
|
61
|
+
|
62
|
+
def hash
|
63
|
+
@depth.hash
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class GlobalScope < Scope
|
68
|
+
def initialize
|
69
|
+
super(0)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|