45
45
46
46
using namespace solidity ;
47
47
using namespace solidity ::yul;
48
- using namespace std ;
49
48
50
49
namespace
51
50
{
@@ -82,15 +81,15 @@ void cleanUnreachable(CFG& _cfg)
82
81
// / Sets the ``recursive`` member to ``true`` for all recursive function calls.
83
82
void markRecursiveCalls (CFG& _cfg)
84
83
{
85
- map<CFG::BasicBlock*, vector<CFG::FunctionCall*>> callsPerBlock;
84
+ std:: map<CFG::BasicBlock*, std:: vector<CFG::FunctionCall*>> callsPerBlock;
86
85
auto const & findCalls = [&](CFG::BasicBlock* _block)
87
86
{
88
87
if (auto * calls = util::valueOrNullptr (callsPerBlock, _block))
89
88
return *calls;
90
- vector<CFG::FunctionCall*>& calls = callsPerBlock[_block];
89
+ std:: vector<CFG::FunctionCall*>& calls = callsPerBlock[_block];
91
90
util::BreadthFirstSearch<CFG::BasicBlock*>{{_block}}.run ([&](CFG::BasicBlock* _block, auto _addChild) {
92
91
for (auto & operation: _block->operations )
93
- if (auto * functionCall = get_if<CFG::FunctionCall>(&operation.operation ))
92
+ if (auto * functionCall = std:: get_if<CFG::FunctionCall>(&operation.operation ))
94
93
calls.emplace_back (functionCall);
95
94
std::visit (util::GenericVisitor{
96
95
[&](CFG::BasicBlock::MainExit const &) {},
@@ -131,7 +130,7 @@ void markRecursiveCalls(CFG& _cfg)
131
130
// / Entering such a block means that control flow will never return to a previously visited block.
132
131
void markStartsOfSubGraphs (CFG& _cfg)
133
132
{
134
- vector<CFG::BasicBlock*> entries;
133
+ std:: vector<CFG::BasicBlock*> entries;
135
134
entries.emplace_back (_cfg.entry );
136
135
for (auto && functionInfo: _cfg.functionInfo | ranges::views::values)
137
136
entries.emplace_back (functionInfo.entry );
@@ -141,17 +140,17 @@ void markStartsOfSubGraphs(CFG& _cfg)
141
140
* Detect bridges following Algorithm 1 in https://arxiv.org/pdf/2108.07346.pdf
142
141
* and mark the bridge targets as starts of sub-graphs.
143
142
*/
144
- set<CFG::BasicBlock*> visited;
145
- map<CFG::BasicBlock*, size_t > disc;
146
- map<CFG::BasicBlock*, size_t > low;
147
- map<CFG::BasicBlock*, CFG::BasicBlock*> parent;
143
+ std:: set<CFG::BasicBlock*> visited;
144
+ std:: map<CFG::BasicBlock*, size_t > disc;
145
+ std:: map<CFG::BasicBlock*, size_t > low;
146
+ std:: map<CFG::BasicBlock*, CFG::BasicBlock*> parent;
148
147
size_t time = 0 ;
149
148
auto dfs = [&](CFG::BasicBlock* _u, auto _recurse) -> void {
150
149
visited.insert (_u);
151
150
disc[_u] = low[_u] = time;
152
151
time++;
153
152
154
- vector<CFG::BasicBlock*> children = _u->entries ;
153
+ std:: vector<CFG::BasicBlock*> children = _u->entries ;
155
154
visit (util::GenericVisitor{
156
155
[&](CFG::BasicBlock::Jump const & _jump) {
157
156
children.emplace_back (_jump.target );
@@ -171,7 +170,7 @@ void markStartsOfSubGraphs(CFG& _cfg)
171
170
{
172
171
parent[v] = _u;
173
172
_recurse (v, _recurse);
174
- low[_u] = min (low[_u], low[v]);
173
+ low[_u] = std:: min (low[_u], low[v]);
175
174
if (low[v] > disc[_u])
176
175
{
177
176
// _u <-> v is a cut edge in the undirected graph
@@ -186,7 +185,7 @@ void markStartsOfSubGraphs(CFG& _cfg)
186
185
}
187
186
}
188
187
else if (v != parent[_u])
189
- low[_u] = min (low[_u], disc[v]);
188
+ low[_u] = std:: min (low[_u], disc[v]);
190
189
};
191
190
dfs (entry, dfs);
192
191
}
@@ -234,7 +233,7 @@ std::unique_ptr<CFG> ControlFlowGraphBuilder::build(
234
233
ControlFlowGraphBuilder::ControlFlowGraphBuilder (
235
234
CFG& _graph,
236
235
AsmAnalysisInfo const & _analysisInfo,
237
- map<FunctionDefinition const *, ControlFlowSideEffects> const & _functionSideEffects,
236
+ std:: map<FunctionDefinition const *, ControlFlowSideEffects> const & _functionSideEffects,
238
237
Dialect const & _dialect
239
238
):
240
239
m_graph(_graph),
@@ -271,7 +270,7 @@ void ControlFlowGraphBuilder::operator()(VariableDeclaration const& _varDecl)
271
270
yulAssert (m_currentBlock, " " );
272
271
auto declaredVariables = _varDecl.variables | ranges::views::transform ([&](TypedName const & _var) {
273
272
return VariableSlot{lookupVariable (_var.name ), _var.debugData };
274
- }) | ranges::to<vector<VariableSlot>>;
273
+ }) | ranges::to<std:: vector<VariableSlot>>;
275
274
Stack input;
276
275
if (_varDecl.value )
277
276
input = visitAssignmentRightHandSide (*_varDecl.value , declaredVariables.size ());
@@ -287,7 +286,7 @@ void ControlFlowGraphBuilder::operator()(Assignment const& _assignment)
287
286
{
288
287
auto assignedVariables = _assignment.variableNames | ranges::views::transform ([&](Identifier const & _var) {
289
288
return VariableSlot{lookupVariable (_var.name ), _var.debugData };
290
- }) | ranges::to<vector<VariableSlot>>;
289
+ }) | ranges::to<std:: vector<VariableSlot>>;
291
290
292
291
Stack input = visitAssignmentRightHandSide (*_assignment.value , assignedVariables.size ());
293
292
yulAssert (m_currentBlock);
@@ -314,7 +313,7 @@ void ControlFlowGraphBuilder::operator()(Block const& _block)
314
313
{
315
314
ScopedSaveAndRestore saveScope (m_scope, m_info.scopes .at (&_block).get ());
316
315
for (auto const & statement: _block.statements )
317
- if (auto const * function = get_if<FunctionDefinition>(&statement))
316
+ if (auto const * function = std:: get_if<FunctionDefinition>(&statement))
318
317
registerFunction (*function);
319
318
for (auto const & statement: _block.statements )
320
319
std::visit (*this , statement);
@@ -334,10 +333,10 @@ void ControlFlowGraphBuilder::operator()(If const& _if)
334
333
void ControlFlowGraphBuilder::operator ()(Switch const & _switch)
335
334
{
336
335
yulAssert (m_currentBlock, " " );
337
- shared_ptr<DebugData const > preSwitchDebugData = debugDataOf (_switch);
336
+ std:: shared_ptr<DebugData const > preSwitchDebugData = debugDataOf (_switch);
338
337
339
338
auto ghostVariableId = m_graph.ghostVariables .size ();
340
- YulString ghostVariableName (" GHOST[" + to_string (ghostVariableId) + " ]" );
339
+ YulString ghostVariableName (" GHOST[" + std:: to_string (ghostVariableId) + " ]" );
341
340
auto & ghostVar = m_graph.ghostVariables .emplace_back (Scope::Variable{" " _yulstring, ghostVariableName});
342
341
343
342
// Artificially generate:
@@ -394,12 +393,12 @@ void ControlFlowGraphBuilder::operator()(Switch const& _switch)
394
393
395
394
void ControlFlowGraphBuilder::operator ()(ForLoop const & _loop)
396
395
{
397
- shared_ptr<DebugData const > preLoopDebugData = debugDataOf (_loop);
396
+ std:: shared_ptr<DebugData const > preLoopDebugData = debugDataOf (_loop);
398
397
ScopedSaveAndRestore scopeRestore (m_scope, m_info.scopes .at (&_loop.pre ).get ());
399
398
(*this )(_loop.pre );
400
399
401
400
std::optional<bool > constantCondition;
402
- if (auto const * literalCondition = get_if<yul::Literal>(_loop.condition .get ()))
401
+ if (auto const * literalCondition = std:: get_if<yul::Literal>(_loop.condition .get ()))
403
402
constantCondition = valueOfLiteral (*literalCondition) != 0 ;
404
403
405
404
CFG::BasicBlock& loopCondition = m_graph.makeBlock (debugDataOf (*_loop.condition ));
@@ -497,13 +496,13 @@ void ControlFlowGraphBuilder::registerFunction(FunctionDefinition const& _functi
497
496
std::get<Scope::Variable>(virtualFunctionScope->identifiers .at (_param.name )),
498
497
_param.debugData
499
498
};
500
- }) | ranges::to<vector>,
499
+ }) | ranges::to<std:: vector>,
501
500
_functionDefinition.returnVariables | ranges::views::transform ([&](auto const & _retVar) {
502
501
return VariableSlot{
503
502
std::get<Scope::Variable>(virtualFunctionScope->identifiers .at (_retVar.name )),
504
503
_retVar.debugData
505
504
};
506
- }) | ranges::to<vector>,
505
+ }) | ranges::to<std:: vector>,
507
506
{},
508
507
m_functionSideEffects.at (&_functionDefinition).canContinue
509
508
})).second ;
@@ -609,7 +608,7 @@ Scope::Variable const& ControlFlowGraphBuilder::lookupVariable(YulString _name)
609
608
}
610
609
611
610
void ControlFlowGraphBuilder::makeConditionalJump (
612
- shared_ptr<DebugData const > _debugData,
611
+ std:: shared_ptr<DebugData const > _debugData,
613
612
StackSlot _condition,
614
613
CFG::BasicBlock& _nonZero,
615
614
CFG::BasicBlock& _zero
@@ -628,7 +627,7 @@ void ControlFlowGraphBuilder::makeConditionalJump(
628
627
}
629
628
630
629
void ControlFlowGraphBuilder::jump (
631
- shared_ptr<DebugData const > _debugData,
630
+ std:: shared_ptr<DebugData const > _debugData,
632
631
CFG::BasicBlock& _target,
633
632
bool backwards
634
633
)
0 commit comments