mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix MSVC Debug crash
This commit is contained in:
parent
34dd30d71b
commit
44093f2ed6
@ -93,26 +93,31 @@ void StructuralSimplifier::operator()(Block& _block)
|
|||||||
|
|
||||||
void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||||
{
|
{
|
||||||
util::GenericVisitor visitor{
|
// Explicit local variables ifLambda, switchLambda, forLoopLambda are created to avoid MSVC C++17 Debug test crash
|
||||||
util::VisitorFallback<OptionalStatements>{},
|
// (Run-Time Check Failure #2 - Stack around the variable '....' was corrupted).
|
||||||
[&](If& _ifStmt) -> OptionalStatements {
|
// As soon as the issue is fixed, this workaround can be removed.
|
||||||
if (expressionAlwaysTrue(*_ifStmt.condition))
|
auto ifLambda = [&](If& _ifStmt) -> OptionalStatements
|
||||||
return {std::move(_ifStmt.body.statements)};
|
{
|
||||||
else if (expressionAlwaysFalse(*_ifStmt.condition))
|
if (expressionAlwaysTrue(*_ifStmt.condition))
|
||||||
return {vector<Statement>{}};
|
return {std::move(_ifStmt.body.statements)};
|
||||||
return {};
|
else if (expressionAlwaysFalse(*_ifStmt.condition))
|
||||||
},
|
return {vector<Statement>{}};
|
||||||
[&](Switch& _switchStmt) -> OptionalStatements {
|
return {};
|
||||||
if (std::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
|
|
||||||
return replaceConstArgSwitch(_switchStmt, constExprVal.value());
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
[&](ForLoop& _forLoop) -> OptionalStatements {
|
|
||||||
if (expressionAlwaysFalse(*_forLoop.condition))
|
|
||||||
return {std::move(_forLoop.pre.statements)};
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
auto switchLambda = [&](Switch& _switchStmt) -> OptionalStatements
|
||||||
|
{
|
||||||
|
if (std::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
|
||||||
|
return replaceConstArgSwitch(_switchStmt, constExprVal.value());
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
auto forLoopLambda = [&](ForLoop& _forLoop) -> OptionalStatements
|
||||||
|
{
|
||||||
|
if (expressionAlwaysFalse(*_forLoop.condition))
|
||||||
|
return {std::move(_forLoop.pre.statements)};
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
util::GenericVisitor visitor{util::VisitorFallback<OptionalStatements>{}, ifLambda, switchLambda, forLoopLambda};
|
||||||
|
|
||||||
util::iterateReplacing(
|
util::iterateReplacing(
|
||||||
_statements,
|
_statements,
|
||||||
|
Loading…
Reference in New Issue
Block a user