From 6ab31420afab093b5d81a2caa1b7de18d2619132 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 10 Mar 2022 09:51:20 +0100 Subject: [PATCH] Remove unneeded header files. --- libyul/optimiser/StructuralSimplifier.cpp | 48 +++++++++++------------ libyul/optimiser/StructuralSimplifier.h | 4 -- test/libyul/KnowledgeBaseTest.cpp | 1 - 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp index 5b1ae2550..ca8f94239 100644 --- a/libyul/optimiser/StructuralSimplifier.cpp +++ b/libyul/optimiser/StructuralSimplifier.cpp @@ -55,6 +55,30 @@ OptionalStatements replaceConstArgSwitch(Switch& _switchStmt, u256 const& _const return optional>{vector{}}; } +optional hasLiteralValue(Expression const& _expression) +{ + if (holds_alternative(_expression)) + return valueOfLiteral(std::get(_expression)); + else + return std::optional(); +} + +bool expressionAlwaysTrue(Expression const& _expression) +{ + if (std::optional value = hasLiteralValue(_expression)) + return *value != 0; + else + return false; +} + +bool expressionAlwaysFalse(Expression const& _expression) +{ + if (std::optional value = hasLiteralValue(_expression)) + return *value == 0; + else + return false; +} + } void StructuralSimplifier::run(OptimiserStepContext&, Block& _ast) @@ -103,27 +127,3 @@ void StructuralSimplifier::simplify(std::vector& _statements) } ); } - -bool StructuralSimplifier::expressionAlwaysTrue(Expression const& _expression) -{ - if (std::optional value = hasLiteralValue(_expression)) - return *value != 0; - else - return false; -} - -bool StructuralSimplifier::expressionAlwaysFalse(Expression const& _expression) -{ - if (std::optional value = hasLiteralValue(_expression)) - return *value == 0; - else - return false; -} - -std::optional StructuralSimplifier::hasLiteralValue(Expression const& _expression) const -{ - if (holds_alternative(_expression)) - return valueOfLiteral(std::get(_expression)); - else - return std::optional(); -} diff --git a/libyul/optimiser/StructuralSimplifier.h b/libyul/optimiser/StructuralSimplifier.h index 3fd59efde..734b2e53a 100644 --- a/libyul/optimiser/StructuralSimplifier.h +++ b/libyul/optimiser/StructuralSimplifier.h @@ -18,7 +18,6 @@ #pragma once #include -#include #include #include @@ -50,9 +49,6 @@ private: StructuralSimplifier() = default; void simplify(std::vector& _statements); - bool expressionAlwaysTrue(Expression const& _expression); - bool expressionAlwaysFalse(Expression const& _expression); - std::optional hasLiteralValue(Expression const& _expression) const; }; } diff --git a/test/libyul/KnowledgeBaseTest.cpp b/test/libyul/KnowledgeBaseTest.cpp index 03cc4cd8d..ac48f962f 100644 --- a/test/libyul/KnowledgeBaseTest.cpp +++ b/test/libyul/KnowledgeBaseTest.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include