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,542 @@
|
|
1
|
+
# C runtime object models for cross module analysis.
|
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/metric"
|
33
|
+
require "adlint/util"
|
34
|
+
|
35
|
+
module AdLint #:nodoc:
|
36
|
+
module Ld #:nodoc:
|
37
|
+
|
38
|
+
class Variable
|
39
|
+
def initialize(variable_definition_record)
|
40
|
+
@metric_record = variable_definition_record
|
41
|
+
end
|
42
|
+
|
43
|
+
def location
|
44
|
+
@metric_record.location
|
45
|
+
end
|
46
|
+
|
47
|
+
def name
|
48
|
+
@metric_record.variable_name
|
49
|
+
end
|
50
|
+
|
51
|
+
def type
|
52
|
+
@metric_record.type_rep
|
53
|
+
end
|
54
|
+
|
55
|
+
def extern?
|
56
|
+
@metric_record.var_linkage_type == "X"
|
57
|
+
end
|
58
|
+
|
59
|
+
def eql?(rhs)
|
60
|
+
name == rhs.name && location == rhs.location
|
61
|
+
end
|
62
|
+
|
63
|
+
alias :== :eql?
|
64
|
+
|
65
|
+
def hash
|
66
|
+
"#{name} #{location}".hash
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class VariableDeclaration
|
71
|
+
def initialize(global_variable_declaration_record)
|
72
|
+
@metric_record = global_variable_declaration_record
|
73
|
+
end
|
74
|
+
|
75
|
+
def location
|
76
|
+
@metric_record.location
|
77
|
+
end
|
78
|
+
|
79
|
+
def name
|
80
|
+
@metric_record.variable_name
|
81
|
+
end
|
82
|
+
|
83
|
+
def type
|
84
|
+
@metric_record.type_rep
|
85
|
+
end
|
86
|
+
|
87
|
+
def extern?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
def eql?(rhs)
|
92
|
+
name == rhs.name && location == rhs.location
|
93
|
+
end
|
94
|
+
|
95
|
+
alias :== :eql?
|
96
|
+
|
97
|
+
def hash
|
98
|
+
"#{name} #{location}".hash
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class VariableMapping
|
103
|
+
def initialize
|
104
|
+
@variable_index = Hash.new { |hash, key| hash[key] = Set.new }
|
105
|
+
@declaration_index = Hash.new { |hash, key| hash[key] = Set.new }
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_variable(variable)
|
109
|
+
@variable_index[variable.name].add(variable)
|
110
|
+
end
|
111
|
+
|
112
|
+
def add_variable_declaration(variable_declaration)
|
113
|
+
@declaration_index[variable_declaration.name].add(variable_declaration)
|
114
|
+
end
|
115
|
+
|
116
|
+
def all_variables
|
117
|
+
@variable_index.values.reduce(Set.new) { |all, variables|
|
118
|
+
all + variables
|
119
|
+
}.to_a
|
120
|
+
end
|
121
|
+
|
122
|
+
def all_variable_declarations
|
123
|
+
@declaration_index.values.reduce(Set.new) { |all, declarations|
|
124
|
+
all + declarations
|
125
|
+
}.to_a
|
126
|
+
end
|
127
|
+
|
128
|
+
def lookup_variables(variable_name)
|
129
|
+
@variable_index[variable_name].to_a
|
130
|
+
end
|
131
|
+
|
132
|
+
def lookup_variable_declarations(variable_name)
|
133
|
+
@declaration_index[variable_name].to_a
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class VariableMapper
|
138
|
+
def initialize
|
139
|
+
@result = VariableMapping.new
|
140
|
+
end
|
141
|
+
|
142
|
+
attr_reader :result
|
143
|
+
|
144
|
+
def execute(metric_fpath)
|
145
|
+
CSV.foreach(metric_fpath) do |row|
|
146
|
+
record = MetricRecord.of(row)
|
147
|
+
case
|
148
|
+
when record.variable_definition?
|
149
|
+
if record.var_linkage_type == "X"
|
150
|
+
@result.add_variable(Variable.new(record))
|
151
|
+
end
|
152
|
+
when record.global_variable_declaration?
|
153
|
+
@result.add_variable_declaration(VariableDeclaration.new(record))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
class VariableReference
|
160
|
+
def initialize(function, variable, location)
|
161
|
+
@function = function
|
162
|
+
@variable = variable
|
163
|
+
@location = location
|
164
|
+
end
|
165
|
+
|
166
|
+
attr_reader :function
|
167
|
+
attr_reader :variable
|
168
|
+
attr_reader :location
|
169
|
+
|
170
|
+
def eql?(rhs)
|
171
|
+
@function == rhs.function && @variable == rhs.variable &&
|
172
|
+
@location == rhs.location
|
173
|
+
end
|
174
|
+
|
175
|
+
alias :== :eql?
|
176
|
+
|
177
|
+
def hash
|
178
|
+
[@function, @variable, @location].hash
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class VariableReferenceGraph
|
183
|
+
extend Memoizable
|
184
|
+
|
185
|
+
def initialize(function_call_graph)
|
186
|
+
@function_call_graph = function_call_graph
|
187
|
+
@referrer_index = Hash.new { |hash, key| hash[key] = Set.new }
|
188
|
+
@variable_index = Hash.new { |hash, key| hash[key] = Set.new }
|
189
|
+
end
|
190
|
+
|
191
|
+
def add(variable_reference)
|
192
|
+
@referrer_index[variable_reference.function].add(variable_reference)
|
193
|
+
@variable_index[variable_reference.variable].add(variable_reference)
|
194
|
+
end
|
195
|
+
|
196
|
+
def all_referrers_of(variable)
|
197
|
+
direct_referrers_of(variable) + indirect_referrers_of(variable)
|
198
|
+
end
|
199
|
+
|
200
|
+
def direct_referrers_of(variable)
|
201
|
+
@variable_index[variable].map { |varref| varref.function }.to_set
|
202
|
+
end
|
203
|
+
|
204
|
+
def indirect_referrers_of(variable)
|
205
|
+
direct_referrers = direct_referrers_of(variable)
|
206
|
+
direct_referrers.reduce(Set.new) do |result, function|
|
207
|
+
result + @function_call_graph.all_callers_of(function)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
class VariableReferenceGraphBuilder
|
213
|
+
def initialize(variable_mapping, function_mapping, function_call_graph)
|
214
|
+
@variable_mapping = variable_mapping
|
215
|
+
@function_mapping = function_mapping
|
216
|
+
@result = VariableReferenceGraph.new(function_call_graph)
|
217
|
+
end
|
218
|
+
|
219
|
+
attr_reader :result
|
220
|
+
|
221
|
+
def execute(metric_fpath)
|
222
|
+
CSV.foreach(metric_fpath) do |row|
|
223
|
+
record = MetricRecord.of(row)
|
224
|
+
case
|
225
|
+
when record.variable_xref?
|
226
|
+
function = @function_mapping.lookup_functions(
|
227
|
+
record.accessor_function.name).first
|
228
|
+
|
229
|
+
variable = @variable_mapping.lookup_variables(
|
230
|
+
record.accessee_variable).first
|
231
|
+
|
232
|
+
if function && variable
|
233
|
+
@result.add(VariableReference.new(
|
234
|
+
function, variable, record.location))
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
class VariableTraversal
|
242
|
+
def initialize(variable_mapping)
|
243
|
+
@variable_mapping = variable_mapping
|
244
|
+
end
|
245
|
+
|
246
|
+
extend Pluggable
|
247
|
+
|
248
|
+
def_plugin :on_declaration
|
249
|
+
def_plugin :on_definition
|
250
|
+
|
251
|
+
def execute
|
252
|
+
@variable_mapping.all_variable_declarations.each do |declaration|
|
253
|
+
on_declaration.invoke(declaration)
|
254
|
+
end
|
255
|
+
|
256
|
+
@variable_mapping.all_variables.each do |definition|
|
257
|
+
on_definition.invoke(definition)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
class Function
|
263
|
+
def initialize(function_definition_record)
|
264
|
+
@metric_record = function_definition_record
|
265
|
+
end
|
266
|
+
|
267
|
+
def location
|
268
|
+
@metric_record.location
|
269
|
+
end
|
270
|
+
|
271
|
+
def signature
|
272
|
+
@metric_record.function_identifier.signature
|
273
|
+
end
|
274
|
+
|
275
|
+
def name
|
276
|
+
@metric_record.function_identifier.name
|
277
|
+
end
|
278
|
+
|
279
|
+
def extern?
|
280
|
+
@metric_record.function_linkage_type == "X"
|
281
|
+
end
|
282
|
+
|
283
|
+
def eql?(rhs)
|
284
|
+
signature == rhs.signature && location == rhs.location
|
285
|
+
end
|
286
|
+
|
287
|
+
alias :== :eql?
|
288
|
+
|
289
|
+
def hash
|
290
|
+
"#{signature} #{location}".hash
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
class FunctionDeclaration
|
295
|
+
def initialize(function_declaration_record)
|
296
|
+
@metric_record = function_declaration_record
|
297
|
+
end
|
298
|
+
|
299
|
+
def location
|
300
|
+
@metric_record.location
|
301
|
+
end
|
302
|
+
|
303
|
+
def signature
|
304
|
+
@metric_record.function_identifier.signature
|
305
|
+
end
|
306
|
+
|
307
|
+
def name
|
308
|
+
@metric_record.function_identifier.name
|
309
|
+
end
|
310
|
+
|
311
|
+
def extern?
|
312
|
+
@metric_record.function_linkage_type == "X"
|
313
|
+
end
|
314
|
+
|
315
|
+
def eql?(rhs)
|
316
|
+
signature == rhs.signature && location == rhs.location
|
317
|
+
end
|
318
|
+
|
319
|
+
alias :== :eql?
|
320
|
+
|
321
|
+
def hash
|
322
|
+
"#{signature} #{location}".hash
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
class FunctionMapping
|
327
|
+
def initialize
|
328
|
+
@function_index = Hash.new { |hash, key| hash[key] = Set.new }
|
329
|
+
@declaration_index = Hash.new { |hash, key| hash[key] = Set.new }
|
330
|
+
end
|
331
|
+
|
332
|
+
def add_function(function)
|
333
|
+
@function_index[function.name].add(function)
|
334
|
+
end
|
335
|
+
|
336
|
+
def add_function_declaration(function_declaration)
|
337
|
+
@declaration_index[function_declaration.name].add(function_declaration)
|
338
|
+
end
|
339
|
+
|
340
|
+
def all_functions
|
341
|
+
@function_index.values.reduce(Set.new) { |all, functions|
|
342
|
+
all + functions
|
343
|
+
}.to_a
|
344
|
+
end
|
345
|
+
|
346
|
+
def all_function_declarations
|
347
|
+
@declaration_index.values.reduce(Set.new) { |all, declarations|
|
348
|
+
all + declarations
|
349
|
+
}.to_a
|
350
|
+
end
|
351
|
+
|
352
|
+
def lookup_functions(function_name)
|
353
|
+
@function_index[function_name].to_a
|
354
|
+
end
|
355
|
+
|
356
|
+
def lookup_function_declarations(function_name)
|
357
|
+
@declaration_index[function_name].to_a
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
class FunctionMapper
|
362
|
+
def initialize
|
363
|
+
@result = FunctionMapping.new
|
364
|
+
end
|
365
|
+
|
366
|
+
attr_reader :result
|
367
|
+
|
368
|
+
def execute(metric_fpath)
|
369
|
+
CSV.foreach(metric_fpath) do |row|
|
370
|
+
record = MetricRecord.of(row)
|
371
|
+
case
|
372
|
+
when record.function_definition?
|
373
|
+
@result.add_function(Function.new(record))
|
374
|
+
when record.function_declaration?
|
375
|
+
@result.add_function_declaration(FunctionDeclaration.new(record))
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
class FunctionCall
|
382
|
+
def initialize(caller_function, callee_function)
|
383
|
+
@caller_function = caller_function
|
384
|
+
@callee_function = callee_function
|
385
|
+
end
|
386
|
+
|
387
|
+
attr_reader :caller_function
|
388
|
+
attr_reader :callee_function
|
389
|
+
|
390
|
+
def eql?(rhs)
|
391
|
+
@caller_function == rhs.caller_function &&
|
392
|
+
@callee_function == rhs.callee_function
|
393
|
+
end
|
394
|
+
|
395
|
+
alias :== :eql?
|
396
|
+
|
397
|
+
def hash
|
398
|
+
[@caller_function, @callee_function].hash
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
class FunctionCallGraph
|
403
|
+
extend Memoizable
|
404
|
+
|
405
|
+
def initialize
|
406
|
+
@caller_index = Hash.new { |hash, key| hash[key] = Set.new }
|
407
|
+
@callee_index = Hash.new { |hash, key| hash[key] = Set.new }
|
408
|
+
end
|
409
|
+
|
410
|
+
def add(function_call)
|
411
|
+
@caller_index[function_call.caller_function].add(function_call)
|
412
|
+
@callee_index[function_call.callee_function].add(function_call)
|
413
|
+
end
|
414
|
+
|
415
|
+
def all_callers_of(callee_function)
|
416
|
+
direct_callers_of(callee_function) + indirect_callers_of(callee_function)
|
417
|
+
end
|
418
|
+
memoize :all_callers_of
|
419
|
+
|
420
|
+
def direct_callers_of(callee_function)
|
421
|
+
@callee_index[callee_function].map { |funcall|
|
422
|
+
funcall.caller_function
|
423
|
+
}.to_set
|
424
|
+
end
|
425
|
+
memoize :direct_callers_of
|
426
|
+
|
427
|
+
def indirect_callers_of(callee_function)
|
428
|
+
direct_callers = direct_callers_of(callee_function)
|
429
|
+
direct_callers.reduce(Set.new) do |all_callers, function|
|
430
|
+
all_callers + collect_callers_of(function, all_callers)
|
431
|
+
end
|
432
|
+
end
|
433
|
+
memoize :indirect_callers_of
|
434
|
+
|
435
|
+
private
|
436
|
+
def collect_callers_of(callee_function, exclusion_list)
|
437
|
+
direct_callers = direct_callers_of(callee_function)
|
438
|
+
|
439
|
+
direct_callers.reduce(Set.new) do |all_callers, function|
|
440
|
+
if exclusion_list.include?(function)
|
441
|
+
all_callers.add(function)
|
442
|
+
else
|
443
|
+
all_callers.add(function) +
|
444
|
+
collect_callers_of(function, exclusion_list + all_callers)
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
memoize :collect_callers_of, 0
|
449
|
+
end
|
450
|
+
|
451
|
+
class FunctionCallGraphBuilder
|
452
|
+
def initialize(function_mapping)
|
453
|
+
@function_mapping = function_mapping
|
454
|
+
@result = FunctionCallGraph.new
|
455
|
+
end
|
456
|
+
|
457
|
+
attr_reader :result
|
458
|
+
|
459
|
+
def execute(metric_fpath)
|
460
|
+
CSV.foreach(metric_fpath) do |row|
|
461
|
+
record = MetricRecord.of(row)
|
462
|
+
case
|
463
|
+
when record.function_call?
|
464
|
+
caller_function, callee_function = lookup_functions_by_call(record)
|
465
|
+
if caller_function && callee_function
|
466
|
+
@result.add(FunctionCall.new(caller_function, callee_function))
|
467
|
+
end
|
468
|
+
when record.function_xref?
|
469
|
+
caller_function, callee_function = lookup_functions_by_xref(record)
|
470
|
+
if caller_function && callee_function
|
471
|
+
@result.add(FunctionCall.new(caller_function, callee_function))
|
472
|
+
end
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
def lookup_functions_by_call(function_call_record)
|
478
|
+
caller_function = @function_mapping.lookup_functions(
|
479
|
+
function_call_record.caller_function.name).find { |function|
|
480
|
+
function.location.fpath == function_call_record.location.fpath
|
481
|
+
}
|
482
|
+
return nil, nil unless caller_function
|
483
|
+
|
484
|
+
callee_functions = @function_mapping.lookup_functions(
|
485
|
+
function_call_record.callee_function.name)
|
486
|
+
|
487
|
+
callee_function = callee_functions.first
|
488
|
+
callee_functions.each do |function|
|
489
|
+
if function.location.fpath == caller_function.location.fpath
|
490
|
+
callee_function = function
|
491
|
+
break
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
return caller_function, callee_function
|
496
|
+
end
|
497
|
+
|
498
|
+
def lookup_functions_by_xref(function_xref_record)
|
499
|
+
caller_function = @function_mapping.lookup_functions(
|
500
|
+
function_xref_record.accessor_function.name).find { |function|
|
501
|
+
function.location.fpath == function_xref_record.location.fpath
|
502
|
+
}
|
503
|
+
return nil, nil unless caller_function
|
504
|
+
|
505
|
+
callee_functions = @function_mapping.lookup_functions(
|
506
|
+
function_xref_record.accessee_function.name)
|
507
|
+
|
508
|
+
callee_function = callee_functions.first
|
509
|
+
callee_functions.each do |function|
|
510
|
+
if function.location.fpath == caller_function.location.fpath
|
511
|
+
callee_function = function
|
512
|
+
break
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
return caller_function, callee_function
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
class FunctionTraversal
|
521
|
+
def initialize(function_mapping)
|
522
|
+
@function_mapping = function_mapping
|
523
|
+
end
|
524
|
+
|
525
|
+
extend Pluggable
|
526
|
+
|
527
|
+
def_plugin :on_declaration
|
528
|
+
def_plugin :on_definition
|
529
|
+
|
530
|
+
def execute
|
531
|
+
@function_mapping.all_function_declarations.each do |declaration|
|
532
|
+
on_declaration.invoke(declaration)
|
533
|
+
end
|
534
|
+
|
535
|
+
@function_mapping.all_functions.each do |definition|
|
536
|
+
on_definition.invoke(definition)
|
537
|
+
end
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
end
|
542
|
+
end
|