mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-20 10:55:14 +00:00
Unit tests for flowgraph pretty printing.
Each test works by rendering the flowgraph for the last identified block we see in expanded pretty-printed output, and comparing it (via `diff`) against a checked in "foo.dot-expected.dot" file. Each test post-processes the output to remove NodeIds ` (id=NUM)` so that the expected output is somewhat stable (or at least independent of how we assign NodeIds) and easier for a human to interpret when looking at the expected output file itself. ---- Test writing style notes: I usually tried to write the tests in a way that would avoid duplicate labels in the output rendered flow graph, when possible. The tests that have string literals "unreachable" in the program text are deliberately written that way to remind the reader that the unreachable nodes in the resulting graph are not an error in the control flow computation, but rather a natural consequence of its construction.
This commit is contained in:
parent
aaf398f26a
commit
3aad0e249c
37
src/test/run-make/graphviz-flowgraph/Makefile
Normal file
37
src/test/run-make/graphviz-flowgraph/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
-include ../tools.mk
|
||||
|
||||
FILES=f00.rs f01.rs f02.rs f03.rs f04.rs f05.rs f06.rs f07.rs \
|
||||
f08.rs f09.rs f10.rs f11.rs f12.rs f13.rs f14.rs f15.rs \
|
||||
f16.rs f17.rs f18.rs f19.rs f20.rs f21.rs f22.rs
|
||||
|
||||
|
||||
# all: $(patsubst %.rs,$(TMPDIR)/%.dot,$(FILES)) $(patsubst %.rs,$(TMPDIR)/%.pp,$(FILES))
|
||||
all: $(patsubst %.rs,$(TMPDIR)/%.check,$(FILES))
|
||||
|
||||
|
||||
RUSTC_LIB=$(RUSTC) --crate-type=lib
|
||||
|
||||
define FIND_LAST_BLOCK
|
||||
LASTBLOCKNUM_$(1) := $(shell $(RUSTC_LIB) --pretty=expanded,identified $(1) \
|
||||
| grep block
|
||||
| tail -1
|
||||
| sed -e 's@.*/\* block \([0-9]*\) \*/.*@\1@')
|
||||
endef
|
||||
|
||||
ifeq ($(findstring rustc,$(RUSTC)),)
|
||||
$(error Must set RUSTC)
|
||||
endif
|
||||
|
||||
$(TMPDIR)/%.pp: %.rs
|
||||
$(RUSTC_LIB) --pretty=expanded,identified $< -o $@
|
||||
|
||||
$(TMPDIR)/%.dot: %.rs
|
||||
$(eval $(call FIND_LAST_BLOCK,$<))
|
||||
$(RUSTC_LIB) --pretty flowgraph=$(LASTBLOCKNUM_$<) $< -o $@.tmp
|
||||
cat $@.tmp | sed -e 's@ (id=[0-9]*)@@g' \
|
||||
-e 's@\[label=""\]@@' \
|
||||
-e 's@digraph [a-zA-Z0-9_]* @digraph block @' \
|
||||
> $@
|
||||
|
||||
$(TMPDIR)/%.check: %.rs $(TMPDIR)/%.dot
|
||||
diff -u $(patsubst %.rs,$(TMPDIR)/%.dot,$<) $(patsubst %.rs,%.dot-expected.dot,$<)
|
@ -0,0 +1,7 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="block { }"];
|
||||
N0 -> N2;
|
||||
N2 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f00.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f00.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn empty_0() {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 1"];
|
||||
N3[label="block { 1; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f01.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f01.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn lit_1() {
|
||||
1;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="local _x"];
|
||||
N3[label="block { let _x: int; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f02.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f02.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn decl_x_2() {
|
||||
let _x : int;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot
Normal file
13
src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot
Normal file
@ -0,0 +1,13 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 3"];
|
||||
N3[label="expr 33"];
|
||||
N4[label="expr 3 + 33"];
|
||||
N5[label="block { 3 + 33; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f03.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f03.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_add_3() {
|
||||
3 + 33;
|
||||
}
|
11
src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot
Normal file
11
src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot
Normal file
@ -0,0 +1,11 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 4"];
|
||||
N3[label="local _x"];
|
||||
N4[label="block { let _x = 4; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f04.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f04.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn pat_id_4() {
|
||||
let _x = 4;
|
||||
}
|
19
src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot
Normal file
19
src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot
Normal file
@ -0,0 +1,19 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 5"];
|
||||
N3[label="expr 55"];
|
||||
N4[label="expr (5, 55)"];
|
||||
N5[label="local _x"];
|
||||
N6[label="local _y"];
|
||||
N7[label="pat (_x, _y)"];
|
||||
N8[label="block { let (_x, _y) = (5, 55); }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f05.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f05.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn pat_tup_5() {
|
||||
let (_x, _y) = (5, 55);
|
||||
}
|
15
src/test/run-make/graphviz-flowgraph/f06.dot-expected.dot
Normal file
15
src/test/run-make/graphviz-flowgraph/f06.dot-expected.dot
Normal file
@ -0,0 +1,15 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 6"];
|
||||
N3[label="expr S6{val: 6,}"];
|
||||
N4[label="local _x"];
|
||||
N5[label="pat S6{val: _x}"];
|
||||
N6[label="block { let S6{val: _x} = S6{val: 6,}; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N1;
|
||||
}
|
14
src/test/run-make/graphviz-flowgraph/f06.rs
Normal file
14
src/test/run-make/graphviz-flowgraph/f06.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct S6 { val: int }
|
||||
pub fn pat_struct_6() {
|
||||
let S6 { val: _x } = S6{ val: 6 };
|
||||
}
|
33
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
Normal file
33
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
Normal file
@ -0,0 +1,33 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 7"];
|
||||
N3[label="expr 77"];
|
||||
N4[label="expr 777"];
|
||||
N5[label="expr 7777"];
|
||||
N6[label="expr [7, 77, 777, 7777]"];
|
||||
N7[label="expr match [7, 77, 777, 7777] { [x, y, ..] => x + y }"];
|
||||
N8[label="local x"];
|
||||
N9[label="local y"];
|
||||
N10[label="pat .."];
|
||||
N11[label="pat [x, y, ..]"];
|
||||
N12[label="expr x"];
|
||||
N13[label="expr y"];
|
||||
N14[label="expr x + y"];
|
||||
N15[label="block { match [7, 77, 777, 7777] { [x, y, ..] => x + y }; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N8;
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N14;
|
||||
N14 -> N7;
|
||||
N7 -> N15;
|
||||
N15 -> N1;
|
||||
}
|
15
src/test/run-make/graphviz-flowgraph/f07.rs
Normal file
15
src/test/run-make/graphviz-flowgraph/f07.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn pat_vec_7() {
|
||||
match [7, 77, 777, 7777] {
|
||||
[x, y, ..] => x + y
|
||||
};
|
||||
}
|
30
src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot
Normal file
30
src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot
Normal file
@ -0,0 +1,30 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 8"];
|
||||
N3[label="local x"];
|
||||
N4[label="local _y"];
|
||||
N5[label="expr x"];
|
||||
N6[label="expr 88"];
|
||||
N7[label="expr x > 88"];
|
||||
N8[label="expr 888"];
|
||||
N9[label="expr _y"];
|
||||
N10[label="expr _y = 888"];
|
||||
N11[label="block { _y = 888; }"];
|
||||
N12[label="expr if x > 88 { _y = 888; }"];
|
||||
N13[label="block { let x = 8; let _y; if x > 88 { _y = 888; } }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N7 -> N12;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N1;
|
||||
}
|
16
src/test/run-make/graphviz-flowgraph/f08.rs
Normal file
16
src/test/run-make/graphviz-flowgraph/f08.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_if_onearm_8() {
|
||||
let x = 8; let _y;
|
||||
if x > 88 {
|
||||
_y = 888;
|
||||
}
|
||||
}
|
44
src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot
Normal file
44
src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot
Normal file
@ -0,0 +1,44 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 91"];
|
||||
N3[label="local x"];
|
||||
N4[label="local _y"];
|
||||
N5[label="expr x"];
|
||||
N6[label="expr 92"];
|
||||
N7[label="expr x > 92"];
|
||||
N8[label="expr 93"];
|
||||
N9[label="expr _y"];
|
||||
N10[label="expr _y = 93"];
|
||||
N11[label="block { _y = 93; }"];
|
||||
N12[label="expr 94"];
|
||||
N13[label="expr 95"];
|
||||
N14[label="expr 94 + 95"];
|
||||
N15[label="expr _y"];
|
||||
N16[label="expr _y = 94 + 95"];
|
||||
N17[label="block { _y = 94 + 95; }"];
|
||||
N18[label="expr { _y = 94 + 95; }"];
|
||||
N19[label="expr if x > 92 { _y = 93; } else { _y = 94 + 95; }"];
|
||||
N20[label="block { let x = 91; let _y; if x > 92 { _y = 93; } else { _y = 94 + 95; } }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N7 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N14;
|
||||
N14 -> N15;
|
||||
N15 -> N16;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N11 -> N19;
|
||||
N18 -> N19;
|
||||
N19 -> N20;
|
||||
N20 -> N1;
|
||||
}
|
18
src/test/run-make/graphviz-flowgraph/f09.rs
Normal file
18
src/test/run-make/graphviz-flowgraph/f09.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_if_twoarm_9() {
|
||||
let x = 91; let _y;
|
||||
if x > 92 {
|
||||
_y = 93;
|
||||
} else {
|
||||
_y = 94+95;
|
||||
}
|
||||
}
|
30
src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot
Normal file
30
src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot
Normal file
@ -0,0 +1,30 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 10"];
|
||||
N3[label="local mut x"];
|
||||
N4[label="(dummy_node)"];
|
||||
N5[label="expr x"];
|
||||
N6[label="expr 0"];
|
||||
N7[label="expr x > 0"];
|
||||
N8[label="expr while x > 0 { x -= 1; }"];
|
||||
N9[label="expr 1"];
|
||||
N10[label="expr x"];
|
||||
N11[label="expr x -= 1"];
|
||||
N12[label="block { x -= 1; }"];
|
||||
N13[label="block { let mut x = 10; while x > 0 { x -= 1; } }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N7 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N4;
|
||||
N8 -> N13;
|
||||
N13 -> N1;
|
||||
}
|
16
src/test/run-make/graphviz-flowgraph/f10.rs
Normal file
16
src/test/run-make/graphviz-flowgraph/f10.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_while_10() {
|
||||
let mut x = 10;
|
||||
while x > 0 {
|
||||
x -= 1;
|
||||
}
|
||||
}
|
25
src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot
Normal file
25
src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot
Normal file
@ -0,0 +1,25 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 11"];
|
||||
N3[label="local mut _x"];
|
||||
N4[label="(dummy_node)"];
|
||||
N5[label="expr loop { _x -= 1; }"];
|
||||
N6[label="expr 1"];
|
||||
N7[label="expr _x"];
|
||||
N8[label="expr _x -= 1"];
|
||||
N9[label="block { _x -= 1; }"];
|
||||
N10[label="expr \"unreachable\""];
|
||||
N11[label="block { let mut _x = 11; loop { _x -= 1; } \"unreachable\"; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N9;
|
||||
N9 -> N4;
|
||||
N5 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N1;
|
||||
}
|
18
src/test/run-make/graphviz-flowgraph/f11.rs
Normal file
18
src/test/run-make/graphviz-flowgraph/f11.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_loop_11() {
|
||||
let mut _x = 11;
|
||||
loop {
|
||||
_x -= 1;
|
||||
}
|
||||
"unreachable";
|
||||
}
|
40
src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot
Normal file
40
src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot
Normal file
@ -0,0 +1,40 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 12"];
|
||||
N3[label="local mut x"];
|
||||
N4[label="(dummy_node)"];
|
||||
N5[label="expr loop { x -= 1; if x == 2 { break ; \"unreachable\"; } }"];
|
||||
N6[label="expr 1"];
|
||||
N7[label="expr x"];
|
||||
N8[label="expr x -= 1"];
|
||||
N9[label="expr x"];
|
||||
N10[label="expr 2"];
|
||||
N11[label="expr x == 2"];
|
||||
N12[label="expr break"];
|
||||
N13[label="(dummy_node)"];
|
||||
N14[label="expr \"unreachable\""];
|
||||
N15[label="block { break ; \"unreachable\"; }"];
|
||||
N16[label="expr if x == 2 { break ; \"unreachable\"; }"];
|
||||
N17[label="block { x -= 1; if x == 2 { break ; \"unreachable\"; } }"];
|
||||
N18[label="block { let mut x = 12; loop { x -= 1; if x == 2 { break ; \"unreachable\"; } } }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N5[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2 { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1; if x == 2 { break ; \"unreachable\"; } }"];
|
||||
N13 -> N14;
|
||||
N14 -> N15;
|
||||
N11 -> N16;
|
||||
N15 -> N16;
|
||||
N16 -> N17;
|
||||
N17 -> N4;
|
||||
N5 -> N18;
|
||||
N18 -> N1;
|
||||
}
|
18
src/test/run-make/graphviz-flowgraph/f12.rs
Normal file
18
src/test/run-make/graphviz-flowgraph/f12.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_loop_12() {
|
||||
let mut x = 12;
|
||||
loop {
|
||||
x -= 1;
|
||||
if x == 2 { break; "unreachable"; }
|
||||
}
|
||||
}
|
44
src/test/run-make/graphviz-flowgraph/f13.dot-expected.dot
Normal file
44
src/test/run-make/graphviz-flowgraph/f13.dot-expected.dot
Normal file
@ -0,0 +1,44 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr E13b"];
|
||||
N3[label="expr 13"];
|
||||
N4[label="expr E13b(13)"];
|
||||
N5[label="local x"];
|
||||
N6[label="local _y"];
|
||||
N7[label="expr x"];
|
||||
N8[label="expr match x { E13a => _y = 1, E13b(v) => _y = v + 1 }"];
|
||||
N9[label="local E13a"];
|
||||
N10[label="expr 1"];
|
||||
N11[label="expr _y"];
|
||||
N12[label="expr _y = 1"];
|
||||
N13[label="local v"];
|
||||
N14[label="pat E13b(v)"];
|
||||
N15[label="expr v"];
|
||||
N16[label="expr 1"];
|
||||
N17[label="expr v + 1"];
|
||||
N18[label="expr _y"];
|
||||
N19[label="expr _y = v + 1"];
|
||||
N20[label="block {\l let x = E13b(13);\l let _y;\l match x { E13a => _y = 1, E13b(v) => _y = v + 1 }\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N8;
|
||||
N7 -> N13;
|
||||
N13 -> N14;
|
||||
N14 -> N15;
|
||||
N15 -> N16;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N18 -> N19;
|
||||
N19 -> N8;
|
||||
N8 -> N20;
|
||||
N20 -> N1;
|
||||
}
|
18
src/test/run-make/graphviz-flowgraph/f13.rs
Normal file
18
src/test/run-make/graphviz-flowgraph/f13.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum E13 { E13a, E13b(int) }
|
||||
pub fn expr_match_13() {
|
||||
let x = E13b(13); let _y;
|
||||
match x {
|
||||
E13a => _y = 1,
|
||||
E13b(v) => _y = v + 1,
|
||||
}
|
||||
}
|
28
src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot
Normal file
28
src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot
Normal file
@ -0,0 +1,28 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 14"];
|
||||
N3[label="local x"];
|
||||
N4[label="expr x"];
|
||||
N5[label="expr 1"];
|
||||
N6[label="expr x > 1"];
|
||||
N7[label="expr return"];
|
||||
N8[label="(dummy_node)"];
|
||||
N9[label="expr \"unreachable\""];
|
||||
N10[label="block { return; \"unreachable\"; }"];
|
||||
N11[label="expr if x > 1 { return; \"unreachable\"; }"];
|
||||
N12[label="block { let x = 14; if x > 1 { return; \"unreachable\"; } }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N1;
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N6 -> N11;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N1;
|
||||
}
|
18
src/test/run-make/graphviz-flowgraph/f14.rs
Normal file
18
src/test/run-make/graphviz-flowgraph/f14.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_ret_14() {
|
||||
let x = 14;
|
||||
if x > 1 {
|
||||
return;
|
||||
"unreachable";
|
||||
}
|
||||
}
|
79
src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot
Normal file
79
src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot
Normal file
@ -0,0 +1,79 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 15"];
|
||||
N3[label="local mut x"];
|
||||
N4[label="expr 151"];
|
||||
N5[label="local mut y"];
|
||||
N6[label="(dummy_node)"];
|
||||
N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l y -= 4;\l x -= 5;\l }\l"];
|
||||
N8[label="(dummy_node)"];
|
||||
N9[label="expr \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l"];
|
||||
N10[label="expr x"];
|
||||
N11[label="expr 1"];
|
||||
N12[label="expr x == 1"];
|
||||
N13[label="expr break \'outer"];
|
||||
N14[label="(dummy_node)"];
|
||||
N15[label="expr \"unreachable\""];
|
||||
N16[label="block { break \'outer ; \"unreachable\" }"];
|
||||
N17[label="expr if x == 1 { break \'outer ; \"unreachable\" }"];
|
||||
N18[label="expr y"];
|
||||
N19[label="expr 2"];
|
||||
N20[label="expr y >= 2"];
|
||||
N21[label="expr break"];
|
||||
N22[label="(dummy_node)"];
|
||||
N23[label="expr \"unreachable\""];
|
||||
N24[label="block { break ; \"unreachable\" }"];
|
||||
N25[label="expr if y >= 2 { break ; \"unreachable\" }"];
|
||||
N26[label="expr 3"];
|
||||
N27[label="expr y"];
|
||||
N28[label="expr y -= 3"];
|
||||
N29[label="block {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l}\l"];
|
||||
N30[label="expr 4"];
|
||||
N31[label="expr y"];
|
||||
N32[label="expr y -= 4"];
|
||||
N33[label="expr 5"];
|
||||
N34[label="expr x"];
|
||||
N35[label="expr x -= 5"];
|
||||
N36[label="block {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l y -= 4;\l x -= 5;\l}\l"];
|
||||
N37[label="block {\l let mut x = 15;\l let mut y = 151;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l y -= 4;\l x -= 5;\l }\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N8;
|
||||
N8 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\" },\lexiting scope_3 expr if x == 1 { break \'outer ; \"unreachable\" },\lexiting scope_4 stmt if x == 1 { break \'outer ; \"unreachable\" },\lexiting scope_5 block {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l }\l y -= 4;\l x -= 5;\l}\l"];
|
||||
N14 -> N15;
|
||||
N15 -> N16;
|
||||
N12 -> N17;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N18 -> N19;
|
||||
N19 -> N20;
|
||||
N20 -> N21;
|
||||
N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\" },\lexiting scope_3 expr if y >= 2 { break ; \"unreachable\" },\lexiting scope_4 stmt if y >= 2 { break ; \"unreachable\" },\lexiting scope_5 block {\l if x == 1 { break \'outer ; \"unreachable\" }\l if y >= 2 { break ; \"unreachable\" }\l y -= 3;\l}\l"];
|
||||
N22 -> N23;
|
||||
N23 -> N24;
|
||||
N20 -> N25;
|
||||
N24 -> N25;
|
||||
N25 -> N26;
|
||||
N26 -> N27;
|
||||
N27 -> N28;
|
||||
N28 -> N29;
|
||||
N29 -> N8;
|
||||
N9 -> N30;
|
||||
N30 -> N31;
|
||||
N31 -> N32;
|
||||
N32 -> N33;
|
||||
N33 -> N34;
|
||||
N34 -> N35;
|
||||
N35 -> N36;
|
||||
N36 -> N6;
|
||||
N7 -> N37;
|
||||
N37 -> N1;
|
||||
}
|
30
src/test/run-make/graphviz-flowgraph/f15.rs
Normal file
30
src/test/run-make/graphviz-flowgraph/f15.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_break_label_15() {
|
||||
let mut x = 15;
|
||||
let mut y = 151;
|
||||
'outer: loop {
|
||||
'inner: loop {
|
||||
if x == 1 {
|
||||
break 'outer;
|
||||
"unreachable"
|
||||
}
|
||||
if y >= 2 {
|
||||
break;
|
||||
"unreachable"
|
||||
}
|
||||
y -= 3;
|
||||
}
|
||||
y -= 4;
|
||||
x -= 5;
|
||||
}
|
||||
}
|
81
src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot
Normal file
81
src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot
Normal file
@ -0,0 +1,81 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 16"];
|
||||
N3[label="local mut x"];
|
||||
N4[label="expr 16"];
|
||||
N5[label="local mut y"];
|
||||
N6[label="(dummy_node)"];
|
||||
N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l y -= 1;\l x -= 1;\l }\l"];
|
||||
N8[label="(dummy_node)"];
|
||||
N9[label="expr \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l"];
|
||||
N10[label="expr x"];
|
||||
N11[label="expr 1"];
|
||||
N12[label="expr x == 1"];
|
||||
N13[label="expr continue \'outer"];
|
||||
N14[label="(dummy_node)"];
|
||||
N15[label="expr \"unreachable\""];
|
||||
N16[label="block { continue \'outer ; \"unreachable\" }"];
|
||||
N17[label="expr if x == 1 { continue \'outer ; \"unreachable\" }"];
|
||||
N18[label="expr y"];
|
||||
N19[label="expr 1"];
|
||||
N20[label="expr y >= 1"];
|
||||
N21[label="expr break"];
|
||||
N22[label="(dummy_node)"];
|
||||
N23[label="expr \"unreachable\""];
|
||||
N24[label="block { break ; \"unreachable\" }"];
|
||||
N25[label="expr if y >= 1 { break ; \"unreachable\" }"];
|
||||
N26[label="expr 1"];
|
||||
N27[label="expr y"];
|
||||
N28[label="expr y -= 1"];
|
||||
N29[label="block {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l}\l"];
|
||||
N30[label="expr 1"];
|
||||
N31[label="expr y"];
|
||||
N32[label="expr y -= 1"];
|
||||
N33[label="expr 1"];
|
||||
N34[label="expr x"];
|
||||
N35[label="expr x -= 1"];
|
||||
N36[label="block {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l y -= 1;\l x -= 1;\l}\l"];
|
||||
N37[label="expr \"unreachable\""];
|
||||
N38[label="block {\l let mut x = 16;\l let mut y = 16;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l y -= 1;\l x -= 1;\l }\l \"unreachable\";\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N8;
|
||||
N8 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\" },\lexiting scope_3 expr if x == 1 { continue \'outer ; \"unreachable\" },\lexiting scope_4 stmt if x == 1 { continue \'outer ; \"unreachable\" },\lexiting scope_5 block {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l }\l y -= 1;\l x -= 1;\l}\l"];
|
||||
N14 -> N15;
|
||||
N15 -> N16;
|
||||
N12 -> N17;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N18 -> N19;
|
||||
N19 -> N20;
|
||||
N20 -> N21;
|
||||
N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\" },\lexiting scope_3 expr if y >= 1 { break ; \"unreachable\" },\lexiting scope_4 stmt if y >= 1 { break ; \"unreachable\" },\lexiting scope_5 block {\l if x == 1 { continue \'outer ; \"unreachable\" }\l if y >= 1 { break ; \"unreachable\" }\l y -= 1;\l}\l"];
|
||||
N22 -> N23;
|
||||
N23 -> N24;
|
||||
N20 -> N25;
|
||||
N24 -> N25;
|
||||
N25 -> N26;
|
||||
N26 -> N27;
|
||||
N27 -> N28;
|
||||
N28 -> N29;
|
||||
N29 -> N8;
|
||||
N9 -> N30;
|
||||
N30 -> N31;
|
||||
N31 -> N32;
|
||||
N32 -> N33;
|
||||
N33 -> N34;
|
||||
N34 -> N35;
|
||||
N35 -> N36;
|
||||
N36 -> N6;
|
||||
N7 -> N37;
|
||||
N37 -> N38;
|
||||
N38 -> N1;
|
||||
}
|
31
src/test/run-make/graphviz-flowgraph/f16.rs
Normal file
31
src/test/run-make/graphviz-flowgraph/f16.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_continue_label_16() {
|
||||
let mut x = 16;
|
||||
let mut y = 16;
|
||||
'outer: loop {
|
||||
'inner: loop {
|
||||
if x == 1 {
|
||||
continue 'outer;
|
||||
"unreachable"
|
||||
}
|
||||
if y >= 1 {
|
||||
break;
|
||||
"unreachable"
|
||||
}
|
||||
y -= 1;
|
||||
}
|
||||
y -= 1;
|
||||
x -= 1;
|
||||
}
|
||||
"unreachable";
|
||||
}
|
17
src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot
Normal file
17
src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot
Normal file
@ -0,0 +1,17 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 1"];
|
||||
N3[label="expr 7"];
|
||||
N4[label="expr 17"];
|
||||
N5[label="expr [1, 7, 17]"];
|
||||
N6[label="local _v"];
|
||||
N7[label="block { let _v = [1, 7, 17]; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N1;
|
||||
}
|
13
src/test/run-make/graphviz-flowgraph/f17.rs
Normal file
13
src/test/run-make/graphviz-flowgraph/f17.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_vec_17() {
|
||||
let _v = [1, 7, 17];
|
||||
}
|
17
src/test/run-make/graphviz-flowgraph/f18.dot-expected.dot
Normal file
17
src/test/run-make/graphviz-flowgraph/f18.dot-expected.dot
Normal file
@ -0,0 +1,17 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr inner"];
|
||||
N3[label="expr inner"];
|
||||
N4[label="expr 18"];
|
||||
N5[label="expr inner(18)"];
|
||||
N6[label="expr inner(inner(18))"];
|
||||
N7[label="block {\l fn inner(x: int) -> int { x + x }\l inner(inner(18));\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N1;
|
||||
}
|
14
src/test/run-make/graphviz-flowgraph/f18.rs
Normal file
14
src/test/run-make/graphviz-flowgraph/f18.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_call_18() {
|
||||
fn inner(x:int) -> int { x + x }
|
||||
inner(inner(18));
|
||||
}
|
19
src/test/run-make/graphviz-flowgraph/f19.dot-expected.dot
Normal file
19
src/test/run-make/graphviz-flowgraph/f19.dot-expected.dot
Normal file
@ -0,0 +1,19 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 19"];
|
||||
N3[label="expr S19{x: 19,}"];
|
||||
N4[label="local s"];
|
||||
N5[label="expr s"];
|
||||
N6[label="expr s.inner()"];
|
||||
N7[label="expr s.inner().inner()"];
|
||||
N8[label="block {\l struct S19 {\l x: int,\l }\l impl S19 {\l fn inner(self) -> S19 { S19{x: self.x + self.x,} }\l }\l let s = S19{x: 19,};\l s.inner().inner();\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N1;
|
||||
}
|
16
src/test/run-make/graphviz-flowgraph/f19.rs
Normal file
16
src/test/run-make/graphviz-flowgraph/f19.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_method_call_19() {
|
||||
struct S19 { x: int }
|
||||
impl S19 { fn inner(self) -> S19 { S19 { x: self.x + self.x } } }
|
||||
let s = S19 { x: 19 };
|
||||
s.inner().inner();
|
||||
}
|
23
src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot
Normal file
23
src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot
Normal file
@ -0,0 +1,23 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 2"];
|
||||
N3[label="expr 0"];
|
||||
N4[label="expr 20"];
|
||||
N5[label="expr [2, 0, 20]"];
|
||||
N6[label="local v"];
|
||||
N7[label="expr v"];
|
||||
N8[label="expr 20"];
|
||||
N9[label="expr v[20]"];
|
||||
N10[label="block { let v = [2, 0, 20]; v[20]; }"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N1;
|
||||
}
|
14
src/test/run-make/graphviz-flowgraph/f20.rs
Normal file
14
src/test/run-make/graphviz-flowgraph/f20.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn expr_index_20() {
|
||||
let v = [2, 0, 20];
|
||||
v[20];
|
||||
}
|
75
src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot
Normal file
75
src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot
Normal file
@ -0,0 +1,75 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 15"];
|
||||
N3[label="local mut x"];
|
||||
N4[label="expr 151"];
|
||||
N5[label="local mut y"];
|
||||
N6[label="(dummy_node)"];
|
||||
N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l \"unreachable\";\l }\l"];
|
||||
N8[label="(dummy_node)"];
|
||||
N9[label="expr \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l"];
|
||||
N10[label="expr x"];
|
||||
N11[label="expr 1"];
|
||||
N12[label="expr x == 1"];
|
||||
N13[label="expr break \'outer"];
|
||||
N14[label="(dummy_node)"];
|
||||
N15[label="expr \"unreachable\""];
|
||||
N16[label="block { break \'outer ; \"unreachable\"; }"];
|
||||
N17[label="expr if x == 1 { break \'outer ; \"unreachable\"; }"];
|
||||
N18[label="expr y"];
|
||||
N19[label="expr 2"];
|
||||
N20[label="expr y >= 2"];
|
||||
N21[label="expr return"];
|
||||
N22[label="(dummy_node)"];
|
||||
N23[label="expr \"unreachable\""];
|
||||
N24[label="block { return; \"unreachable\"; }"];
|
||||
N25[label="expr if y >= 2 { return; \"unreachable\"; }"];
|
||||
N26[label="expr 3"];
|
||||
N27[label="expr y"];
|
||||
N28[label="expr y -= 3"];
|
||||
N29[label="expr 5"];
|
||||
N30[label="expr x"];
|
||||
N31[label="expr x -= 5"];
|
||||
N32[label="block {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l}\l"];
|
||||
N33[label="expr \"unreachable\""];
|
||||
N34[label="block {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l \"unreachable\";\l}\l"];
|
||||
N35[label="block {\l let mut x = 15;\l let mut y = 151;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l \"unreachable\";\l }\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N8;
|
||||
N8 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1 { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1 { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l \"unreachable\";\l}\l"];
|
||||
N14 -> N15;
|
||||
N15 -> N16;
|
||||
N12 -> N17;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N18 -> N19;
|
||||
N19 -> N20;
|
||||
N20 -> N21;
|
||||
N21 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { break \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l y -= 3;\l x -= 5;\l }\l \"unreachable\";\l }\l"];
|
||||
N22 -> N23;
|
||||
N23 -> N24;
|
||||
N20 -> N25;
|
||||
N24 -> N25;
|
||||
N25 -> N26;
|
||||
N26 -> N27;
|
||||
N27 -> N28;
|
||||
N28 -> N29;
|
||||
N29 -> N30;
|
||||
N30 -> N31;
|
||||
N31 -> N32;
|
||||
N32 -> N8;
|
||||
N9 -> N33;
|
||||
N33 -> N34;
|
||||
N34 -> N6;
|
||||
N7 -> N35;
|
||||
N35 -> N1;
|
||||
}
|
30
src/test/run-make/graphviz-flowgraph/f21.rs
Normal file
30
src/test/run-make/graphviz-flowgraph/f21.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_break_label_21() {
|
||||
let mut x = 15;
|
||||
let mut y = 151;
|
||||
'outer: loop {
|
||||
'inner: loop {
|
||||
if x == 1 {
|
||||
break 'outer;
|
||||
"unreachable";
|
||||
}
|
||||
if y >= 2 {
|
||||
return;
|
||||
"unreachable";
|
||||
}
|
||||
y -= 3;
|
||||
x -= 5;
|
||||
}
|
||||
"unreachable";
|
||||
}
|
||||
}
|
77
src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot
Normal file
77
src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot
Normal file
@ -0,0 +1,77 @@
|
||||
digraph block {
|
||||
N0[label="entry"];
|
||||
N1[label="exit"];
|
||||
N2[label="expr 15"];
|
||||
N3[label="local mut x"];
|
||||
N4[label="expr 151"];
|
||||
N5[label="local mut y"];
|
||||
N6[label="(dummy_node)"];
|
||||
N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l \"unreachable\";\l }\l"];
|
||||
N8[label="(dummy_node)"];
|
||||
N9[label="expr \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l"];
|
||||
N10[label="expr x"];
|
||||
N11[label="expr 1"];
|
||||
N12[label="expr x == 1"];
|
||||
N13[label="expr continue \'outer"];
|
||||
N14[label="(dummy_node)"];
|
||||
N15[label="expr \"unreachable\""];
|
||||
N16[label="block { continue \'outer ; \"unreachable\"; }"];
|
||||
N17[label="expr if x == 1 { continue \'outer ; \"unreachable\"; }"];
|
||||
N18[label="expr y"];
|
||||
N19[label="expr 2"];
|
||||
N20[label="expr y >= 2"];
|
||||
N21[label="expr return"];
|
||||
N22[label="(dummy_node)"];
|
||||
N23[label="expr \"unreachable\""];
|
||||
N24[label="block { return; \"unreachable\"; }"];
|
||||
N25[label="expr if y >= 2 { return; \"unreachable\"; }"];
|
||||
N26[label="expr 1"];
|
||||
N27[label="expr x"];
|
||||
N28[label="expr x -= 1"];
|
||||
N29[label="expr 3"];
|
||||
N30[label="expr y"];
|
||||
N31[label="expr y -= 3"];
|
||||
N32[label="block {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l}\l"];
|
||||
N33[label="expr \"unreachable\""];
|
||||
N34[label="block {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l \"unreachable\";\l}\l"];
|
||||
N35[label="expr \"unreachable\""];
|
||||
N36[label="block {\l let mut x = 15;\l let mut y = 151;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l \"unreachable\";\l }\l \"unreachable\";\l}\l"];
|
||||
N0 -> N2;
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N8;
|
||||
N8 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1 { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1 { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l \"unreachable\";\l}\l"];
|
||||
N14 -> N15;
|
||||
N15 -> N16;
|
||||
N12 -> N17;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N18 -> N19;
|
||||
N19 -> N20;
|
||||
N20 -> N21;
|
||||
N21 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1 { continue \'outer ; \"unreachable\"; }\l if y >= 2 { return; \"unreachable\"; }\l x -= 1;\l y -= 3;\l }\l \"unreachable\";\l }\l"];
|
||||
N22 -> N23;
|
||||
N23 -> N24;
|
||||
N20 -> N25;
|
||||
N24 -> N25;
|
||||
N25 -> N26;
|
||||
N26 -> N27;
|
||||
N27 -> N28;
|
||||
N28 -> N29;
|
||||
N29 -> N30;
|
||||
N30 -> N31;
|
||||
N31 -> N32;
|
||||
N32 -> N8;
|
||||
N9 -> N33;
|
||||
N33 -> N34;
|
||||
N34 -> N6;
|
||||
N7 -> N35;
|
||||
N35 -> N36;
|
||||
N36 -> N1;
|
||||
}
|
31
src/test/run-make/graphviz-flowgraph/f22.rs
Normal file
31
src/test/run-make/graphviz-flowgraph/f22.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn expr_break_label_21() {
|
||||
let mut x = 15;
|
||||
let mut y = 151;
|
||||
'outer: loop {
|
||||
'inner: loop {
|
||||
if x == 1 {
|
||||
continue 'outer;
|
||||
"unreachable";
|
||||
}
|
||||
if y >= 2 {
|
||||
return;
|
||||
"unreachable";
|
||||
}
|
||||
x -= 1;
|
||||
y -= 3;
|
||||
}
|
||||
"unreachable";
|
||||
}
|
||||
"unreachable";
|
||||
}
|
Loading…
Reference in New Issue
Block a user