Reject optimizer options as invalid in linker and Standard JSON modes

This commit is contained in:
Kamil Śliwak 2021-08-03 17:16:41 +02:00
parent b7c124911a
commit 7a36a1d1db
43 changed files with 52 additions and 4 deletions

View File

@ -12,11 +12,12 @@ Compiler Features:
* SMTChecker: Support low level ``call`` as external calls to unknown code.
* SMTChecker: Add constraints to better correlate ``address(this).balance`` and ``msg.value``.
* SMTChecker: Support the ``value`` option for external function calls.
* Commandline Interface: Disallowed the ``--experimental-via-ir`` option to be used with Standard Json, Assembler and Linker modes.
Bugfixes:
* Code Generator: Use stable source order for ABI functions.
* Commandline Interface: Report optimizer options as invalid in Standard JSON and linker modes instead of ignoring them.
* Commandline Interface: Disallow the ``--experimental-via-ir`` option in Standard JSON, Assembler and Linker modes.
* Opcode Optimizer: Prevent the optimizer from running multiple times to avoid potential bytecode differences for referenced code.
* Name Resolver: Fix that when importing an aliased symbol using ``import {AliasedName} from "a.sol"`` it would use the original name of the symbol and not the aliased one.
* SMTChecker: Fix false negative caused by ``push`` on storage array references returned by internal functions.

View File

@ -940,6 +940,26 @@ General Information)").c_str(),
if (!parseInputPathsAndRemappings())
return false;
if (
m_options.input.mode != InputMode::Compiler &&
m_options.input.mode != InputMode::CompilerWithASTImport &&
m_options.input.mode != InputMode::Assembler
)
{
if (!m_args[g_strOptimizeRuns].defaulted())
{
serr() << "Option --" << g_strOptimizeRuns << " is only valid in compiler and assembler modes." << endl;
return false;
}
for (string const& option: {g_strOptimize, g_strNoOptimizeYul, g_strOptimizeYul, g_strYulOptimizations})
if (m_args.count(option) > 0)
{
serr() << "Option --" << option << " is only valid in compiler and assembler modes." << endl;
return false;
}
}
if (m_options.input.mode == InputMode::StandardJson)
return true;

View File

@ -0,0 +1 @@
--no-optimize-yul --link --libraries input.sol:L=0x1234567890123456789012345678901234567890

View File

@ -0,0 +1 @@
Option --no-optimize-yul is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
--optimize --link --libraries input.sol:L=0x1234567890123456789012345678901234567890

View File

@ -0,0 +1 @@
Option --optimize is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--optimize-runs 1000 --link --libraries input.sol:L=0x1234567890123456789012345678901234567890

View File

@ -0,0 +1 @@
Option --optimize-runs is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--optimize-yul --link --libraries input.sol:L=0x1234567890123456789012345678901234567890

View File

@ -0,0 +1 @@
Option --optimize-yul is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--yul-optimizations a --link --libraries input.sol:L=0x1234567890123456789012345678901234567890

View File

@ -0,0 +1 @@
Option --yul-optimizations is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
--no-optimize-yul

View File

@ -0,0 +1 @@
Option --no-optimize-yul is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--optimize

View File

@ -0,0 +1 @@
Option --optimize is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--optimize-runs 1000

View File

@ -0,0 +1 @@
Option --optimize-runs is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--optimize-yul

View File

@ -0,0 +1 @@
Option --optimize-yul is only valid in compiler and assembler modes.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
--yul-optimizations a

View File

@ -0,0 +1 @@
Option --yul-optimizations is only valid in compiler and assembler modes.

View File

@ -368,9 +368,6 @@ BOOST_AUTO_TEST_CASE(standard_json_mode_options)
"--combined-json=abi,bin", // Accepted but has no effect in Standard JSON mode
"--metadata-hash=swarm", // Ignored in Standard JSON mode
"--metadata-literal", // Ignored in Standard JSON mode
"--optimize", // Ignored in Standard JSON mode
"--optimize-runs=1000", // Ignored in Standard JSON mode
"--yul-optimizations=agf",
"--model-checker-contracts=" // Ignored in Standard JSON mode
"contract1.yul:A,"
"contract2.yul:B",