From c17ee4fe65ce81b0ad1966656b7929ed87c3b6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 10 Jun 2021 16:33:08 +0200 Subject: [PATCH] CommandLineParser: Equality operators for settings --- solc/CommandLineParser.cpp | 91 +++++++++++++++++++++++++++++++++++++- solc/CommandLineParser.h | 9 ++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 67c74236a..263637907 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -270,6 +270,95 @@ bool checkMutuallyExclusive(boost::program_options::variables_map const& args, s } +bool CompilerOutputs::operator==(CompilerOutputs const& _other) const noexcept +{ + static_assert( + sizeof(*this) == 15 * sizeof(bool), + "Remember to update code below if you add/remove fields." + ); + + return + astCompactJson == _other.astCompactJson && + asm_ == _other.asm_ && + asmJson == _other.asmJson && + opcodes == _other.opcodes && + binary == _other.binary && + binaryRuntime == _other.binaryRuntime && + abi == _other.abi && + ir == _other.ir && + irOptimized == _other.irOptimized && + ewasm == _other.ewasm && + signatureHashes == _other.signatureHashes && + natspecUser == _other.natspecUser && + natspecDev == _other.natspecDev && + metadata == _other.metadata && + storageLayout == _other.storageLayout; +} + +bool CombinedJsonRequests::operator==(CombinedJsonRequests const& _other) const noexcept +{ + static_assert( + sizeof(*this) == 17 * sizeof(bool), + "Remember to update code below if you add/remove fields." + ); + + return + abi == _other.abi && + metadata == _other.metadata && + binary == _other.binary && + binaryRuntime == _other.binaryRuntime && + opcodes == _other.opcodes && + asm_ == _other.asm_ && + storageLayout == _other.storageLayout && + generatedSources == _other.generatedSources && + generatedSourcesRuntime == _other.generatedSourcesRuntime && + srcMap == _other.srcMap && + srcMapRuntime == _other.srcMapRuntime && + funDebug == _other.funDebug && + funDebugRuntime == _other.funDebugRuntime && + signatureHashes == _other.signatureHashes && + natspecDev == _other.natspecDev && + natspecUser == _other.natspecUser && + ast == _other.ast; +} + +bool CommandLineOptions::operator==(CommandLineOptions const& _other) const noexcept +{ + return + input.paths == _other.input.paths && + input.standardJsonFile == _other.input.standardJsonFile && + input.remappings == _other.input.remappings && + input.addStdin == _other.input.addStdin && + input.basePath == _other.input.basePath && + input.allowedDirectories == _other.input.allowedDirectories && + input.ignoreMissingFiles == _other.input.ignoreMissingFiles && + input.errorRecovery == _other.input.errorRecovery && + output.dir == _other.output.dir && + output.overwriteFiles == _other.output.overwriteFiles && + output.evmVersion == _other.output.evmVersion && + output.experimentalViaIR == _other.output.experimentalViaIR && + output.revertStrings == _other.output.revertStrings && + output.stopAfter == _other.output.stopAfter && + input.mode == _other.input.mode && + assembly.targetMachine == _other.assembly.targetMachine && + assembly.inputLanguage == _other.assembly.inputLanguage && + linker.libraries == _other.linker.libraries && + formatting.prettyJson == _other.formatting.prettyJson && + formatting.coloredOutput == _other.formatting.coloredOutput && + formatting.withErrorIds == _other.formatting.withErrorIds && + compiler.outputs == _other.compiler.outputs && + compiler.estimateGas == _other.compiler.estimateGas && + compiler.combinedJsonRequests == _other.compiler.combinedJsonRequests && + metadata.hash == _other.metadata.hash && + metadata.literalSources == _other.metadata.literalSources && + optimizer.enabled == _other.optimizer.enabled && + optimizer.expectedExecutionsPerDeployment == _other.optimizer.expectedExecutionsPerDeployment && + optimizer.noOptimizeYul == _other.optimizer.noOptimizeYul && + optimizer.yulSteps == _other.optimizer.yulSteps && + modelChecker.initialize == _other.modelChecker.initialize && + modelChecker.settings == _other.modelChecker.settings; +} + bool CommandLineParser::parseInputPathsAndRemappings() { m_options.input.ignoreMissingFiles = (m_args.count(g_argIgnoreMissingFiles) > 0); @@ -768,7 +857,7 @@ General Information)").c_str(), m_options.formatting.prettyJson = (m_args.count(g_argPrettyJson) > 0); static_assert( - sizeof(m_options.compiler.selectedOutputs) == 15 * sizeof(bool), + sizeof(m_options.compiler.outputs) == 15 * sizeof(bool), "Remember to update code below if you add/remove fields." ); m_options.compiler.outputs.astCompactJson = (m_args.count(g_argAstCompactJson) > 0); diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index 4aaf0d9b5..7d7223419 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -51,6 +51,9 @@ enum class InputMode struct CompilerOutputs { + bool operator!=(CompilerOutputs const& _other) const noexcept { return !(*this == _other); } + bool operator==(CompilerOutputs const& _other) const noexcept; + bool astCompactJson = false; bool asm_ = false; bool asmJson = false; @@ -70,6 +73,9 @@ struct CompilerOutputs struct CombinedJsonRequests { + bool operator!=(CombinedJsonRequests const& _other) const noexcept { return !(*this == _other); } + bool operator==(CombinedJsonRequests const& _other) const noexcept; + bool abi = false; bool metadata = false; bool binary = false; @@ -91,6 +97,9 @@ struct CombinedJsonRequests struct CommandLineOptions { + bool operator==(CommandLineOptions const& _other) const noexcept; + bool operator!=(CommandLineOptions const& _other) const noexcept { return !(*this == _other); } + struct { InputMode mode = InputMode::Compiler;