mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove side-effect-free expressions, and not only movable expressions.
This commit is contained in:
parent
e8a88b13e4
commit
aa24e12054
@ -75,7 +75,7 @@ void UnusedPruner::operator()(Block& _block)
|
|||||||
{
|
{
|
||||||
if (!varDecl.value)
|
if (!varDecl.value)
|
||||||
statement = Block{std::move(varDecl.location), {}};
|
statement = Block{std::move(varDecl.location), {}};
|
||||||
else if (MovableChecker(m_dialect, *varDecl.value).movable())
|
else if (MovableChecker(m_dialect, *varDecl.value).sideEffectFree())
|
||||||
{
|
{
|
||||||
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
|
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
|
||||||
statement = Block{std::move(varDecl.location), {}};
|
statement = Block{std::move(varDecl.location), {}};
|
||||||
@ -93,9 +93,8 @@ void UnusedPruner::operator()(Block& _block)
|
|||||||
else if (statement.type() == typeid(ExpressionStatement))
|
else if (statement.type() == typeid(ExpressionStatement))
|
||||||
{
|
{
|
||||||
ExpressionStatement& exprStmt = boost::get<ExpressionStatement>(statement);
|
ExpressionStatement& exprStmt = boost::get<ExpressionStatement>(statement);
|
||||||
if (MovableChecker(m_dialect, exprStmt.expression).movable())
|
if (MovableChecker(m_dialect, exprStmt.expression).sideEffectFree())
|
||||||
{
|
{
|
||||||
// pop(x) should be movable!
|
|
||||||
subtractReferences(ReferencesCounter::countReferences(exprStmt.expression));
|
subtractReferences(ReferencesCounter::countReferences(exprStmt.expression));
|
||||||
statement = Block{std::move(exprStmt.location), {}};
|
statement = Block{std::move(exprStmt.location), {}};
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ struct Dialect;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimisation stage that removes unused variables and functions and also
|
* Optimisation stage that removes unused variables and functions and also
|
||||||
* removes movable expression statements.
|
* removes side-effect-free expression statements.
|
||||||
*
|
*
|
||||||
* Note that this does not remove circular references.
|
* Note that this does not remove circular references.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user