From 7d16c7b127b7dd49e445d4111aa604da17c7a121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 7 Jun 2021 18:57:35 +0200 Subject: [PATCH] Equality operators for ModelCheckerSettings and ImportRemapper --- libsolidity/formal/ModelCheckerSettings.h | 19 +++++++++++++++++++ libsolidity/interface/ImportRemapper.h | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/libsolidity/formal/ModelCheckerSettings.h b/libsolidity/formal/ModelCheckerSettings.h index 6b4c121ae..cfcd31d2c 100644 --- a/libsolidity/formal/ModelCheckerSettings.h +++ b/libsolidity/formal/ModelCheckerSettings.h @@ -44,6 +44,9 @@ struct ModelCheckerContracts return has(_source) && contracts.at(_source).count(_contract); } + bool operator!=(ModelCheckerContracts const& _other) const noexcept { return !(*this == _other); } + bool operator==(ModelCheckerContracts const& _other) const noexcept { return contracts == _other.contracts; } + /// Represents which contracts should be analyzed by the SMTChecker /// as the most derived. /// The key is the source file. If the map is empty, all sources must be analyzed. @@ -79,6 +82,9 @@ struct ModelCheckerEngine return engineMap.at(_engine); return {}; } + + bool operator!=(ModelCheckerEngine const& _other) const noexcept { return !(*this == _other); } + bool operator==(ModelCheckerEngine const& _other) const noexcept { return bmc == _other.bmc && chc == _other.chc; } }; enum class VerificationTargetType { ConstantCondition, Underflow, Overflow, UnderOverflow, DivByZero, Balance, Assert, PopEmptyArray, OutOfBounds }; @@ -97,6 +103,9 @@ struct ModelCheckerTargets static std::map const targetStrings; + bool operator!=(ModelCheckerTargets const& _other) const noexcept { return !(*this == _other); } + bool operator==(ModelCheckerTargets const& _other) const noexcept { return targets == _other.targets; } + std::set targets; }; @@ -106,6 +115,16 @@ struct ModelCheckerSettings ModelCheckerEngine engine = ModelCheckerEngine::None(); ModelCheckerTargets targets = ModelCheckerTargets::Default(); std::optional timeout; + + bool operator!=(ModelCheckerSettings const& _other) const noexcept { return !(*this == _other); } + bool operator==(ModelCheckerSettings const& _other) const noexcept + { + return + contracts == _other.contracts && + engine == _other.engine && + targets == _other.targets && + timeout == _other.timeout; + } }; } diff --git a/libsolidity/interface/ImportRemapper.h b/libsolidity/interface/ImportRemapper.h index 15e2803dc..4451f0291 100644 --- a/libsolidity/interface/ImportRemapper.h +++ b/libsolidity/interface/ImportRemapper.h @@ -35,6 +35,15 @@ class ImportRemapper public: struct Remapping { + bool operator!=(Remapping const& _other) const noexcept { return !(*this == _other); } + bool operator==(Remapping const& _other) const noexcept + { + return + context == _other.context && + prefix == _other.prefix && + target == _other.target; + } + std::string context; std::string prefix; std::string target;