mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! Implementation of Lengauer-Tarjan algorithm to find dominators
This commit is contained in:
parent
9aad3688dc
commit
ffb53ad8a6
@ -95,7 +95,7 @@ public:
|
|||||||
// @note for a vertex ``_v``, the _v’s inclusion in the set of dominators of ``_v`` is implicit.
|
// @note for a vertex ``_v``, the _v’s inclusion in the set of dominators of ``_v`` is implicit.
|
||||||
std::vector<Vertex> dominatorsOf(Vertex _v)
|
std::vector<Vertex> dominatorsOf(Vertex _v)
|
||||||
{
|
{
|
||||||
solAssert(m_vertex.size() > 0);
|
solAssert(!m_vertex.empty());
|
||||||
// The entry node always dominates all other nodes
|
// The entry node always dominates all other nodes
|
||||||
std::vector<Vertex> dominators = std::vector<Vertex>{m_vertex[0]};
|
std::vector<Vertex> dominators = std::vector<Vertex>{m_vertex[0]};
|
||||||
|
|
||||||
@ -112,8 +112,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void buildDominatorTree() {
|
void buildDominatorTree() {
|
||||||
solAssert(m_vertex.size() > 0);
|
solAssert(!m_vertex.empty());
|
||||||
solAssert(m_immediateDominator.size() > 0);
|
solAssert(!m_immediateDominator.empty());
|
||||||
|
|
||||||
//Ignoring the entry node since no one dominates it.
|
//Ignoring the entry node since no one dominates it.
|
||||||
for (size_t i = 1; i < m_immediateDominator.size(); ++i)
|
for (size_t i = 1; i < m_immediateDominator.size(); ++i)
|
||||||
|
@ -69,14 +69,14 @@ protected:
|
|||||||
std::map<std::string, size_t> _expectedDFSIndices
|
std::map<std::string, size_t> _expectedDFSIndices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
soltestAssert(_edges.size() > 0);
|
soltestAssert(!_edges.empty());
|
||||||
|
|
||||||
ImmediateDominatorTest* test = new ImmediateDominatorTest();
|
ImmediateDominatorTest* test = new ImmediateDominatorTest();
|
||||||
for (std::string name: _vertices)
|
for (std::string name: _vertices)
|
||||||
test->vertices.insert(make_pair(name, new Vertex{name, std::vector<Vertex*>{}}));
|
test->vertices.insert(make_pair(name, new Vertex{name, std::vector<Vertex*>{}}));
|
||||||
test->entry = test->vertices[_vertices[0]];
|
test->entry = test->vertices[_vertices[0]];
|
||||||
|
|
||||||
soltestAssert(_vertices.size() > 0 && _vertices.size() == test->vertices.size());
|
soltestAssert(!_vertices.empty() && _vertices.size() == test->vertices.size());
|
||||||
|
|
||||||
test->numVertices = _vertices.size();
|
test->numVertices = _vertices.size();
|
||||||
for (auto const& [from, to]: _edges)
|
for (auto const& [from, to]: _edges)
|
||||||
|
Loading…
Reference in New Issue
Block a user