From ffb53ad8a6d5d576946ddeffb400ec2c3ce36f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 11 Aug 2023 18:55:01 +0200 Subject: [PATCH] fixup! Implementation of Lengauer-Tarjan algorithm to find dominators --- libyul/backends/evm/Dominator.h | 6 +++--- test/libyul/DominatorTest.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libyul/backends/evm/Dominator.h b/libyul/backends/evm/Dominator.h index 7de1f1410..5603409dc 100644 --- a/libyul/backends/evm/Dominator.h +++ b/libyul/backends/evm/Dominator.h @@ -95,7 +95,7 @@ public: // @note for a vertex ``_v``, the _v’s inclusion in the set of dominators of ``_v`` is implicit. std::vector dominatorsOf(Vertex _v) { - solAssert(m_vertex.size() > 0); + solAssert(!m_vertex.empty()); // The entry node always dominates all other nodes std::vector dominators = std::vector{m_vertex[0]}; @@ -112,8 +112,8 @@ public: } void buildDominatorTree() { - solAssert(m_vertex.size() > 0); - solAssert(m_immediateDominator.size() > 0); + solAssert(!m_vertex.empty()); + solAssert(!m_immediateDominator.empty()); //Ignoring the entry node since no one dominates it. for (size_t i = 1; i < m_immediateDominator.size(); ++i) diff --git a/test/libyul/DominatorTest.cpp b/test/libyul/DominatorTest.cpp index a27da3a40..943befb49 100644 --- a/test/libyul/DominatorTest.cpp +++ b/test/libyul/DominatorTest.cpp @@ -69,14 +69,14 @@ protected: std::map _expectedDFSIndices ) { - soltestAssert(_edges.size() > 0); + soltestAssert(!_edges.empty()); ImmediateDominatorTest* test = new ImmediateDominatorTest(); for (std::string name: _vertices) test->vertices.insert(make_pair(name, new Vertex{name, std::vector{}})); 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(); for (auto const& [from, to]: _edges)