mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add helper to see if a switch has a default case.
This commit is contained in:
parent
c6ac1625bd
commit
28593839d9
@ -457,8 +457,7 @@ void ControlFlowBuilder::operator()(yul::Switch const& _switch)
|
||||
}
|
||||
mergeFlow(nodes);
|
||||
|
||||
bool hasDefault = util::contains_if(_switch.cases, [](yul::Case const& _case) { return !_case.value; });
|
||||
if (!hasDefault)
|
||||
if (!hasDefaultCase(_switch))
|
||||
connect(beforeSwitch, m_currentNode);
|
||||
}
|
||||
|
||||
|
@ -144,4 +144,13 @@ template <class... Args> inline std::shared_ptr<DebugData const> debugDataOf(std
|
||||
return std::visit([](auto const& _arg) { return debugDataOf(_arg); }, _node);
|
||||
}
|
||||
|
||||
inline bool hasDefaultCase(Switch const& _switch)
|
||||
{
|
||||
return std::any_of(
|
||||
_switch.cases.begin(),
|
||||
_switch.cases.end(),
|
||||
[](Case const& _case) { return !_case.value; }
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,13 +60,7 @@ void removeEmptyDefaultFromSwitch(Switch& _switchStmt)
|
||||
|
||||
void removeEmptyCasesFromSwitch(Switch& _switchStmt)
|
||||
{
|
||||
bool hasDefault = std::any_of(
|
||||
_switchStmt.cases.begin(),
|
||||
_switchStmt.cases.end(),
|
||||
[](Case const& _case) { return !_case.value; }
|
||||
);
|
||||
|
||||
if (hasDefault)
|
||||
if (hasDefaultCase(_switchStmt))
|
||||
return;
|
||||
|
||||
ranges::actions::remove_if(
|
||||
|
Loading…
Reference in New Issue
Block a user