Skip to content

Commit c17ee4f

Browse files
committed
CommandLineParser: Equality operators for settings
1 parent 7d16c7b commit c17ee4f

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

solc/CommandLineParser.cpp

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,95 @@ bool checkMutuallyExclusive(boost::program_options::variables_map const& args, s
270270

271271
}
272272

273+
bool CompilerOutputs::operator==(CompilerOutputs const& _other) const noexcept
274+
{
275+
static_assert(
276+
sizeof(*this) == 15 * sizeof(bool),
277+
"Remember to update code below if you add/remove fields."
278+
);
279+
280+
return
281+
astCompactJson == _other.astCompactJson &&
282+
asm_ == _other.asm_ &&
283+
asmJson == _other.asmJson &&
284+
opcodes == _other.opcodes &&
285+
binary == _other.binary &&
286+
binaryRuntime == _other.binaryRuntime &&
287+
abi == _other.abi &&
288+
ir == _other.ir &&
289+
irOptimized == _other.irOptimized &&
290+
ewasm == _other.ewasm &&
291+
signatureHashes == _other.signatureHashes &&
292+
natspecUser == _other.natspecUser &&
293+
natspecDev == _other.natspecDev &&
294+
metadata == _other.metadata &&
295+
storageLayout == _other.storageLayout;
296+
}
297+
298+
bool CombinedJsonRequests::operator==(CombinedJsonRequests const& _other) const noexcept
299+
{
300+
static_assert(
301+
sizeof(*this) == 17 * sizeof(bool),
302+
"Remember to update code below if you add/remove fields."
303+
);
304+
305+
return
306+
abi == _other.abi &&
307+
metadata == _other.metadata &&
308+
binary == _other.binary &&
309+
binaryRuntime == _other.binaryRuntime &&
310+
opcodes == _other.opcodes &&
311+
asm_ == _other.asm_ &&
312+
storageLayout == _other.storageLayout &&
313+
generatedSources == _other.generatedSources &&
314+
generatedSourcesRuntime == _other.generatedSourcesRuntime &&
315+
srcMap == _other.srcMap &&
316+
srcMapRuntime == _other.srcMapRuntime &&
317+
funDebug == _other.funDebug &&
318+
funDebugRuntime == _other.funDebugRuntime &&
319+
signatureHashes == _other.signatureHashes &&
320+
natspecDev == _other.natspecDev &&
321+
natspecUser == _other.natspecUser &&
322+
ast == _other.ast;
323+
}
324+
325+
bool CommandLineOptions::operator==(CommandLineOptions const& _other) const noexcept
326+
{
327+
return
328+
input.paths == _other.input.paths &&
329+
input.standardJsonFile == _other.input.standardJsonFile &&
330+
input.remappings == _other.input.remappings &&
331+
input.addStdin == _other.input.addStdin &&
332+
input.basePath == _other.input.basePath &&
333+
input.allowedDirectories == _other.input.allowedDirectories &&
334+
input.ignoreMissingFiles == _other.input.ignoreMissingFiles &&
335+
input.errorRecovery == _other.input.errorRecovery &&
336+
output.dir == _other.output.dir &&
337+
output.overwriteFiles == _other.output.overwriteFiles &&
338+
output.evmVersion == _other.output.evmVersion &&
339+
output.experimentalViaIR == _other.output.experimentalViaIR &&
340+
output.revertStrings == _other.output.revertStrings &&
341+
output.stopAfter == _other.output.stopAfter &&
342+
input.mode == _other.input.mode &&
343+
assembly.targetMachine == _other.assembly.targetMachine &&
344+
assembly.inputLanguage == _other.assembly.inputLanguage &&
345+
linker.libraries == _other.linker.libraries &&
346+
formatting.prettyJson == _other.formatting.prettyJson &&
347+
formatting.coloredOutput == _other.formatting.coloredOutput &&
348+
formatting.withErrorIds == _other.formatting.withErrorIds &&
349+
compiler.outputs == _other.compiler.outputs &&
350+
compiler.estimateGas == _other.compiler.estimateGas &&
351+
compiler.combinedJsonRequests == _other.compiler.combinedJsonRequests &&
352+
metadata.hash == _other.metadata.hash &&
353+
metadata.literalSources == _other.metadata.literalSources &&
354+
optimizer.enabled == _other.optimizer.enabled &&
355+
optimizer.expectedExecutionsPerDeployment == _other.optimizer.expectedExecutionsPerDeployment &&
356+
optimizer.noOptimizeYul == _other.optimizer.noOptimizeYul &&
357+
optimizer.yulSteps == _other.optimizer.yulSteps &&
358+
modelChecker.initialize == _other.modelChecker.initialize &&
359+
modelChecker.settings == _other.modelChecker.settings;
360+
}
361+
273362
bool CommandLineParser::parseInputPathsAndRemappings()
274363
{
275364
m_options.input.ignoreMissingFiles = (m_args.count(g_argIgnoreMissingFiles) > 0);
@@ -768,7 +857,7 @@ General Information)").c_str(),
768857
m_options.formatting.prettyJson = (m_args.count(g_argPrettyJson) > 0);
769858

770859
static_assert(
771-
sizeof(m_options.compiler.selectedOutputs) == 15 * sizeof(bool),
860+
sizeof(m_options.compiler.outputs) == 15 * sizeof(bool),
772861
"Remember to update code below if you add/remove fields."
773862
);
774863
m_options.compiler.outputs.astCompactJson = (m_args.count(g_argAstCompactJson) > 0);

solc/CommandLineParser.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ enum class InputMode
5151

5252
struct CompilerOutputs
5353
{
54+
bool operator!=(CompilerOutputs const& _other) const noexcept { return !(*this == _other); }
55+
bool operator==(CompilerOutputs const& _other) const noexcept;
56+
5457
bool astCompactJson = false;
5558
bool asm_ = false;
5659
bool asmJson = false;
@@ -70,6 +73,9 @@ struct CompilerOutputs
7073

7174
struct CombinedJsonRequests
7275
{
76+
bool operator!=(CombinedJsonRequests const& _other) const noexcept { return !(*this == _other); }
77+
bool operator==(CombinedJsonRequests const& _other) const noexcept;
78+
7379
bool abi = false;
7480
bool metadata = false;
7581
bool binary = false;
@@ -91,6 +97,9 @@ struct CombinedJsonRequests
9197

9298
struct CommandLineOptions
9399
{
100+
bool operator==(CommandLineOptions const& _other) const noexcept;
101+
bool operator!=(CommandLineOptions const& _other) const noexcept { return !(*this == _other); }
102+
94103
struct
95104
{
96105
InputMode mode = InputMode::Compiler;

0 commit comments

Comments
 (0)