Skip to content

Commit bbfc0b3

Browse files
committed
Add Check.checkStandaloneExp
1 parent 56f5f9a commit bbfc0b3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/check.ml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ let checkAttributes (attrs: attribute list) : unit =
7979

8080

8181
(* Keep track of defined types *)
82-
let typeDefs : (string, typ) H.t = H.create 117
82+
let typeDefs : (string, typ) H.t = H.create 117 (* TODO: unused *)
8383

8484

8585
(* Keep track of all variables names, enum tags and type names *)
@@ -1086,3 +1086,26 @@ let checkFile flags fl =
10861086
if !E.verboseFlag then
10871087
ignore (E.log "Finished checking file %s\n" fl.fileName);
10881088
!valid
1089+
1090+
1091+
let checkStandaloneExp ~(vars: varinfo list) (exp: exp) =
1092+
if !E.verboseFlag then ignore (E.log "Checking exp %a\n" d_exp exp);
1093+
valid := true;
1094+
List.iter defineVariable vars;
1095+
1096+
(try ignore (checkExp false exp) with _ -> ());
1097+
1098+
(* Clean the hashes to let the GC do its job *)
1099+
H.clear typeDefs;
1100+
H.clear varNamesEnv;
1101+
H.clear varIdsEnv;
1102+
H.clear allVarIds;
1103+
H.clear fundecForVarIds;
1104+
H.clear compNames;
1105+
H.clear compUsed;
1106+
H.clear enumUsed;
1107+
H.clear typUsed;
1108+
varNamesList := [];
1109+
if !E.verboseFlag then
1110+
ignore (E.log "Finished checking exp %a\n" d_exp exp);
1111+
!valid

src/check.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ type checkFlags =
4545
(** Ignore the specified instructions *)
4646

4747
val checkFile: checkFlags list -> Cil.file -> bool
48+
49+
val checkStandaloneExp: vars:Cil.varinfo list -> Cil.exp -> bool

0 commit comments

Comments
 (0)