ControlFlowAnalyser: Also consider called functions in a flow

This commit is contained in:
Mathias Baumann
2021-06-01 15:54:37 +02:00
parent 3dfa68a574
commit 56ebea8b2f
33 changed files with 723 additions and 52 deletions
@@ -0,0 +1,12 @@
==== Source: s1.sol ====
function normal() pure returns (uint) { return 1337; }
function reverting() pure returns (uint) { revert(); }
==== Source: s2.sol ====
import "s1.sol";
contract C
{
function foo() public pure returns (uint) { normal(); }
function bar() public pure returns (uint) { reverting(); }
}
// ----
// Warning 6321: (s2.sol:67-71): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
@@ -0,0 +1,16 @@
==== Source: s1.sol ====
library L
{
function normal() public pure returns (uint) { return 1337; }
function reverting() public pure returns (uint) { revert(); }
}
==== Source: s2.sol ====
import "s1.sol";
contract C
{
function foo() public pure returns (uint) { L.normal(); }
function bar() public pure returns (uint) { L.reverting(); }
}
// ----
// Warning 6321: (s2.sol:67-71): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6321: (s2.sol:126-130): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
@@ -0,0 +1,15 @@
==== Source: s1.sol ====
contract C
{
function normal() public pure returns (uint) { return 1337; }
function reverting() public pure returns (uint) { revert(); }
}
==== Source: s2.sol ====
import "s1.sol";
contract D is C
{
function foo() public pure returns (uint) { normal(); }
function bar() public pure returns (uint) { reverting(); }
}
// ----
// Warning 6321: (s2.sol:72-76): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
@@ -0,0 +1,24 @@
==== Source: s1.sol ====
contract C
{
function normal(bool x) public pure returns (uint)
{
if (x)
return xxx();
else
return yyy();
}
function yyy() public pure returns (uint) { revert(); }
function bar() public pure returns (uint) { normal(true); }
function xxx() public virtual pure returns (uint) { return 1; }
}
==== Source: s2.sol ====
import "s1.sol";
contract D is C
{
function foo() public pure returns (uint) { normal(false); }
function xxx() public override pure returns(uint) { revert(); }
}
// ----
// Warning 6321: (s1.sol:215-219): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.