Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file instrument_label.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135(**************************************************************************)(* *)(* This file is part of the Frama-C's Luncov plug-in. *)(* *)(* Copyright (C) 2012-2025 *)(* 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 LICENSE) *)(* *)(**************************************************************************)openCil_typesopenInstrumentletget_labelid=letvalue=getidinmatchvaluewith|Labellinfo->linfo|_->assertfalseletget_locid=(get_labelid).li_locletget_tagid=(get_labelid).li_tagletget_annotable_stmtid=(get_labelid).li_annotableletget_predicateid=(get_labelid).li_predicateletget_kf_idid=(get_labelid).li_kf_idletat=refReq(** Visitor that removes all but a single label (given its id),
add a single assertion whose validity implies the uncoverability of a label,
and provides information to get a Property.t
*)classlabel_selectorlblidinfoprj=object(self)inheritVisitor.frama_c_copyprjvalmutableremove_locals=[]methodprivateclean_localslocals=List.filter(funvi->not(List.exists(funvi'->Cil_datatype.Varinfo.equalvivi')remove_locals))localsmethodprivateclean_skipsstmtl=List.filter(funs->s.labels<>[]||not@@Cil.is_skips.skind)stmtlmethod!vfunc_=Cil.DoChildrenPost(funf->f.slocals<-self#clean_localsf.slocals;File.must_recompute_cfgf;remove_locals<-[];f)method!vblock_=Cil.DoChildrenPost(funb->b.bstmts<-self#clean_skipsb.bstmts;b.blocals<-self#clean_localsb.blocals;b)method!vstmt_auxstmt=matchstmt.skind,is_stmt_by_sidstmt.sidwith|_,[lblid']whenlblid'=lblid->self#add_label_annot();Cil.JustCopy|Blockb,[_]->remove_locals<-b.blocals@remove_locals;stmt.skind<-Instr(SkipCil_datatype.Location.unknown);Cil.JustCopy|Instri,_->beginmatchiwith|Set((Varv,_),_,_)|Local_init(v,_,_)|Call(Some(Varv,_),_,_,_)->letvn="__SEQ_STATUS_"inifString.lengthv.vname>String.lengthvn&&String.subv.vname0(String.lengthvn)=vnthenbeginifString.split_on_char'_'v.vname|>List.rev|>List.hd|>int_of_string<>lblidthenbeginstmt.skind<-Instr(SkipCil_datatype.Location.unknown);remove_locals<-[v]@remove_locals;endend;Cil.JustCopy|_->Cil.JustCopyend|_,_->Cil.DoChildrenmethodprivateadd_label_annot()=letlblinfo=get_labellblidinletold_kf=Option.getself#current_kfinletnew_kf=Visitor_behavior.Get.kernel_functionself#behaviorold_kfinletcond=Visitor.visitFramacExpr(self:>Visitor.frama_c_visitor)lblinfo.li_predicateinletpred=Logic_utils.expr_to_predicatecondinletpred=if!at=ReqthenLogic_const.pnotpredelsepredin(* NB negated*)lettop_pred=Logic_const.toplevel_predicate~kind:Checkpredinletcode_annot=AAssert([],top_pred)inletqueued_action()=letcode_annotation=Logic_const.new_code_annotationcode_annotinAnnotations.add_code_annot~kf:new_kfwp_emitterlblinfo.li_annotablecode_annotation;letip=Property.ip_of_code_annot_singlenew_kflblinfo.li_annotablecode_annotationininfo:=Someip;inQueue.addqueued_actionself#get_filling_actionsendletcreate_project_for_label?nameid=letname=matchnamewithNone->"label_"^string_of_intid|Somename->nameinletinfo=refNoneinletprj=File.create_project_from_visitorname(newlabel_selectoridinfo)inprj,!info