Merge pull request #5595 from ethereum/ssavaluetracker-fix

SSAValueTracker should only use nullptr for default values
This commit is contained in:
chriseth 2018-12-05 22:08:46 +01:00 committed by GitHub
commit d3c8ba00ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 1 deletions

View File

@ -37,7 +37,7 @@ void SSAValueTracker::operator()(VariableDeclaration const& _varDecl)
{
if (_varDecl.variables.size() == 1)
setValue(_varDecl.variables.front().name, _varDecl.value.get());
else
else if (!_varDecl.value)
for (auto const& var: _varDecl.variables)
setValue(var.name, nullptr);
}

View File

@ -33,6 +33,8 @@ namespace yul
* Class that walks the AST and stores the initial value of each variable
* that is never assigned to.
*
* Default value is represented as nullptr.
*
* Prerequisite: Disambiguator
*/
class SSAValueTracker: public ASTWalker

View File

@ -0,0 +1,14 @@
{
function f() -> x, z {}
let c, d := f()
let y := add(d, add(c, 7))
}
// ----
// expressionSimplifier
// {
// function f() -> x, z
// {
// }
// let c, d := f()
// let y := add(add(d, c), 7)
// }

View File

@ -0,0 +1,12 @@
// c & d can't be optimized as expression simplifier doesn't handle default
// values yet
{
let c, d
let y := add(d, add(c, 7))
}
// ----
// expressionSimplifier
// {
// let c, d
// let y := add(add(d, c), 7)
// }