cleanup break/continue fixup
we know which loop we're in when we're constructing the cfg, so let's link break/continue properly during cfg construction instead of doing the hacky "find which loop we're in after the fact" thing
my very basic testcase:
contract C {
function f() public {
for (uint i = 0; i < 10; i++) {
if (i > 100) {
break;
}
if (i < 3) {
continue;
}
for (uint j = 0; j < 10; j++) {
if (j > 10) {
continue;
}
if (j < 3) {
break;
}
j -= 1;
}
}
}
}
@0xalpharush: could you review if we can update the work done by @samczsun to work on the current dev?
TBD: we might want the CONTINUE node to point to the increment EXPRESSION and not STARTLOOP. See visualization here. Will open an issue and fix in a follow-on PR
I am a bit unsure about the usage of FunctionSolc. _loops, as this variable is meant for local analysis (during the parsing), but is added to the object itself. It might give the impression that this will contain all the loops, but it actually contain a list that is pushed/popped during the parsing.
Maybe we should make a functions' parameter, and rename it to something like loop_scope?
Can we merge this? I have a fix for continue (https://github.com/crytic/slither/pull/1651), but I'll need to rebase.