Skip to content

Commit fa5e9ac

Browse files
Add option witness.invariant.all-locals that can be turned off to only print locals definitely in scope
1 parent 887ebe0 commit fa5e9ac

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/cdomain/value/domains/invariantCil.ml

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ let exp_replace_original_name e =
2121
let var_is_in_scope scope vi =
2222
match Cilfacade.find_scope_fundec vi with
2323
| None -> vi.vstorage <> Static (* CIL pulls static locals into globals, but they aren't syntactically in global scope *)
24-
| Some fd -> CilType.Fundec.equal fd scope
24+
| Some fd ->
25+
if CilType.Fundec.equal fd scope then
26+
GobConfig.get_bool "witness.invariant.all-locals" || (not @@ hasAttribute "goblint_cil_nested" vi.vattr)
27+
else
28+
false
2529

2630
class exp_is_in_scope_visitor (scope: fundec) (acc: bool ref) = object
2731
inherit nopCilVisitor

src/config/options.schema.json

+6
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,12 @@
24492449
"RETURN"
24502450
]
24512451
},
2452+
"all-locals": {
2453+
"title": "witness.invariant.all-locals",
2454+
"description": "Emit invariants for local variables under the assumption they are always in scope within their function.",
2455+
"type": "boolean",
2456+
"default": true
2457+
},
24522458
"goblint": {
24532459
"title": "witness.invariant.goblint",
24542460
"description": "Emit non-standard Goblint-specific invariants. Currently array invariants with all_index offsets.",

src/maingoblint.ml

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ let check_arguments () =
143143
if get_bool "incremental.restart.sided.enabled" && get_string_list "incremental.restart.list" <> [] then warn "Passing a non-empty list to incremental.restart.list (manual restarting) while incremental.restart.sided.enabled (automatic restarting) is activated.";
144144
if get_bool "ana.autotune.enabled" && get_bool "incremental.load" then (set_bool "ana.autotune.enabled" false; warn "ana.autotune.enabled implicitly disabled by incremental.load");
145145
if get_bool "exp.basic-blocks" && not (get_bool "justcil") && List.mem "assert" @@ get_string_list "trans.activated" then (set_bool "exp.basic-blocks" false; warn "The option exp.basic-blocks implicitely disabled by activating the \"assert\" tranformation.");
146+
if (not @@ get_bool "witness.invariant.all-locals") && (not @@ get_bool "cil.addNestedScopeAttr") then (set_bool "cil.addNestedScopeAttr" true; warn "Disabling witness.invariant.all-locals implicitly enables cil.addNestedScopeAttr.");
146147
if List.mem "remove_dead_code" @@ get_string_list "trans.activated" then (
147148
(* 'assert' transform happens before 'remove_dead_code' transform *)
148149
ignore @@ List.fold_left

0 commit comments

Comments
 (0)