123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* 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_typesopenCilopenLocationsclassvirtualdo_it_=object(self)inherit[Zone.t]Cumulative_analysis.cumulative_visitorvalmutablederefs=Zone.bottommethodbottom=Zone.bottommethodresult=derefsmethodjoinnew_=derefs<-Zone.joinnew_derefs;method!vlval(base,_aslv)=beginmatchbasewith|Var_->()|Meme->letstmt=Option.getself#current_stmtinletr=Eva.Results.(beforestmt|>eval_expe|>as_cvalue)inletloc=loc_bytes_to_loc_bitsrinletsize=Bit_utils.sizeof_lvallvinself#join(enumerate_valid_bitsRead(make_loclocsize))end;DoChildrenmethodcompute_funspec(_:kernel_function)=Zone.bottommethodclean_kf_result(_:kernel_function)(r:Locations.Zone.t)=rendmoduleAnalysis=Cumulative_analysis.Make(structletanalysis_name="derefs"typet=Locations.Zone.tmoduleT=Locations.Zoneclassvirtualdo_it=do_it_end)letget_internal=Analysis.kernel_functionletexternalize_returnfundecx=Zone.filter_base(funv->not(Base.is_formal_or_localvfundec))xmoduleExternals=Kernel_function.Make_Table(Locations.Zone)(structletname="Inout.Derefs.Externals"letdependencies=[Analysis.Memo.self]letsize=17end)letget_external=Externals.memo(funkf->Eva.Analysis.compute();ifKernel_function.is_definitionkfthentryexternalize(Kernel_function.find_returnkf)(Kernel_function.get_definitionkf)(get_internalkf)withKernel_function.No_Statement->assertfalseelse(* assume there is no deref for leaf functions *)Zone.bottom)letcompute_externalkf=ignore(get_externalkf)let_pretty_internalfmtkf=Format.fprintffmt"@[Derefs (internal) for function %a:@\n@[<hov 2> %a@]@]@\n"Kernel_function.prettykfZone.pretty(get_internalkf)letpretty_externalfmtkf=Format.fprintffmt"@[Derefs for function %a:@\n@[<hov 2> %a@]@]@\n"Kernel_function.prettykfZone.pretty(get_externalkf)let()=Db.Derefs.self_internal:=Analysis.Memo.self;Db.Derefs.self_external:=Externals.self;Db.Derefs.get_internal:=get_internal;Db.Derefs.get_external:=get_external;Db.Derefs.compute:=compute_external;Db.Derefs.display:=pretty_external;Db.Derefs.statement:=Analysis.statement