106e0cd412
To do this with a clean conscience, I needed to convert the unroll- counting logic from a linear time algorithm to constant-time. Getting all the edge cases correct requires a lot of care, and there are now plenty of unit tests. Change-Id: I620909d069ac425b7310e345bf80ec844fe035f8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445643 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
26 lines
1.3 KiB
Plaintext
26 lines
1.3 KiB
Plaintext
// Expect 15 errors
|
|
|
|
void loop_length_128() { for (int i = 0; i < 128; i++) {} } // OK, under kLoopTerminationLimit
|
|
void loop_length_129() { for (int i = 0; i < 129; i++) {} } // OK, under kLoopTerminationLimit
|
|
void loop_length_99999() { for (int i = 0; i < 99999; i++) {} } // OK, under kLoopTerminationLimit
|
|
void loop_length_100000() { for (int i = 0; i < 100000; i++) {} }
|
|
void infinite_loop1() { for (int i = 0; i < 1; i += 0) {} }
|
|
void infinite_loop2() { for (int i = 3; i >= 3; i += 0) {} }
|
|
void infinite_loop3() { for (float i = 3; i >= 3; i += 1e-20) {} }
|
|
|
|
void set(out int x) { x = 1; }
|
|
void inc(inout int x) { x++; }
|
|
|
|
void index_modified() { for (int i = 0; i < 2; i++) { i++; } }
|
|
void index_out_param() { for (int i = 0; i < 1; i++) { set(i); } }
|
|
void index_inout_param() { for (int i = 0; i < 1; i++) { inc(i); } }
|
|
|
|
void infinite_loop_le() { for (int i = 0; i <= 3; --i) {} }
|
|
void infinite_loop_lt() { for (int i = 0; i < 4; --i) {} }
|
|
void infinite_loop_ge() { for (int i = 3; i >= 0; ++i) {} }
|
|
void infinite_loop_gt() { for (int i = 3; i > -1; ++i) {} }
|
|
void infinite_loop_eq1() { for (int i = 0; i == 0; i-=0) {} }
|
|
void infinite_loop_eq2() { for (int i = 1; i == 1; i+=0) {} }
|
|
void infinite_loop_ne1() { for (int i = 0; i != 4; i--) {} }
|
|
void infinite_loop_ne2() { for (int i = 0; i != 4; i+=3) {} }
|