Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file instrument_label.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121(**************************************************************************)(* *)(* SPDX-License-Identifier LGPL-2.1 *)(* Copyright (C) *)(* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *)(* *)(**************************************************************************)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(SkipFileloc.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(SkipFileloc.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