Skip to content

Commit 6f83c45

Browse files
rgrigfacebook-github-bot
authored andcommitted
[topl] Remove nondet marker
Summary: The explicit marker for nondeterministic states was used to speed up the shallow implementations of Topl, which ar enow removed. Reviewed By: jvillard Differential Revision: D27297019 fbshipit-source-id: 0fce93817
1 parent 55af83d commit 6f83c45

File tree

12 files changed

+8
-45
lines changed

12 files changed

+8
-45
lines changed

infer/src/topl/ToplAst.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,4 @@ type transition = {source: vertex; target: vertex; label: label option}
4747

4848
(* TODO(rgrigore): Check that registers are read only after being initialized *)
4949
type t =
50-
{ name: property_name
51-
; message: string option
52-
; prefixes: string list
53-
; nondet: string list
54-
; transitions: transition list }
50+
{name: property_name; message: string option; prefixes: string list; transitions: transition list}

infer/src/topl/ToplAutomaton.ml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ type tindex = int
3131

3232
type transition = {source: vindex; target: vindex; label: ToplAst.label option}
3333

34-
(** - INV1: Array.length states = Array.length outgoing = Array.length nondets
35-
- INV2: Array.length transitions = Array.length skips
36-
- INV3: each index of [transitions] occurs exactly once in one of [outgoing]'s lists
37-
- INV4: max_args is the maximum length of the arguments list in a label on a transition
34+
(** - INV1: Array.length transitions = Array.length skips
35+
- INV2: each index of [transitions] occurs exactly once in one of [outgoing]'s lists
36+
- INV3: max_args is the maximum length of the arguments list in a label on a transition
3837
3938
The fields marked as redundant are computed from the others (when the automaton is built), and
4039
are cached for speed. *)
4140
type t =
4241
{ states: vname array
43-
; nondets: bool array (* redundant *)
4442
; transitions: transition array
4543
; skips: bool array (* redundant *)
4644
; outgoing: tindex list array
@@ -76,7 +74,7 @@ let make properties =
7674
Array.of_list (List.dedup_and_sort ~compare:Vname.compare (List.concat_map ~f properties))
7775
in
7876
Array.iteri ~f:(fun i (p, v) -> tt "state[%d]=(%s,%s)@\n" i p v) states ;
79-
let vindex_opt, vindex = index_in (module Vname.Table) states in
77+
let _vindex_opt, vindex = index_in (module Vname.Table) states in
8078
let vindex = vindex "vertex" in
8179
let transitions : transition array =
8280
let f p =
@@ -118,30 +116,12 @@ let make properties =
118116
|> Array.max_elt ~compare:Int.compare
119117
|> Option.value ~default:0 |> succ
120118
in
121-
let nondets : bool array =
122-
let vcount = Array.length states in
123-
let a = Array.create ~len:vcount false in
124-
let f ToplAst.{nondet; name; _} =
125-
let set_nondet state =
126-
match vindex_opt (name, state) with
127-
| Some i ->
128-
a.(i) <- true
129-
| None ->
130-
L.user_warning
131-
"TOPL: %s declared as nondet, but it appears in no transition of property %s" state
132-
name
133-
in
134-
List.iter ~f:set_nondet nondet
135-
in
136-
List.iter ~f properties ;
137-
a
138-
in
139119
let skips : bool array =
140120
(* TODO(rgrigore): Rename "anys"? *)
141121
let is_skip {label} = Option.is_none label in
142122
Array.map ~f:is_skip transitions
143123
in
144-
{states; nondets; transitions; skips; outgoing; vindex; max_args}
124+
{states; transitions; skips; outgoing; vindex; max_args}
145125

146126

147127
let vname a i = a.states.(i)

infer/src/topl/ToplLexer.mll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ rule raw_token = parse
5656
| "prefix" { PREFIX }
5757
| "property" { PROPERTY }
5858
| "message" { MESSAGE }
59-
| "nondet" { NONDET }
6059
| "when" { WHEN }
6160
| ['a'-'z'] id_tail as id { LID id }
6261
| ['A'-'Z'] id_tail as id { UID id }

infer/src/topl/ToplParser.mly

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
%token LT
3131
%token MESSAGE
3232
%token NE
33-
%token NONDET
3433
%token PREFIX
3534
%token PROPERTY
3635
%token RC
@@ -46,16 +45,14 @@
4645
properties: ps=one_property* EOF { ps }
4746

4847
one_property:
49-
PROPERTY name=identifier LC message=message? prefixes=prefix* nondet=nondet
48+
PROPERTY name=identifier LC message=message? prefixes=prefix*
5049
transitions=transition* RC
51-
{ ToplAst.{name; message; prefixes; nondet; transitions} }
50+
{ ToplAst.{name; message; prefixes; transitions} }
5251

5352
message: MESSAGE s=STRING { s }
5453

5554
prefix: PREFIX s=STRING { s }
5655

57-
nondet: NONDET LP ns=state* RP { ns }
58-
5956
transition:
6057
source=state ARROW target=state COLON label=label
6158
{ ToplAst.{source; target; label} }

infer/tests/codetoanalyze/java/topl/baos/baos.topl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
property BaosRetrieveWithoutFlush
2-
nondet (start)
32
start -> start: *
43
start -> valid: ".*OutputStream"(X, Y, Ret) => x := X; y := Y
54
valid -> invalid: ".*OutputStream.write.*"(X, Ia, Ret) when X == x
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
property MaxArgs
2-
nondet (start)
32
start -> start: *
43
start -> error: "CompareArgs.max"(Ignore, I, J, IgnoreRet) when I >= J

infer/tests/codetoanalyze/java/topl/hasnext/hasnext.topl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ property HasNext
22
prefix "Iterator"
33
prefix "List"
44
prefix "Scanner"
5-
nondet (start)
65
start -> start: *
76
start -> invalid: iterator(Ignore, RetIter) => i := RetIter
87
start -> invalid: Scanner(Iter, IgnoreA, IgnoreB) => i := Iter // For constructors, "this" is first argument, and there's a dummy return

infer/tests/codetoanalyze/java/topl/immutableArray/immutableArray.topl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
property ImmutableArrayModified
22
prefix "ImmutableArray"
3-
nondet (start)
43
start -> start: *
54
start -> tracking: getTestArray(IgnoreObject, Array) => a := Array
65
tracking -> error: #ArrayWrite(Array, IgnoreIndex) when a == Array

infer/tests/codetoanalyze/java/topl/servlet/servlet.topl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
property InterleavedResponse
99
message "A ServletResponse was asked for both a writer and a stream."
1010
prefix "ServletResponse"
11-
nondet (start)
1211
start -> start: *
1312
start -> gotWriter: getWriter(R, IgnoreRet) => r := R
1413
start -> gotStream: getOutputStream(R, IgnoreRet) => r := R
@@ -17,7 +16,6 @@ property InterleavedResponse
1716

1817
property ForwardUncommitted
1918
message "A ServletResponse was forwarded before being committed."
20-
nondet (start)
2119
start -> start: *
2220
start -> gotChannel: "ServletResponse.\\(getWriter\\|getOutputStream\\)"(R, C) => r := R; c := C
2321
gotChannel -> ok: "\\(PrintWriter\\|ServletOutputStream\\).flush.*"(C, IgnoreRet) when C == c

infer/tests/codetoanalyze/java/topl/skip/SkipAfterRemove.topl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
property SkipAfterRemove
22
prefix "ArrayList"
3-
nondet (start)
43
start -> start: *
54
start -> removed: remove(Collection, Index, IgnoreRet) => c := Collection; i := Index
65
removed -> ok: get(Collection, Index, IgnoreRet) when i == Index && c == Collection

0 commit comments

Comments
 (0)