123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2019 The MOPSA Project. *)(* *)(* This program is free software: 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, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program 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. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)(* *)(****************************************************************************)(** Common constructs for points-to evaluations. *)openMopsaopenUniversal.AstopenBaseopenAlarms(* Points-to records *)(* ================= *)typepoints_to=|P_funofAst.c_fundec|P_blockofbase(** base *)*expr(** offset *)*modeoption(** strong or weak *)|P_null|P_invalid|P_topletmk_c_points_to_blocbom=P_block(b,o,m)letmk_c_points_to_null=P_nullletmk_c_points_to_invalid=P_invalidletmk_c_points_to_funf=P_funfletmk_c_points_to_top=P_topletpp_points_tofmt=function|P_funf->Format.fprintffmt"(fp %s)"f.Ast.c_func_org_name|P_block(base,offset,None)->Format.fprintffmt"(%a, %a)"pp_basebasepp_exproffset|P_block(base,offset,Somemode)->Format.fprintffmt"(%a, %a, %a)"pp_basebasepp_exproffsetpp_modemode|P_null->Format.pp_print_stringfmt"NULL"|P_invalid->Format.pp_print_stringfmt"Invalid"|P_top->Format.pp_print_stringfmt"⊤"letcompare_points_top1p2=matchp1,p2with|P_funf1,P_funf2->comparef1.Ast.c_func_unique_namef2.Ast.c_func_unique_name|P_block(b1,o1,m1),P_block(b2,o2,m2)->Compare.compose[(fun()->compare_baseb1b2);(fun()->compare_expro1o2);(fun()->Option.comparecompare_modem1m2);]|_,_->Stdlib.comparep1p2(* Points-to query *)(* =============== *)type('a,_)query+=Q_c_points_to:expr->('a,points_to)queryletresolve_pointerpmanflow=man.ask(Q_c_points_top)flow|>Cases.remove_duplicate_resultsman.lattice~equal:(funp1p2->compare_points_top1p2=0)(* Points-to containers *)(* ==================== *)modulePointsToSet=SetExt.Make(structtypet=points_toletcompare=compare_points_toend)modulePointsToMap=MapExt.Make(structtypet=points_toletcompare=compare_points_toend)