(* * Useful Info * Learning OCaml (If you so choose) * Tutorial: http://www.ocaml-tutorial.org/ * Tutorial: http://www.soton.ac.uk/~fangohr/software/ocamltutorial/ * Notes: http://www.csc.villanova.edu/~dmatusze/resources/ocaml/ocaml.html * Manual: http://caml.inria.fr/pub/docs/manual-ocaml/index.html * Chapter: http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html * Pretty Printing and General IO * http://hal.cs.berkeley.edu/cil/attributes.html#toc6 * Dataflow * http://manju.cs.berkeley.edu/cil/api/Dataflow.html * Simplifications (worth reading twice) * http://hal.cs.berkeley.edu/cil/cil004.html * Three address code: http://hal.cs.berkeley.edu/cil/ext.html#toc24 *) open Cil open Dataflow module E = Errormsg module IH = Inthash module P = Pretty (* You may begin... now *) let warnOverFunction (f:fundec) = match f.sallstmts with [] -> () | head::_ ->begin ignore(P.printf "Scanning %s for NULL info..." f.svar.vname); (* You should invoke your analysis here*) ignore(P.printf "Done\n") end let doNullWarner (f:file) = let getFuncs(fl:fundec list)(g:global) = match g with GFun(decl,_) -> decl::fl | _ -> fl in List.iter warnOverFunction (List.fold_left getFuncs [] f.globals) let feature : featureDescr = { fd_name = "nullwarner"; fd_enabled = ref false; fd_description = "warn about dereferencing (potentially) null pointers"; fd_extraopt = []; fd_doit = (fun (f:file) -> ignore(P.printf "\nProcessing: %s\n\n" f.fileName); iterGlobals f Simplify.doGlobal; Cfg.computeFileCFG f; doNullWarner(f)); fd_post_check = true; }