Skip to content

Commit

Permalink
Merge pull request #96 from goblint/check-exp
Browse files Browse the repository at this point in the history
Add standalone expression AST checking
  • Loading branch information
sim642 authored May 27, 2022
2 parents 56f5f9a + bbfc0b3 commit 7fa0796
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
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

0 comments on commit 7fa0796

Please sign in to comment.