12345678910111213141516171819202122232425262728293031323334353637383940openGoblintCiltypet=|GlobalofCilType.Varinfo.t|Nodeof{node:Node.t;fundec:CilType.Fundec.toption}[@@derivingord]type'vf='v->unitletvarinfo_from_global(g:Cil.global):Cil.varinfooption=matchgwith|GFun(f,_)->Somef.svar|GVar(v,_,_)->Somev|GVarDecl(v,_)->Somev|_->Noneletvarquery_from_global(g:Cil.global):toption=matchgwith|GFun(f,_)->Some(Node{node=FunctionEntryf;fundec=Somef})|GVar(v,_,_)->Some(Globalv)|GVarDecl(v,_)->Some(Globalv)|_->Noneletvarqueries_from_names(file:Cil.file)(names:stringlist):tlist*stringlist=letmoduleSM=Set.Make(Printable.Strings)inletset=SM.of_listnamesin(* Find list of [Cil.global]s that have one of the queried names, and a set of the found names *)letglobals,matched=Cil.foldGlobalsfile(fun((globs,matched)asacc)g->matchvarinfo_from_globalg,varquery_from_globalgwith|Somev,Somevq->beginmatchSM.memv.vnamesetwith|true->(vq::globs,SM.addv.vnamematched)|_->accend|None,None->acc|_,_->assertfalse)([],SM.empty)in(* List of queried but not found names *)letunmatched=List.filter(funs->not@@SM.memsmatched)namesinglobals,unmatched