@@ -93,32 +93,27 @@ void StructuralSimplifier::operator()(Block& _block)
93
93
94
94
void StructuralSimplifier::simplify (std::vector<yul::Statement>& _statements)
95
95
{
96
- // Explicit local variables ifLambda, switchLambda, forLoopLambda are created to avoid MSVC C++17 Debug test crash
97
- // (Run-Time Check Failure #2 - Stack around the variable '....' was corrupted).
98
- // As soon as the issue is fixed, this workaround can be removed.
99
- auto ifLambda = [&](If& _ifStmt) -> OptionalStatements
100
- {
101
- if (expressionAlwaysTrue (*_ifStmt.condition ))
102
- return {std::move (_ifStmt.body .statements )};
103
- else if (expressionAlwaysFalse (*_ifStmt.condition ))
104
- return {vector<Statement>{}};
105
- return {};
106
- };
107
- auto switchLambda = [&](Switch& _switchStmt) -> OptionalStatements
108
- {
109
- if (std::optional<u256> const constExprVal = hasLiteralValue (*_switchStmt.expression ))
110
- return replaceConstArgSwitch (_switchStmt, constExprVal.value ());
111
- return {};
112
- };
113
- auto forLoopLambda = [&](ForLoop& _forLoop) -> OptionalStatements
114
- {
115
- if (expressionAlwaysFalse (*_forLoop.condition ))
116
- return {std::move (_forLoop.pre .statements )};
117
- return {};
96
+ util::GenericVisitor visitor{
97
+ util::VisitorFallback<OptionalStatements>{},
98
+ [&](If& _ifStmt) -> OptionalStatements {
99
+ if (expressionAlwaysTrue (*_ifStmt.condition ))
100
+ return {std::move (_ifStmt.body .statements )};
101
+ else if (expressionAlwaysFalse (*_ifStmt.condition ))
102
+ return {vector<Statement>{}};
103
+ return {};
104
+ },
105
+ [&](Switch& _switchStmt) -> OptionalStatements {
106
+ if (std::optional<u256> const constExprVal = hasLiteralValue (*_switchStmt.expression ))
107
+ return replaceConstArgSwitch (_switchStmt, constExprVal.value ());
108
+ return {};
109
+ },
110
+ [&](ForLoop& _forLoop) -> OptionalStatements {
111
+ if (expressionAlwaysFalse (*_forLoop.condition ))
112
+ return {std::move (_forLoop.pre .statements )};
113
+ return {};
114
+ }
118
115
};
119
116
120
- util::GenericVisitor visitor{util::VisitorFallback<OptionalStatements>{}, ifLambda, switchLambda, forLoopLambda};
121
-
122
117
util::iterateReplacing (
123
118
_statements,
124
119
[&](Statement& _stmt) -> OptionalStatements
0 commit comments