Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standalone expression AST checking #96

Merged
merged 1 commit into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let checkAttributes (attrs: attribute list) : unit =


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


(* Keep track of all variables names, enum tags and type names *)
Expand Down Expand Up @@ -1086,3 +1086,26 @@ let checkFile flags fl =
if !E.verboseFlag then
ignore (E.log "Finished checking file %s\n" fl.fileName);
!valid


let checkStandaloneExp ~(vars: varinfo list) (exp: exp) =
if !E.verboseFlag then ignore (E.log "Checking exp %a\n" d_exp exp);
valid := true;
List.iter defineVariable vars;

(try ignore (checkExp false exp) with _ -> ());

(* Clean the hashes to let the GC do its job *)
H.clear typeDefs;
H.clear varNamesEnv;
H.clear varIdsEnv;
H.clear allVarIds;
H.clear fundecForVarIds;
H.clear compNames;
H.clear compUsed;
H.clear enumUsed;
H.clear typUsed;
varNamesList := [];
if !E.verboseFlag then
ignore (E.log "Finished checking exp %a\n" d_exp exp);
!valid
2 changes: 2 additions & 0 deletions src/check.mli
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ type checkFlags =
(** Ignore the specified instructions *)

val checkFile: checkFlags list -> Cil.file -> bool

val checkStandaloneExp: vars:Cil.varinfo list -> Cil.exp -> bool