123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat a l'energie atomique et aux energies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openCil_typesmoduleWp=Wp_parametersmoduleKf=Kernel_function(* ---------------------------------------------------------------------- *)(* --- Compute Analysis --- *)(* ---------------------------------------------------------------------- *)letcomputekf=letmap=Region.create()inifKf.is_definitionkfthenbeginWp.feedback~ontty:`Transient"[region] Analyzing %a"Kf.prettykf;letdef=Kf.get_definitionkfinRegionAccess.cc_fundecmapdef;Populate_spec.populate_funspeckf[`Assigns];letspec=Annotations.funspeckfinRegionAccess.cc_specmapspec;List.iter(funbhv->letregion_specs=RegionAnnot.of_behaviorbhvinifregion_specs<>[]thenifCil.is_default_behaviorbhvthenList.iter(RegionAccess.cc_regionmap)region_specselseWp.warning~once:true"Region specifications in non-default behaviours are skipped.")spec.spec_behavior;ifWp.Region_fixpoint.get()thenRegion.fixpointmap;end;map(* ---------------------------------------------------------------------- *)(* --- Projectified Analysis Result --- *)(* ---------------------------------------------------------------------- *)moduleREGION=Datatype.Make(structtypet=Region.mapincludeDatatype.Undefinedletreprs=[Region.create()]letname="Wp.RegionAnalysis.region"letmem_project=Datatype.never_any_projectend)moduleGLOBAL=State_builder.Ref(REGION)(structletname="Wp.RegionAnalysis.ref"letdependencies=[Ast.self]letdefault=Region.createend)moduleREGISTRY=State_builder.Hashtbl(Kernel_function.Hashtbl)(REGION)(structletname="Wp.RegionAnalysis.registry"letdependencies=[Ast.self]letsize=32end)letget=function|None->GLOBAL.get()|Somekf->tryREGISTRY.findkfwithNot_found->letmap=computekfinREGISTRY.addkfmap;map(* ---------------------------------------------------------------------- *)(* --- Command Line Registry --- *)(* ---------------------------------------------------------------------- *)letmain()=ifWp.Region.get()thenbeginAst.compute();letdump=ifWp_parameters.Region_output_dot.is_set()thenRegionDump.dump_in_file~file:(Wp_parameters.Region_output_dot.get())elseRegionDump.dump_in_dir~dir:(Wp.get_output_dir"region")inWp.iter_kf(funkf->letmap=get(Somekf)inifnot(Region.is_emptymap)thendump(Kernel_function.get_namekf)map);endlet()=Db.Main.extendmain(* ---------------------------------------------------------------------- *)