@@ -435,8 +435,10 @@ let ghost_instr_loc = function
435435 originalstatement;
436436 ghostupdate;
437437 __VERIFIER_atomic_end();
438- ]} *)
439- class ghostUpdateVisitor (updates : (string, Cil.instr list) Hashtbl.t ) (atomic_begin : Cil.varinfo ) (atomic_end : Cil.varinfo ) = object
438+ ]}
439+ [placed] is populated with every key from [updates] that was successfully
440+ matched; callers can use this to warn about unmatched keys. *)
441+ class ghostUpdateVisitor (updates : (string, Cil.instr list) Hashtbl.t ) (placed : (string, unit) Hashtbl.t ) (atomic_begin : Cil.varinfo ) (atomic_end : Cil.varinfo ) = object
440442 inherit nopCilVisitor
441443
442444 method! vstmt s =
@@ -451,6 +453,7 @@ class ghostUpdateVisitor (updates : (string, Cil.instr list) Hashtbl.t) (atomic_
451453 (match Hashtbl. find_opt updates key with
452454 | None | Some [] -> [instr]
453455 | Some update_instrs ->
456+ Hashtbl. replace placed key () ;
454457 let abegin = Formatcil. cInstr " %v:__VERIFIER_atomic_begin();" loc
455458 [(" __VERIFIER_atomic_begin" , Cil. Fv atomic_begin)] in
456459 let aend = Formatcil. cInstr " %v:__VERIFIER_atomic_end();" loc
@@ -596,7 +599,12 @@ let init () =
596599 in
597600 let atomic_begin = find_or_make " __VERIFIER_atomic_begin" in
598601 let atomic_end = find_or_make " __VERIFIER_atomic_end" in
599- visitCilFile (new ghostUpdateVisitor updates atomic_begin atomic_end) file
602+ let placed : (string, unit) Hashtbl.t = Hashtbl. create 16 in
603+ visitCilFile (new ghostUpdateVisitor updates placed atomic_begin atomic_end) file;
604+ Hashtbl. iter (fun key _ ->
605+ if not (Hashtbl. mem placed key) then
606+ M. warn_noloc ~category: Witness " ghost update at %s could not be placed: no matching instruction found" key
607+ ) updates
600608 end
601609
602610module ValidationResult =
0 commit comments