From 8e711a8b9908ba71770869155e38f596c2f247ab Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 6 Jul 2020 18:14:51 +0200 Subject: [PATCH 01/71] Remove duplicate creation of internal routine. --- libsolidity/codegen/ArrayUtils.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index eebe03e53..409c16cd7 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -935,11 +935,6 @@ void ArrayUtils::clearStorageLoop(TypePointer _type) const } // stack: end_pos pos - // jump to and return from the loop to allow for duplicate code removal - evmasm::AssemblyItem returnTag = _context.pushNewTag(); - _context << Instruction::SWAP2 << Instruction::SWAP1; - - // stack: end_pos pos evmasm::AssemblyItem loopStart = _context.appendJumpToNew(); _context << loopStart; // check for loop condition @@ -959,11 +954,8 @@ void ArrayUtils::clearStorageLoop(TypePointer _type) const _context.appendJumpTo(loopStart); // cleanup _context << zeroLoopEnd; - _context << Instruction::POP << Instruction::SWAP1; - // "return" - _context << Instruction::JUMP; + _context << Instruction::POP; - _context << returnTag; solAssert(_context.stackHeight() == stackHeightStart - 1, ""); } ); From 38c479ffd40254752bc4fa01ecfe7986f0a79aeb Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 7 Jul 2020 15:16:21 +0200 Subject: [PATCH 02/71] Set version to 0.6.12. --- CMakeLists.txt | 2 +- Changelog.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3374ff09d..18949721e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.6.11") +set(PROJECT_VERSION "0.6.12") # OSX target needed in order to support std::visit set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) diff --git a/Changelog.md b/Changelog.md index 5c52d5e65..d427d637f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +### 0.6.12 (unreleased) + + + + ### 0.6.11 (2020-07-07) Language Features: From b23f7d879009306c294438ef47b216722d8457ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 7 Jul 2020 16:47:31 +0200 Subject: [PATCH 03/71] [yul-phaser] Temporarily disable very slow tests for the classic algorithm --- test/yulPhaser/GeneticAlgorithms.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/yulPhaser/GeneticAlgorithms.cpp b/test/yulPhaser/GeneticAlgorithms.cpp index d7ef8db57..12302bb8b 100644 --- a/test/yulPhaser/GeneticAlgorithms.cpp +++ b/test/yulPhaser/GeneticAlgorithms.cpp @@ -212,7 +212,8 @@ BOOST_FIXTURE_TEST_CASE(runNextRound_should_generate_individuals_in_the_crossove BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE(ClassicGeneticAlgorithmTest) -BOOST_FIXTURE_TEST_CASE(runNextRound_should_select_individuals_with_probability_proportional_to_fitness, ClassicGeneticAlgorithmFixture) +// FIXME: This test runs *very* slowly (tens of seconds). Investigate, fix and re-enable. +BOOST_FIXTURE_TEST_CASE(runNextRound_should_select_individuals_with_probability_proportional_to_fitness, ClassicGeneticAlgorithmFixture, *boost::unit_test::disabled()) { constexpr double relativeTolerance = 0.1; constexpr size_t populationSize = 1000; @@ -253,7 +254,8 @@ BOOST_FIXTURE_TEST_CASE(runNextRound_should_select_individuals_with_probability_ BOOST_TEST(abs(meanSquaredError(newFitness, expectedValue) - variance) < variance * relativeTolerance); } -BOOST_FIXTURE_TEST_CASE(runNextRound_should_select_only_individuals_existing_in_the_original_population, ClassicGeneticAlgorithmFixture) +// FIXME: This test runs *very* slowly (tens of seconds). Investigate, fix and re-enable. +BOOST_FIXTURE_TEST_CASE(runNextRound_should_select_only_individuals_existing_in_the_original_population, ClassicGeneticAlgorithmFixture, *boost::unit_test::disabled()) { constexpr size_t populationSize = 1000; auto population = Population::makeRandom(m_fitnessMetric, populationSize, 1, 10); @@ -297,7 +299,8 @@ BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_crossover, ClassicGeneticAlgorith BOOST_TEST(totalCrossed >= 2); } -BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_mutation, ClassicGeneticAlgorithmFixture) +// FIXME: This test runs *very* slowly (tens of seconds). Investigate, fix and re-enable. +BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_mutation, ClassicGeneticAlgorithmFixture, *boost::unit_test::disabled()) { m_options.mutationChance = 0.6; ClassicGeneticAlgorithm algorithm(m_options); @@ -326,7 +329,8 @@ BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_mutation, ClassicGeneticAlgorithm BOOST_TEST(abs(meanSquaredError(bernoulliTrials, expectedValue) - variance) < variance * relativeTolerance); } -BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_deletion, ClassicGeneticAlgorithmFixture) +// FIXME: This test runs *very* slowly (tens of seconds). Investigate, fix and re-enable. +BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_deletion, ClassicGeneticAlgorithmFixture, *boost::unit_test::disabled()) { m_options.deletionChance = 0.6; ClassicGeneticAlgorithm algorithm(m_options); @@ -355,7 +359,8 @@ BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_deletion, ClassicGeneticAlgorithm BOOST_TEST(abs(meanSquaredError(bernoulliTrials, expectedValue) - variance) < variance * relativeTolerance); } -BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_addition, ClassicGeneticAlgorithmFixture) +// FIXME: This test runs *very* slowly (tens of seconds). Investigate, fix and re-enable. +BOOST_FIXTURE_TEST_CASE(runNextRound_should_do_addition, ClassicGeneticAlgorithmFixture, *boost::unit_test::disabled()) { m_options.additionChance = 0.6; ClassicGeneticAlgorithm algorithm(m_options); From 5ebf2b84ef6127b273df9a1e898759155a89906c Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Jul 2020 09:33:30 +0200 Subject: [PATCH 04/71] Improve testing speed by only enabling the Yul optimizer if needed. --- .../SolidityExecutionFramework.cpp | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index 29b3b8b43..2d0ae44da 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -61,18 +61,40 @@ bytes SolidityExecutionFramework::multiSourceCompileContract( evmasm::LinkerObject obj; if (m_compileViaYul) { - yul::AssemblyStack asmStack( - m_evmVersion, - yul::AssemblyStack::Language::StrictAssembly, - // Ignore optimiser settings here because we need Yul optimisation to - // get code that does not exhaust the stack. - OptimiserSettings::full() - ); - bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName)); - solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors"); + // Try compiling twice: If the first run fails due to stack errors, forcefully enable + // the optimizer. + for (bool forceEnableOptimizer: {false, true}) + { + OptimiserSettings optimiserSettings = m_optimiserSettings; + if (!forceEnableOptimizer && !optimiserSettings.runYulOptimiser) + { + // Enable some optimizations on the first run + optimiserSettings.runYulOptimiser = true; + optimiserSettings.yulOptimiserSteps = "uljmul jmul"; + } + else if (forceEnableOptimizer) + optimiserSettings = OptimiserSettings::full(); - asmStack.optimize(); - obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode); + yul::AssemblyStack asmStack( + m_evmVersion, + yul::AssemblyStack::Language::StrictAssembly, + optimiserSettings + ); + bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName)); + solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors"); + + try + { + asmStack.optimize(); + obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode); + break; + } + catch (...) + { + if (forceEnableOptimizer || optimiserSettings == OptimiserSettings::full()) + throw; + } + } } else obj = m_compiler.object(contractName); From f9d6fa71fd6b72d86c54a62f5cd79c71794ed07d Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 7 Jul 2020 19:03:25 +0200 Subject: [PATCH 05/71] Add create & delete array tests for yul --- .../array/create_memory_array.sol | 3 +- .../array/delete_memory_array.sol | 17 ++++++++ .../array/delete_storage_array.sol | 40 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/semanticTests/array/delete_memory_array.sol create mode 100644 test/libsolidity/semanticTests/array/delete_storage_array.sol diff --git a/test/libsolidity/semanticTests/array/create_memory_array.sol b/test/libsolidity/semanticTests/array/create_memory_array.sol index fd4fe943c..cf00ccaa6 100644 --- a/test/libsolidity/semanticTests/array/create_memory_array.sol +++ b/test/libsolidity/semanticTests/array/create_memory_array.sol @@ -16,6 +16,7 @@ contract C { return (x[199], y[203][1], z[170].a[1], z[170].b[99]); } } - +// ==== +// compileViaYul: also // ---- // f() -> "A", 8, 4, "B" diff --git a/test/libsolidity/semanticTests/array/delete_memory_array.sol b/test/libsolidity/semanticTests/array/delete_memory_array.sol new file mode 100644 index 000000000..64fc9a972 --- /dev/null +++ b/test/libsolidity/semanticTests/array/delete_memory_array.sol @@ -0,0 +1,17 @@ +contract C { + + function len() public returns (uint ret) { + uint[] memory data = new uint[](2); + data[0] = 234; + data[1] = 123; + delete data; + assembly { + ret := mload(data) + } + } +} + +// ==== +// compileViaYul: also +// ---- +// len() -> 0 diff --git a/test/libsolidity/semanticTests/array/delete_storage_array.sol b/test/libsolidity/semanticTests/array/delete_storage_array.sol new file mode 100644 index 000000000..f0bb76978 --- /dev/null +++ b/test/libsolidity/semanticTests/array/delete_storage_array.sol @@ -0,0 +1,40 @@ +contract C { + uint[] data; + + function len() public returns (uint ret) { + data.push(234); + data.push(123); + delete data; + assembly { + ret := sload(data_slot) + } + } + + function val() public returns (uint ret) { + assembly { + sstore(0, 2) + mstore(0, 0) + sstore(keccak256(0, 32), 234) + sstore(add(keccak256(0, 32), 1), 123) + } + + assert(data[0] == 234); + assert(data[1] == 123); + + delete data; + + uint size = 999; + + assembly { + size := sload(0) + mstore(0, 0) + ret := sload(keccak256(0, 32)) + } + } +} + +// ==== +// compileViaYul: also +// ---- +// len() -> 0 +// val() -> 0 From 48ac4b295495c81649a980c9807a5d7a2243241d Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Mon, 6 Jul 2020 14:09:06 +0200 Subject: [PATCH 06/71] Disable more than one reference to a variable on the LHS of a tuple assignment --- test/tools/ossfuzz/protoToYul.cpp | 54 +++++++++++++++++++++++-------- test/tools/ossfuzz/protoToYul.h | 2 ++ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 8d5ced0a8..73462356b 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -178,6 +178,14 @@ bool ProtoConverter::functionCallNotPossible(FunctionCall_Returns _type) (_type == FunctionCall::MULTIASSIGN && !varDeclAvailable()); } +unsigned ProtoConverter::numVarsInScope() +{ + if (m_inFunctionDef) + return m_currentFuncVars.size(); + else + return m_currentGlobalVars.size(); +} + void ProtoConverter::visit(VarRef const& _x) { if (m_inFunctionDef) @@ -830,18 +838,18 @@ void ProtoConverter::visitFunctionInputParams(FunctionCall const& _x, unsigned _ case 4: visit(_x.in_param4()); m_output << ", "; - BOOST_FALLTHROUGH; + [[fallthrough]]; case 3: visit(_x.in_param3()); m_output << ", "; - BOOST_FALLTHROUGH; + [[fallthrough]]; case 2: visit(_x.in_param2()); m_output << ", "; - BOOST_FALLTHROUGH; + [[fallthrough]]; case 1: visit(_x.in_param1()); - BOOST_FALLTHROUGH; + [[fallthrough]]; case 0: break; default: @@ -966,23 +974,43 @@ void ProtoConverter::visit(FunctionCall const& _x) "Proto fuzzer: Function call with too many output params encountered." ); + // Return early if numOutParams > number of available variables + if (numOutParams > numVarsInScope()) + return; + + // Copy variables in scope in order to prevent repeated references + vector variables; + if (m_inFunctionDef) + for (auto var: m_currentFuncVars) + variables.push_back(*var); + else + for (auto var: m_currentGlobalVars) + variables.push_back(*var); + + auto refVar = [](vector& _var, unsigned _rand, bool _comma = true) -> string + { + auto index = _rand % _var.size(); + string ref = _var[index]; + _var.erase(_var.begin() + index); + if (_comma) + ref += ", "; + return ref; + }; + // Convert LHS of multi assignment // We reverse the order of out param visits since the order does not matter. // This helps reduce the size of this switch statement. switch (numOutParams) { case 4: - visit(_x.out_param4()); - m_output << ", "; - BOOST_FALLTHROUGH; + m_output << refVar(variables, _x.out_param4().varnum()); + [[fallthrough]]; case 3: - visit(_x.out_param3()); - m_output << ", "; - BOOST_FALLTHROUGH; + m_output << refVar(variables, _x.out_param3().varnum()); + [[fallthrough]]; case 2: - visit(_x.out_param2()); - m_output << ", "; - visit(_x.out_param1()); + m_output << refVar(variables, _x.out_param2().varnum()); + m_output << refVar(variables, _x.out_param1().varnum(), false); break; default: yulAssert(false, "Proto fuzzer: Function call with too many or too few input parameters."); diff --git a/test/tools/ossfuzz/protoToYul.h b/test/tools/ossfuzz/protoToYul.h index 9f7240f5e..950dd97a9 100644 --- a/test/tools/ossfuzz/protoToYul.h +++ b/test/tools/ossfuzz/protoToYul.h @@ -120,6 +120,8 @@ private: void closeFunctionScope(); /// Adds @a _vars to current scope void addVarsToScope(std::vector const& _vars); + /// @returns number of variables that are in scope + unsigned numVarsInScope(); std::string createHex(std::string const& _hexBytes); From 0a0f578d7c11dfd1878eeaa3ffee2d240b9eb951 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 7 Jul 2020 15:10:21 +0200 Subject: [PATCH 07/71] Evaluate keccak256 of string literals at compile-time. --- Changelog.md | 2 ++ libsolidity/codegen/ExpressionCompiler.cpp | 12 ++++--- .../codegen/ir/IRGeneratorForStatements.cpp | 32 ++++++++++++------- .../specialFunctions/keccak256_optimized.sol | 19 +++++++++++ 4 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol diff --git a/Changelog.md b/Changelog.md index d427d637f..e6e49a3c6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ ### 0.6.12 (unreleased) +Compiler Features: + * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index ffa8ced4c..694ea8fa6 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -792,20 +792,24 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) TypePointer const& argType = arguments.front()->annotation().type; solAssert(argType, ""); arguments.front()->accept(*this); - // Optimization: If type is bytes or string, then do not encode, - // but directly compute keccak256 on memory. - if (*argType == *TypeProvider::bytesMemory() || *argType == *TypeProvider::stringMemory()) + if (auto const* stringLiteral = dynamic_cast(argType)) + // Optimization: Compute keccak256 on string literals at compile-time. + m_context << u256(keccak256(stringLiteral->value())); + else if (*argType == *TypeProvider::bytesMemory() || *argType == *TypeProvider::stringMemory()) { + // Optimization: If type is bytes or string, then do not encode, + // but directly compute keccak256 on memory. ArrayUtils(m_context).retrieveLength(*TypeProvider::bytesMemory()); m_context << Instruction::SWAP1 << u256(0x20) << Instruction::ADD; + m_context << Instruction::KECCAK256; } else { utils().fetchFreeMemoryPointer(); utils().packedEncode({argType}, TypePointers()); utils().toSizeAfterFreeMemoryPointer(); + m_context << Instruction::KECCAK256; } - m_context << Instruction::KECCAK256; break; } case FunctionType::Kind::Log0: diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index c14d65121..a8d657b02 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1020,18 +1020,28 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) ArrayType const* arrayType = TypeProvider::bytesMemory(); - auto array = convert(*arguments[0], *arrayType); + if (auto const* stringLiteral = dynamic_cast(arguments.front()->annotation().type)) + { + // Optimization: Compute keccak256 on string literals at compile-time. + define(_functionCall) << + ("0x" + keccak256(stringLiteral->value()).hex()) << + "\n"; + } + else + { + auto array = convert(*arguments[0], *arrayType); - define(_functionCall) << - "keccak256(" << - m_utils.arrayDataAreaFunction(*arrayType) << - "(" << - array.commaSeparatedList() << - "), " << - m_utils.arrayLengthFunction(*arrayType) << - "(" << - array.commaSeparatedList() << - "))\n"; + define(_functionCall) << + "keccak256(" << + m_utils.arrayDataAreaFunction(*arrayType) << + "(" << + array.commaSeparatedList() << + "), " << + m_utils.arrayLengthFunction(*arrayType) << + "(" << + array.commaSeparatedList() << + "))\n"; + } break; } case FunctionType::Kind::ArrayPop: diff --git a/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol b/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol new file mode 100644 index 000000000..cb3c8d608 --- /dev/null +++ b/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol @@ -0,0 +1,19 @@ +// tests compile-time evaluation of keccak256 on literal strings +contract C { + function short() public pure returns (bool) { + bytes32 a = keccak256("abcdefghijklmn"); + bytes memory s = "abcdefghijklmn"; + return a == keccak256(s); + } + bytes32 constant sc = keccak256("abcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmn"); + function long() public pure returns (bool, bool) { + bytes32 a = keccak256("abcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmn"); + bytes memory s = "abcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmn"; + return (a == keccak256(s), sc == keccak256(s)); + } +} +// ==== +// compileViaYul: also +// ---- +// short() -> true +// long() -> true, true From 83337c850eab317b8d3dcd6b3b54f3b66e48195d Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Jul 2020 17:56:14 +0200 Subject: [PATCH 08/71] Do not run tests that do not need options multiple times. --- .circleci/soltest.sh | 2 +- .circleci/soltest_all.sh | 2 +- test/libsolutil/IpfsHash.cpp | 2 +- test/libsolutil/IterateReplacing.cpp | 2 +- test/libsolutil/JSON.cpp | 2 +- test/libsolutil/Keccak256.cpp | 2 +- test/libsolutil/LazyInit.cpp | 2 +- test/libsolutil/StringUtils.cpp | 2 +- test/libsolutil/SwarmHash.cpp | 2 +- test/libsolutil/UTF8.cpp | 2 +- test/libsolutil/Whiskers.cpp | 2 +- test/libyul/StackReuseCodegen.cpp | 2 +- test/yulPhaser/AlgorithmRunner.cpp | 2 +- test/yulPhaser/Chromosome.cpp | 2 +- test/yulPhaser/Common.cpp | 2 +- test/yulPhaser/FitnessMetrics.cpp | 2 +- test/yulPhaser/GeneticAlgorithms.cpp | 2 +- test/yulPhaser/Mutations.cpp | 2 +- test/yulPhaser/PairSelections.cpp | 2 +- test/yulPhaser/Phaser.cpp | 2 +- test/yulPhaser/Population.cpp | 2 +- test/yulPhaser/Program.cpp | 2 +- test/yulPhaser/ProgramCache.cpp | 2 +- test/yulPhaser/Selections.cpp | 2 +- test/yulPhaser/SimulationRNG.cpp | 2 +- test/yulPhaser/TestHelpersTest.cpp | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.circleci/soltest.sh b/.circleci/soltest.sh index f55239e60..41ab71875 100755 --- a/.circleci/soltest.sh +++ b/.circleci/soltest.sh @@ -54,7 +54,7 @@ get_logfile_basename() { echo -ne "${filename}" } -BOOST_TEST_ARGS="--color_output=no --show_progress=yes --logger=JUNIT,error,test_results/`get_logfile_basename`.xml" +BOOST_TEST_ARGS="--color_output=no --show_progress=yes --logger=JUNIT,error,test_results/`get_logfile_basename`.xml ${BOOST_TEST_ARGS}" SOLTEST_ARGS="--evm-version=$EVM $SOLTEST_FLAGS" test "${OPTIMIZE}" = "1" && SOLTEST_ARGS="${SOLTEST_ARGS} --optimize" test "${ABI_ENCODER_V2}" = "1" && SOLTEST_ARGS="${SOLTEST_ARGS} --abiencoderv2" diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 74b3f1197..94a89704a 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -30,7 +30,7 @@ REPODIR="$(realpath $(dirname $0)/..)" for OPTIMIZE in 0 1; do for EVM in homestead byzantium constantinople petersburg istanbul; do - EVM=$EVM OPTIMIZE=$OPTIMIZE ${REPODIR}/.circleci/soltest.sh + EVM=$EVM OPTIMIZE=$OPTIMIZE BOOST_TEST_ARGS="-t !@nooptions" ${REPODIR}/.circleci/soltest.sh done done diff --git a/test/libsolutil/IpfsHash.cpp b/test/libsolutil/IpfsHash.cpp index 9d6f0f8fc..40385d43f 100644 --- a/test/libsolutil/IpfsHash.cpp +++ b/test/libsolutil/IpfsHash.cpp @@ -29,7 +29,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(IpfsHash) +BOOST_AUTO_TEST_SUITE(IpfsHash, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(test_small) { diff --git a/test/libsolutil/IterateReplacing.cpp b/test/libsolutil/IterateReplacing.cpp index d1598dbc3..e28091c76 100644 --- a/test/libsolutil/IterateReplacing.cpp +++ b/test/libsolutil/IterateReplacing.cpp @@ -29,7 +29,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(IterateReplacing) +BOOST_AUTO_TEST_SUITE(IterateReplacing, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(no_replacement) { diff --git a/test/libsolutil/JSON.cpp b/test/libsolutil/JSON.cpp index e45c6fdec..d0e86c3c7 100644 --- a/test/libsolutil/JSON.cpp +++ b/test/libsolutil/JSON.cpp @@ -30,7 +30,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(JsonTest) +BOOST_AUTO_TEST_SUITE(JsonTest, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(json_pretty_print) { diff --git a/test/libsolutil/Keccak256.cpp b/test/libsolutil/Keccak256.cpp index 4bb3bddd6..bad8510c5 100644 --- a/test/libsolutil/Keccak256.cpp +++ b/test/libsolutil/Keccak256.cpp @@ -26,7 +26,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(Keccak256) +BOOST_AUTO_TEST_SUITE(Keccak256, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(empty) { diff --git a/test/libsolutil/LazyInit.cpp b/test/libsolutil/LazyInit.cpp index 346805c82..ec170946d 100644 --- a/test/libsolutil/LazyInit.cpp +++ b/test/libsolutil/LazyInit.cpp @@ -59,7 +59,7 @@ T valueOf(LazyInit _lazyInit) } -BOOST_AUTO_TEST_SUITE(LazyInitTests) +BOOST_AUTO_TEST_SUITE(LazyInitTests, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(default_constructed_is_empty) { diff --git a/test/libsolutil/StringUtils.cpp b/test/libsolutil/StringUtils.cpp index e50260e88..a9c03acd9 100644 --- a/test/libsolutil/StringUtils.cpp +++ b/test/libsolutil/StringUtils.cpp @@ -33,7 +33,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(StringUtils) +BOOST_AUTO_TEST_SUITE(StringUtils, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(test_similarity) { diff --git a/test/libsolutil/SwarmHash.cpp b/test/libsolutil/SwarmHash.cpp index a976bfccf..cacb04adf 100644 --- a/test/libsolutil/SwarmHash.cpp +++ b/test/libsolutil/SwarmHash.cpp @@ -31,7 +31,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(SwarmHash) +BOOST_AUTO_TEST_SUITE(SwarmHash, *boost::unit_test::label("nooptions")) string bzzr0HashHex(string const& _input) { diff --git a/test/libsolutil/UTF8.cpp b/test/libsolutil/UTF8.cpp index b3e969b9b..94ec6c6d7 100644 --- a/test/libsolutil/UTF8.cpp +++ b/test/libsolutil/UTF8.cpp @@ -30,7 +30,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(UTF8) +BOOST_AUTO_TEST_SUITE(UTF8, *boost::unit_test::label("nooptions")) namespace { diff --git a/test/libsolutil/Whiskers.cpp b/test/libsolutil/Whiskers.cpp index 093b0acb6..3ed87acb9 100644 --- a/test/libsolutil/Whiskers.cpp +++ b/test/libsolutil/Whiskers.cpp @@ -29,7 +29,7 @@ using namespace std; namespace solidity::util::test { -BOOST_AUTO_TEST_SUITE(WhiskersTest) +BOOST_AUTO_TEST_SUITE(WhiskersTest, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(no_templates) { diff --git a/test/libyul/StackReuseCodegen.cpp b/test/libyul/StackReuseCodegen.cpp index 5103befb0..eec882e8c 100644 --- a/test/libyul/StackReuseCodegen.cpp +++ b/test/libyul/StackReuseCodegen.cpp @@ -43,7 +43,7 @@ string assemble(string const& _input) } } -BOOST_AUTO_TEST_SUITE(StackReuseCodegen) +BOOST_AUTO_TEST_SUITE(StackReuseCodegen, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/yulPhaser/AlgorithmRunner.cpp b/test/yulPhaser/AlgorithmRunner.cpp index 042cd4c2b..0cd731aef 100644 --- a/test/yulPhaser/AlgorithmRunner.cpp +++ b/test/yulPhaser/AlgorithmRunner.cpp @@ -121,7 +121,7 @@ protected: RandomisingAlgorithm m_algorithm; }; -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(AlgorithmRunnerTest) BOOST_FIXTURE_TEST_CASE(run_should_call_runNextRound_once_per_round, AlgorithmRunnerFixture) diff --git a/test/yulPhaser/Chromosome.cpp b/test/yulPhaser/Chromosome.cpp index 442f7967f..94b95d82c 100644 --- a/test/yulPhaser/Chromosome.cpp +++ b/test/yulPhaser/Chromosome.cpp @@ -46,7 +46,7 @@ using namespace solidity::util; namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(ChromosomeTest) BOOST_AUTO_TEST_CASE(constructor_should_convert_from_string_to_optimisation_steps) diff --git a/test/yulPhaser/Common.cpp b/test/yulPhaser/Common.cpp index 39e6dd784..b24143a94 100644 --- a/test/yulPhaser/Common.cpp +++ b/test/yulPhaser/Common.cpp @@ -66,7 +66,7 @@ map const StringToTestEnumMap = invertMap(TestEnumToStringMap) } -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(CommonTest) BOOST_FIXTURE_TEST_CASE(readLinesFromFile_should_return_all_lines_from_a_text_file_as_strings_without_newlines, ReadLinesFromFileFixture) diff --git a/test/yulPhaser/FitnessMetrics.cpp b/test/yulPhaser/FitnessMetrics.cpp index e668b54e9..73a92fb40 100644 --- a/test/yulPhaser/FitnessMetrics.cpp +++ b/test/yulPhaser/FitnessMetrics.cpp @@ -95,7 +95,7 @@ protected: }; }; -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(FitnessMetricsTest) BOOST_AUTO_TEST_SUITE(ProgramBasedMetricTest) diff --git a/test/yulPhaser/GeneticAlgorithms.cpp b/test/yulPhaser/GeneticAlgorithms.cpp index 12302bb8b..473a6c009 100644 --- a/test/yulPhaser/GeneticAlgorithms.cpp +++ b/test/yulPhaser/GeneticAlgorithms.cpp @@ -56,7 +56,7 @@ protected: }; }; -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(GeneticAlgorithmsTest) BOOST_AUTO_TEST_SUITE(RandomAlgorithmTest) diff --git a/test/yulPhaser/Mutations.cpp b/test/yulPhaser/Mutations.cpp index b20cb8e4c..aae16cced 100644 --- a/test/yulPhaser/Mutations.cpp +++ b/test/yulPhaser/Mutations.cpp @@ -33,7 +33,7 @@ using namespace solidity::util; namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(MutationsTest) BOOST_AUTO_TEST_SUITE(GeneRandomisationTest) diff --git a/test/yulPhaser/PairSelections.cpp b/test/yulPhaser/PairSelections.cpp index 62a4dd4bc..a63704cf5 100644 --- a/test/yulPhaser/PairSelections.cpp +++ b/test/yulPhaser/PairSelections.cpp @@ -31,7 +31,7 @@ using namespace std; namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(PairSelectionsTest) BOOST_AUTO_TEST_SUITE(RandomPairSelectionTest) diff --git a/test/yulPhaser/Phaser.cpp b/test/yulPhaser/Phaser.cpp index 5cef03778..f1e0fd96a 100644 --- a/test/yulPhaser/Phaser.cpp +++ b/test/yulPhaser/Phaser.cpp @@ -103,7 +103,7 @@ protected: }; }; -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(PhaserTest) BOOST_AUTO_TEST_SUITE(GeneticAlgorithmFactoryTest) diff --git a/test/yulPhaser/Population.cpp b/test/yulPhaser/Population.cpp index 5fd8c2073..fb6d45940 100644 --- a/test/yulPhaser/Population.cpp +++ b/test/yulPhaser/Population.cpp @@ -59,7 +59,7 @@ protected: shared_ptr m_fitnessMetric = make_shared(); }; -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(PopulationTest) BOOST_AUTO_TEST_CASE(isFitter_should_use_fitness_as_the_main_criterion) diff --git a/test/yulPhaser/Program.cpp b/test/yulPhaser/Program.cpp index 0a7520dd7..d951c4e4e 100644 --- a/test/yulPhaser/Program.cpp +++ b/test/yulPhaser/Program.cpp @@ -57,7 +57,7 @@ namespace namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(ProgramTest) BOOST_AUTO_TEST_CASE(copy_constructor_should_make_deep_copy_of_ast) diff --git a/test/yulPhaser/ProgramCache.cpp b/test/yulPhaser/ProgramCache.cpp index 3b652e3fb..da4b7c18c 100644 --- a/test/yulPhaser/ProgramCache.cpp +++ b/test/yulPhaser/ProgramCache.cpp @@ -70,7 +70,7 @@ protected: ProgramCache m_programCache{m_program}; }; -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(ProgramCacheTest) BOOST_AUTO_TEST_CASE(CacheStats_operator_plus_should_add_stats_together) diff --git a/test/yulPhaser/Selections.cpp b/test/yulPhaser/Selections.cpp index d25766ae6..7fdea6192 100644 --- a/test/yulPhaser/Selections.cpp +++ b/test/yulPhaser/Selections.cpp @@ -34,7 +34,7 @@ using namespace solidity::util; namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(SelectionsTest) BOOST_AUTO_TEST_SUITE(RangeSelectionTest) diff --git a/test/yulPhaser/SimulationRNG.cpp b/test/yulPhaser/SimulationRNG.cpp index 0cdacc428..306074b3c 100644 --- a/test/yulPhaser/SimulationRNG.cpp +++ b/test/yulPhaser/SimulationRNG.cpp @@ -28,7 +28,7 @@ using namespace std; namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(RandomTest) BOOST_AUTO_TEST_CASE(bernoulliTrial_should_produce_samples_with_right_expected_value_and_variance) diff --git a/test/yulPhaser/TestHelpersTest.cpp b/test/yulPhaser/TestHelpersTest.cpp index 7fc4ef0af..09b722517 100644 --- a/test/yulPhaser/TestHelpersTest.cpp +++ b/test/yulPhaser/TestHelpersTest.cpp @@ -34,7 +34,7 @@ namespace fs = boost::filesystem; namespace solidity::phaser::test { -BOOST_AUTO_TEST_SUITE(Phaser) +BOOST_AUTO_TEST_SUITE(Phaser, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_SUITE(TestHelpersTest) BOOST_AUTO_TEST_CASE(ChromosomeLengthMetric_evaluate_should_return_chromosome_length) From d4ecd332477d9ff0ab5ad1d27241d72a8d0b7f90 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 7 Jul 2020 11:30:15 +0200 Subject: [PATCH 09/71] Propagate function call argument types across function call options. --- Changelog.md | 2 ++ libsolidity/analysis/TypeChecker.cpp | 2 ++ .../functionCall/call_options_overload.sol | 14 ++++++++++++++ .../functionCalls/call_options_overload.sol | 9 --------- 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 test/libsolidity/semanticTests/functionCall/call_options_overload.sol delete mode 100644 test/libsolidity/syntaxTests/functionCalls/call_options_overload.sol diff --git a/Changelog.md b/Changelog.md index e6e49a3c6..9795ecb51 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,8 @@ Compiler Features: * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. +Bugfixes: + * Type Checker: Fix overload resolution in combination with ``{value: ...}``. ### 0.6.11 (2020-07-07) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 5c49bf1dc..6bb9dd39f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2354,6 +2354,8 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) { solAssert(_functionCallOptions.options().size() == _functionCallOptions.names().size(), "Lengths of name & value arrays differ!"); + _functionCallOptions.expression().annotation().arguments = _functionCallOptions.annotation().arguments; + _functionCallOptions.expression().accept(*this); auto expressionFunctionType = dynamic_cast(type(_functionCallOptions.expression())); diff --git a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol new file mode 100644 index 000000000..27e8e4127 --- /dev/null +++ b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol @@ -0,0 +1,14 @@ +contract C { + function f(uint x) external payable returns (uint) { return 1; } + function f(uint x, uint y) external payable returns (uint) { return 2; } + function call() public payable returns (uint v, uint x, uint y, uint z) { + v = this.f{value: 10}(2); + x = this.f{gas: 1000}(2, 3); + y = this.f{gas: 1000, value: 10}(2, 3); + z = this.f{gas: 1000}{value: 10}(2, 3); + } + receive() external payable {} +} +// ---- +// (), 1 ether +// call() -> 1, 2, 2, 2 diff --git a/test/libsolidity/syntaxTests/functionCalls/call_options_overload.sol b/test/libsolidity/syntaxTests/functionCalls/call_options_overload.sol deleted file mode 100644 index 11021f7d7..000000000 --- a/test/libsolidity/syntaxTests/functionCalls/call_options_overload.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - function f(uint x) external payable { } - function f(uint x, uint y) external payable { } - function call() internal { - this.f{value: 10}(2); - } -} -// ---- -// TypeError 6675: (148-154): Member "f" not unique after argument-dependent lookup in contract C. From d3abbd5610824ad82337d9926655da02d45063ea Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Jul 2020 20:13:11 +0200 Subject: [PATCH 10/71] Remove unneccessary masking of tags. --- Changelog.md | 1 + libevmasm/PeepholeOptimiser.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 9795ecb51..ca81e04d8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ Compiler Features: * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. + * Peephole Optimizer: Remove unnecessary masking of tags. Bugfixes: * Type Checker: Fix overload resolution in combination with ``{value: ...}``. diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp index 861cae0f2..dd5f9399c 100644 --- a/libevmasm/PeepholeOptimiser.cpp +++ b/libevmasm/PeepholeOptimiser.cpp @@ -266,9 +266,10 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod std::back_insert_iterator _out ) { + if (_and != Instruction::AND) + return false; if ( _pushTag.type() == PushTag && - _and == Instruction::AND && _pushConstant.type() == Push && (_pushConstant.data() & u256(0xFFFFFFFF)) == u256(0xFFFFFFFF) ) @@ -276,6 +277,16 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod *_out = _pushTag; return true; } + else if ( + // tag and constant are swapped + _pushConstant.type() == PushTag && + _pushTag.type() == Push && + (_pushTag.data() & u256(0xFFFFFFFF)) == u256(0xFFFFFFFF) + ) + { + *_out = _pushConstant; + return true; + } else return false; } From 59f4989966ead898cc2a048a73361d6c996a8320 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 4 Jun 2020 11:11:53 +0200 Subject: [PATCH 11/71] Optimize combination of byte and shl. --- .gitignore | 2 +- Changelog.md | 3 ++ libevmasm/RuleList.h | 14 ++++++ test/formal/combine_byte_shl.py | 29 ++++++++++++ test/formal/combine_byte_shr_1.py | 30 +++++++++++++ test/formal/combine_byte_shr_2.py | 30 +++++++++++++ test/formal/opcodes.py | 4 ++ .../semanticTests/optimizer/shift_bytes.sol | 44 +++++++++++++++++++ 8 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 test/formal/combine_byte_shl.py create mode 100644 test/formal/combine_byte_shr_1.py create mode 100644 test/formal/combine_byte_shr_2.py create mode 100644 test/libsolidity/semanticTests/optimizer/shift_bytes.sol diff --git a/.gitignore b/.gitignore index f6eeba75f..67e450759 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ build/ build*/ emscripten_build/ docs/_build -docs/utils/__pycache__ +__pycache__ docs/utils/*.pyc /deps/downloads/ deps/install diff --git a/Changelog.md b/Changelog.md index 9795ecb51..7b0a87a9a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,9 @@ Compiler Features: Bugfixes: * Type Checker: Fix overload resolution in combination with ``{value: ...}``. +Compiler Features: + * Optimizer: Add rule to remove shifts inside the byte opcode. + ### 0.6.11 (2020-07-07) diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index e29141b49..9442524b1 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -571,6 +571,20 @@ std::vector> simplificationRuleListPart7( feasibilityFunction }); + rules.push_back({ + Builtins::BYTE(A, Builtins::SHL(B, X)), + [=]() -> Pattern { return Builtins::BYTE(A.d() + B.d() / 8, X); }, + false, + [=] { return B.d() % 8 == 0 && A.d() <= 32 && B.d() <= 256; } + }); + + rules.push_back({ + Builtins::BYTE(A, Builtins::SHR(B, X)), + [=]() -> Pattern { return A.d() < B.d() / 8 ? Word(0) : Builtins::BYTE(A.d() - B.d() / 8, X); }, + false, + [=] { return B.d() % 8 == 0 && A.d() < Pattern::WordSize / 8 && B.d() <= Pattern::WordSize; } + }); + return rules; } diff --git a/test/formal/combine_byte_shl.py b/test/formal/combine_byte_shl.py new file mode 100644 index 000000000..e2a6034ff --- /dev/null +++ b/test/formal/combine_byte_shl.py @@ -0,0 +1,29 @@ +from rule import Rule +from opcodes import * + +""" +byte(A, shl(B, X)) +given B % 8 == 0 && A <= 32 && B <= 256 +-> +byte(A + B / 8, X) +""" + +rule = Rule() + +n_bits = 256 + +# Input vars +X = BitVec('X', n_bits) +A = BitVec('A', n_bits) +B = BitVec('B', n_bits) + +# Non optimized result +nonopt = BYTE(A, SHL(B, X)) +# Optimized result +opt = BYTE(A + B / 8, X) + +rule.require(B % 8 == 0) +rule.require(ULE(A, 32)) +rule.require(ULE(B, 256)) + +rule.check(nonopt, opt) diff --git a/test/formal/combine_byte_shr_1.py b/test/formal/combine_byte_shr_1.py new file mode 100644 index 000000000..4938e73f7 --- /dev/null +++ b/test/formal/combine_byte_shr_1.py @@ -0,0 +1,30 @@ +from rule import Rule +from opcodes import * + +""" +byte(A, shr(B, X)) +given B % 8 == 0 && A < n_bits/8 && B <= n_bits && A >= B / 8 +-> +byte(A - B / 8, X) +""" + +rule = Rule() + +n_bits = 256 + +# Input vars +X = BitVec('X', n_bits) +A = BitVec('A', n_bits) +B = BitVec('B', n_bits) + +# Non optimized result +nonopt = BYTE(A, SHR(B, X)) +# Optimized result +opt = BYTE(A - B / 8, X) + +rule.require(B % 8 == 0) +rule.require(ULT(A, n_bits/8)) +rule.require(ULE(B, n_bits)) +rule.require(UGE(A, DIV(B,8))) + +rule.check(nonopt, opt) diff --git a/test/formal/combine_byte_shr_2.py b/test/formal/combine_byte_shr_2.py new file mode 100644 index 000000000..d74114e85 --- /dev/null +++ b/test/formal/combine_byte_shr_2.py @@ -0,0 +1,30 @@ +from rule import Rule +from opcodes import * + +""" +byte(A, shr(B, X)) +given B % 8 == 0 && A < n_bits/8 && B <= n_bits && A < B / 8 +-> +0 +""" + +rule = Rule() + +n_bits = 256 + +# Input vars +X = BitVec('X', n_bits) +A = BitVec('A', n_bits) +B = BitVec('B', n_bits) + +# Non optimized result +nonopt = BYTE(A, SHR(B, X)) +# Optimized result +opt = 0 + +rule.require(B % 8 == 0) +rule.require(ULT(A, n_bits/8)) +rule.require(ULE(B, n_bits)) +rule.require(ULT(A, DIV(B,8))) + +rule.check(nonopt, opt) diff --git a/test/formal/opcodes.py b/test/formal/opcodes.py index 589bd9520..24d53484b 100644 --- a/test/formal/opcodes.py +++ b/test/formal/opcodes.py @@ -56,3 +56,7 @@ def SHR(x, y): def SAR(x, y): return y >> x + +def BYTE(i, x): + bit = (i + 1) * 8 + return If(UGT(bit, x.size()), BitVecVal(0, x.size()), (LShR(x, (x.size() - bit))) & 0xff) diff --git a/test/libsolidity/semanticTests/optimizer/shift_bytes.sol b/test/libsolidity/semanticTests/optimizer/shift_bytes.sol new file mode 100644 index 000000000..5a85160f9 --- /dev/null +++ b/test/libsolidity/semanticTests/optimizer/shift_bytes.sol @@ -0,0 +1,44 @@ +// This tests the optimizer rule +// byte(A, shl(B, X)) +// -> +// byte(A + B / 8, X) +// given A <= 32 && B % 8 == 0 && B <= 256 +// +// and the respective rule about shr +contract C { + function f(uint a) public returns (uint, uint, uint) { + uint x = a << (256 - 8); + assembly { + x := byte(0, x) + } + uint y = a << 8; + assembly { + y := byte(30, y) + } + uint z = a << 16; + assembly { + z := byte(1, z) + } + return (x, y, z); + } + function g(uint a) public returns (uint, uint, uint) { + uint x = a >> (256 - 16); + assembly { + x := byte(31, x) + } + uint y = a >> 8; + assembly { + y := byte(4, y) + } + uint z = a >> 16; + assembly { + z := byte(7, z) + } + return (x, y, z); + } +} +// ==== +// compileViaYul: also +// ---- +// f(uint256): 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f -> 0x1f, 0x1f, 3 +// g(uint256): 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f -> 1, 3, 5 From fe5bcf759e607f6685ad0822fb877864b000d2a1 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 8 Jul 2020 22:57:36 +0200 Subject: [PATCH 12/71] Run proof script only on existing files. --- scripts/run_proofs.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/run_proofs.sh b/scripts/run_proofs.sh index bc6cd8e8a..db6b0e02b 100755 --- a/scripts/run_proofs.sh +++ b/scripts/run_proofs.sh @@ -10,16 +10,18 @@ git fetch origin error=0 for new_proof in $(git diff origin/develop --name-only test/formal/) do - set +e - echo "Proving $new_proof..." - output=$(python3 "$new_proof") - result=$? - set -e + if [ -e "$new_proof" ]; then + set +e + echo "Proving $new_proof..." + output=$(python3 "$new_proof") + result=$? + set -e - if [[ "$result" != 0 ]] - then - echo "Proof $(basename "$new_proof" ".py") failed: $output." - error=1 + if [[ "$result" != 0 ]] + then + echo "Proof $(basename "$new_proof" ".py") failed: $output." + error=1 + fi fi done From 72721293548d89d089195e73c263efab01c5d27d Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Mon, 18 Nov 2019 12:12:30 +0100 Subject: [PATCH 13/71] yul fuzzer: Add framework for yul optimizer custom mutation routines Co-authored-by: Leonardo --- .circleci/config.yml | 1 + test/tools/ossfuzz/CMakeLists.txt | 23 ++- .../ossfuzz/protomutators/YulProtoMutator.cpp | 147 ++++++++++++++++++ .../ossfuzz/protomutators/YulProtoMutator.h | 98 ++++++++++++ 4 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 test/tools/ossfuzz/protomutators/YulProtoMutator.cpp create mode 100644 test/tools/ossfuzz/protomutators/YulProtoMutator.h diff --git a/.circleci/config.yml b/.circleci/config.yml index 5157f0661..d17f13baa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,6 +97,7 @@ defaults: - test/tools/ossfuzz/strictasm_diff_ossfuzz - test/tools/ossfuzz/strictasm_opt_ossfuzz - test/tools/ossfuzz/yul_proto_diff_ossfuzz + - test/tools/ossfuzz/yul_proto_diff_custom_mutate_ossfuzz - test/tools/ossfuzz/yul_proto_ossfuzz - test/tools/ossfuzz/sol_proto_ossfuzz diff --git a/test/tools/ossfuzz/CMakeLists.txt b/test/tools/ossfuzz/CMakeLists.txt index ccd71a983..8a33f1f7c 100644 --- a/test/tools/ossfuzz/CMakeLists.txt +++ b/test/tools/ossfuzz/CMakeLists.txt @@ -10,7 +10,12 @@ add_dependencies(ossfuzz if (OSSFUZZ) add_custom_target(ossfuzz_proto) - add_dependencies(ossfuzz_proto yul_proto_ossfuzz yul_proto_diff_ossfuzz sol_proto_ossfuzz) + add_dependencies(ossfuzz_proto + sol_proto_ossfuzz + yul_proto_ossfuzz + yul_proto_diff_ossfuzz + yul_proto_diff_custom_mutate_ossfuzz + ) add_custom_target(ossfuzz_abiv2) add_dependencies(ossfuzz_abiv2 abiv2_proto_ossfuzz) @@ -60,6 +65,22 @@ if (OSSFUZZ) ) set_target_properties(yul_proto_diff_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + add_executable(yul_proto_diff_custom_mutate_ossfuzz + yulProto_diff_ossfuzz.cpp + yulFuzzerCommon.cpp + protoToYul.cpp + yulProto.pb.cc + protomutators/YulProtoMutator.cpp +) + target_include_directories(yul_proto_diff_custom_mutate_ossfuzz PRIVATE /usr/include/libprotobuf-mutator) + target_link_libraries(yul_proto_diff_custom_mutate_ossfuzz PRIVATE yul + yulInterpreter + protobuf-mutator-libfuzzer.a + protobuf-mutator.a + protobuf.a +) + set_target_properties(yul_proto_diff_custom_mutate_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + add_executable(abiv2_proto_ossfuzz ../../EVMHost.cpp abiV2ProtoFuzzer.cpp diff --git a/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp b/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp new file mode 100644 index 000000000..32fda663d --- /dev/null +++ b/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp @@ -0,0 +1,147 @@ +#include + +#include + +#include + +using namespace solidity::yul::test::yul_fuzzer; +using namespace protobuf_mutator; +using namespace std; + +using YPM = YulProtoMutator; + +MutationInfo::MutationInfo(ProtobufMessage const* _message, string const& _info): + ScopeGuard([&]{ exitInfo(); }), + m_protobufMsg(_message) +{ + writeLine("----------------------------------"); + writeLine("YULMUTATOR: " + _info); + writeLine("Before"); + writeLine(SaveMessageAsText(*m_protobufMsg)); +} + +void MutationInfo::exitInfo() +{ + writeLine("After"); + writeLine(SaveMessageAsText(*m_protobufMsg)); +} + +/// Initialize deterministic PRNG. +static YulRandomNumGenerator s_rand(1337); + +/// Add m/sstore(0, variable) +static LPMPostProcessor addStoreToZero( + [](Block* _message, unsigned _seed) + { + if (_seed % YPM::s_highIP == 0) + { + MutationInfo m{_message, "Added store to zero"}; + auto storeStmt = new StoreFunc(); + storeStmt->set_st(YPM::EnumTypeConverter{}.enumFromSeed(s_rand())); + storeStmt->set_allocated_loc(YPM::litExpression(0)); + storeStmt->set_allocated_val(YPM::refExpression(s_rand)); + auto stmt = _message->add_statements(); + stmt->set_allocated_storage_func(storeStmt); + } + } +); + +Literal* YPM::intLiteral(unsigned _value) +{ + auto lit = new Literal(); + lit->set_intval(_value); + return lit; +} + +VarRef* YPM::varRef(unsigned _seed) +{ + auto varref = new VarRef(); + varref->set_varnum(_seed); + return varref; +} + +Expression* YPM::refExpression(YulRandomNumGenerator& _rand) +{ + auto refExpr = new Expression(); + refExpr->set_allocated_varref(varRef(_rand())); + return refExpr; +} + +Expression* YPM::litExpression(unsigned _value) +{ + auto lit = intLiteral(_value); + auto expr = new Expression(); + expr->set_allocated_cons(lit); + return expr; +} + +template +T YPM::EnumTypeConverter::validEnum(unsigned _seed) +{ + auto ret = static_cast(_seed % (enumMax() - enumMin() + 1) + enumMin()); + if constexpr (std::is_same_v, FunctionCall_Returns>) + yulAssert(FunctionCall_Returns_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, StoreFunc_Storage>) + yulAssert(StoreFunc_Storage_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, NullaryOp_NOp>) + yulAssert(NullaryOp_NOp_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, BinaryOp_BOp>) + yulAssert(BinaryOp_BOp_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, UnaryOp_UOp>) + yulAssert(UnaryOp_UOp_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, LowLevelCall_Type>) + yulAssert(LowLevelCall_Type_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, Create_Type>) + yulAssert(Create_Type_IsValid(ret), "Yul proto mutator: Invalid enum"); + else if constexpr (std::is_same_v, UnaryOpData_UOpData>) + yulAssert(UnaryOpData_UOpData_IsValid(ret), "Yul proto mutator: Invalid enum"); + else + static_assert(AlwaysFalse::value, "Yul proto mutator: non-exhaustive visitor."); + return ret; +} + +template +unsigned YPM::EnumTypeConverter::enumMax() +{ + if constexpr (std::is_same_v, FunctionCall_Returns>) + return FunctionCall_Returns_Returns_MAX; + else if constexpr (std::is_same_v, StoreFunc_Storage>) + return StoreFunc_Storage_Storage_MAX; + else if constexpr (std::is_same_v, NullaryOp_NOp>) + return NullaryOp_NOp_NOp_MAX; + else if constexpr (std::is_same_v, BinaryOp_BOp>) + return BinaryOp_BOp_BOp_MAX; + else if constexpr (std::is_same_v, UnaryOp_UOp>) + return UnaryOp_UOp_UOp_MAX; + else if constexpr (std::is_same_v, LowLevelCall_Type>) + return LowLevelCall_Type_Type_MAX; + else if constexpr (std::is_same_v, Create_Type>) + return Create_Type_Type_MAX; + else if constexpr (std::is_same_v, UnaryOpData_UOpData>) + return UnaryOpData_UOpData_UOpData_MAX; + else + static_assert(AlwaysFalse::value, "Yul proto mutator: non-exhaustive visitor."); +} + +template +unsigned YPM::EnumTypeConverter::enumMin() +{ + if constexpr (std::is_same_v, FunctionCall_Returns>) + return FunctionCall_Returns_Returns_MIN; + else if constexpr (std::is_same_v, StoreFunc_Storage>) + return StoreFunc_Storage_Storage_MIN; + else if constexpr (std::is_same_v, NullaryOp_NOp>) + return NullaryOp_NOp_NOp_MIN; + else if constexpr (std::is_same_v, BinaryOp_BOp>) + return BinaryOp_BOp_BOp_MIN; + else if constexpr (std::is_same_v, UnaryOp_UOp>) + return UnaryOp_UOp_UOp_MIN; + else if constexpr (std::is_same_v, LowLevelCall_Type>) + return LowLevelCall_Type_Type_MIN; + else if constexpr (std::is_same_v, Create_Type>) + return Create_Type_Type_MIN; + else if constexpr (std::is_same_v, UnaryOpData_UOpData>) + return UnaryOpData_UOpData_UOpData_MIN; + else + static_assert(AlwaysFalse::value, "Yul proto mutator: non-exhaustive visitor."); +} diff --git a/test/tools/ossfuzz/protomutators/YulProtoMutator.h b/test/tools/ossfuzz/protomutators/YulProtoMutator.h new file mode 100644 index 000000000..0627a3468 --- /dev/null +++ b/test/tools/ossfuzz/protomutators/YulProtoMutator.h @@ -0,0 +1,98 @@ +#pragma once + +#include + +#include + +#include + +#include + +namespace solidity::yul::test::yul_fuzzer +{ + +using ProtobufMessage = google::protobuf::Message; + +template +using LPMPostProcessor = protobuf_mutator::libfuzzer::PostProcessorRegistration; + +class MutationInfo: public ScopeGuard +{ +public: + MutationInfo(ProtobufMessage const* _message, std::string const& _info); + + static void writeLine(std::string const& _str) + { + std::cout << _str << std::endl; + } + void exitInfo(); + + ProtobufMessage const* m_protobufMsg; +}; + +struct YulRandomNumGenerator +{ + using RandomEngine = std::minstd_rand; + + explicit YulRandomNumGenerator(unsigned _seed): m_random(RandomEngine(_seed)) {} + + unsigned operator()() + { + return m_random(); + } + + RandomEngine m_random; +}; + +struct YulProtoMutator +{ + /// @param _value: Value of the integer literal + /// @returns an integer literal protobuf message initialized with + /// the given value. + static Literal* intLiteral(unsigned _value); + + /// @param _seed: Pseudo-random unsigned integer used as index + /// of variable to be referenced + /// @returns a variable reference protobuf message. + static VarRef* varRef(unsigned _seed); + + /// @param _value: value of literal expression + /// @returns an expression protobuf message + static Expression* litExpression(unsigned _value); + + /// @param _rand: Pseudo-random number generator + /// of variable to be referenced + /// @returns a variable reference protobuf message + static Expression* refExpression(YulRandomNumGenerator& _rand); + + /// Helper type for type matching visitor. + template struct AlwaysFalse: std::false_type {}; + + /// Template struct for obtaining a valid enum value of + /// template type from a pseudo-random unsigned integer. + /// @param _seed: Pseudo-random integer + /// @returns Valid enum of enum type T + template + struct EnumTypeConverter + { + T enumFromSeed(unsigned _seed) + { + return validEnum(_seed); + } + + /// @returns a valid enum of type T from _seed + T validEnum(unsigned _seed); + /// @returns maximum enum value for enum of type T + static unsigned enumMax(); + /// @returns minimum enum value for enum of type T + static unsigned enumMin(); + }; + + /// Modulo for mutations that should occur rarely + static constexpr unsigned s_lowIP = 31; + /// Modulo for mutations that should occur not too often + static constexpr unsigned s_mediumIP = 29; + /// Modulo for mutations that should occur often + static constexpr unsigned s_highIP = 23; +}; +} From a068583bece4073477eec7df73baf52a76abe0b8 Mon Sep 17 00:00:00 2001 From: a3d4 Date: Thu, 9 Jul 2020 14:39:05 +0200 Subject: [PATCH 14/71] Cover cmdlineTests.sh errors --- scripts/error_codes.py | 11 +++++++++++ test/cmdlineTests/error_codes/err | 19 +++++++++++-------- test/cmdlineTests/error_codes/input.sol | 2 -- .../imports/declaration_not_found.sol | 7 +++++++ test/libsolidity/syntaxTests/unexpected.sol | 3 +++ 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 test/libsolidity/syntaxTests/imports/declaration_not_found.sol create mode 100644 test/libsolidity/syntaxTests/unexpected.sol diff --git a/scripts/error_codes.py b/scripts/error_codes.py index 7ab136e84..da317d45c 100755 --- a/scripts/error_codes.py +++ b/scripts/error_codes.py @@ -127,6 +127,12 @@ def find_ids_in_test_files(file_names): return used_ids +def find_ids_in_cmdline_test_err(file_name): + source = read_file(file_name) + pattern = r' \(\d\d\d\d\):' + return {m.group(0)[-6:-2] for m in re.finditer(pattern, source, flags=re.MULTILINE)} + + def print_ids(ids): for k, id in enumerate(sorted(ids)): if k % 10 > 0: @@ -149,6 +155,11 @@ def examine_id_coverage(top_dir, used_ids): ) covered_ids = find_ids_in_test_files(test_file_names) + # special case, we are interested in warnings which are ignored by regular tests: + # Warning (1878): SPDX license identifier not provided in source file. .... + # Warning (3420): Source file does not specify required compiler version! + covered_ids |= find_ids_in_cmdline_test_err(path.join(top_dir, "test", "cmdlineTests", "error_codes", "err")) + print(f"IDs in source files: {len(used_ids)}") print(f"IDs in test files : {len(covered_ids)} ({len(covered_ids) - len(used_ids)})") print() diff --git a/test/cmdlineTests/error_codes/err b/test/cmdlineTests/error_codes/err index 1d983a7fd..a10362a86 100644 --- a/test/cmdlineTests/error_codes/err +++ b/test/cmdlineTests/error_codes/err @@ -1,26 +1,29 @@ +Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> error_codes/input.sol + Error (4937): No visibility specified. Did you intend to add "public"? - --> error_codes/input.sol:4:5: + --> error_codes/input.sol:2:5: | -4 | function f() { +2 | function f() { | ^ (Relevant source part starts here and spans across multiple lines). Warning (3420): Source file does not specify required compiler version! --> error_codes/input.sol Error (4247): Expression has to be an lvalue. - --> error_codes/input.sol:5:9: + --> error_codes/input.sol:3:9: | -5 | 2=0; +3 | 2=0; | ^ Error (7407): Type int_const 0 is not implicitly convertible to expected type int_const 2. - --> error_codes/input.sol:5:11: + --> error_codes/input.sol:3:11: | -5 | 2=0; +3 | 2=0; | ^ Error (2614): Indexed expression has to be a type, mapping or array (is literal_string "") - --> error_codes/input.sol:6:9: + --> error_codes/input.sol:4:9: | -6 | ""[2]; +4 | ""[2]; | ^^ diff --git a/test/cmdlineTests/error_codes/input.sol b/test/cmdlineTests/error_codes/input.sol index 78aceb41f..5ea2800c5 100644 --- a/test/cmdlineTests/error_codes/input.sol +++ b/test/cmdlineTests/error_codes/input.sol @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-3.0 - contract C { function f() { 2=0; diff --git a/test/libsolidity/syntaxTests/imports/declaration_not_found.sol b/test/libsolidity/syntaxTests/imports/declaration_not_found.sol new file mode 100644 index 000000000..b02868e54 --- /dev/null +++ b/test/libsolidity/syntaxTests/imports/declaration_not_found.sol @@ -0,0 +1,7 @@ +==== Source: a ==== +contract A { } +==== Source: b ==== +import {C} from "a"; +contract B { } +// ---- +// DeclarationError 2904: (b:0-20): Declaration "C" not found in "a" (referenced as "a"). diff --git a/test/libsolidity/syntaxTests/unexpected.sol b/test/libsolidity/syntaxTests/unexpected.sol new file mode 100644 index 000000000..79ee1b6cb --- /dev/null +++ b/test/libsolidity/syntaxTests/unexpected.sol @@ -0,0 +1,3 @@ +unexpected +// ---- +// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/struct/enum definition. From ec2393d3b656291636f827f81b067caac17bad89 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 9 Jul 2020 14:24:49 +0200 Subject: [PATCH 15/71] Refactor interpreter. --- test/libyul/EwasmTranslationTest.cpp | 4 +- test/libyul/YulInterpreterTest.cpp | 3 +- test/tools/ossfuzz/yulFuzzerCommon.cpp | 3 +- test/tools/yulInterpreter/Interpreter.cpp | 81 +++++++++++------------ test/tools/yulInterpreter/Interpreter.h | 48 +++++++------- test/tools/yulrun.cpp | 5 +- 6 files changed, 69 insertions(+), 75 deletions(-) diff --git a/test/libyul/EwasmTranslationTest.cpp b/test/libyul/EwasmTranslationTest.cpp index 8ef5ba0a0..9ef203dd0 100644 --- a/test/libyul/EwasmTranslationTest.cpp +++ b/test/libyul/EwasmTranslationTest.cpp @@ -99,11 +99,9 @@ string EwasmTranslationTest::interpret() InterpreterState state; state.maxTraceSize = 10000; state.maxSteps = 100000; - WasmDialect dialect; - Interpreter interpreter(state, dialect); try { - interpreter(*m_object->code); + Interpreter::run(state, WasmDialect{}, *m_object->code); } catch (InterpreterTerminatedGeneric const&) { diff --git a/test/libyul/YulInterpreterTest.cpp b/test/libyul/YulInterpreterTest.cpp index 9925b9546..fa84c0869 100644 --- a/test/libyul/YulInterpreterTest.cpp +++ b/test/libyul/YulInterpreterTest.cpp @@ -88,10 +88,9 @@ string YulInterpreterTest::interpret() InterpreterState state; state.maxTraceSize = 10000; state.maxSteps = 10000; - Interpreter interpreter(state, EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{})); try { - interpreter(*m_ast); + Interpreter::run(state, EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}), *m_ast); } catch (InterpreterTerminatedGeneric const&) { diff --git a/test/tools/ossfuzz/yulFuzzerCommon.cpp b/test/tools/ossfuzz/yulFuzzerCommon.cpp index 214caf3f8..3682eef48 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.cpp +++ b/test/tools/ossfuzz/yulFuzzerCommon.cpp @@ -44,12 +44,11 @@ yulFuzzerUtil::TerminationReason yulFuzzerUtil::interpret( 0xc7, 0x60, 0x5f, 0x7c, 0xcd, 0xfb, 0x92, 0xcd, 0x8e, 0xf3, 0x9b, 0xe4, 0x4f, 0x6c, 0x14, 0xde }; - Interpreter interpreter(state, _dialect); TerminationReason reason = TerminationReason::None; try { - interpreter(*_ast); + Interpreter::run(state, _dialect, *_ast); } catch (StepLimitReached const&) { diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index 5f0861d14..cd4fa5d69 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -64,6 +64,12 @@ void InterpreterState::dumpTraceAndState(ostream& _out) const _out << " " << slot.first.hex() << ": " << slot.second.hex() << endl; } +void Interpreter::run(InterpreterState& _state, Dialect const& _dialect, Block const& _ast) +{ + Scope scope; + Interpreter{_state, _dialect, scope}(_ast); +} + void Interpreter::operator()(ExpressionStatement const& _expressionStatement) { evaluateMulti(_expressionStatement.expression); @@ -94,8 +100,7 @@ void Interpreter::operator()(VariableDeclaration const& _declaration) YulString varName = _declaration.variables.at(i).name; solAssert(!m_variables.count(varName), ""); m_variables[varName] = values.at(i); - solAssert(!m_scopes.back().count(varName), ""); - m_scopes.back().emplace(varName, nullptr); + m_scope->names.emplace(varName, nullptr); } } @@ -128,8 +133,8 @@ void Interpreter::operator()(ForLoop const& _forLoop) { solAssert(_forLoop.condition, ""); - openScope(); - ScopeGuard g([this]{ closeScope(); }); + enterScope(_forLoop.pre); + ScopeGuard g([this]{ leaveScope(); }); for (auto const& statement: _forLoop.pre.statements) { @@ -176,14 +181,13 @@ void Interpreter::operator()(Block const& _block) m_state.trace.emplace_back("Interpreter execution step limit reached."); throw StepLimitReached(); } - openScope(); + enterScope(_block); // Register functions. for (auto const& statement: _block.statements) if (holds_alternative(statement)) { FunctionDefinition const& funDef = std::get(statement); - solAssert(!m_scopes.back().count(funDef.name), ""); - m_scopes.back().emplace(funDef.name, &funDef); + m_scope->names.emplace(funDef.name, &funDef); } for (auto const& statement: _block.statements) @@ -193,29 +197,41 @@ void Interpreter::operator()(Block const& _block) break; } - closeScope(); + leaveScope(); } u256 Interpreter::evaluate(Expression const& _expression) { - ExpressionEvaluator ev(m_state, m_dialect, m_variables, m_scopes); + ExpressionEvaluator ev(m_state, m_dialect, *m_scope, m_variables); ev.visit(_expression); return ev.value(); } vector Interpreter::evaluateMulti(Expression const& _expression) { - ExpressionEvaluator ev(m_state, m_dialect, m_variables, m_scopes); + ExpressionEvaluator ev(m_state, m_dialect, *m_scope, m_variables); ev.visit(_expression); return ev.values(); } -void Interpreter::closeScope() +void Interpreter::enterScope(Block const& _block) { - for (auto const& [var, funDeclaration]: m_scopes.back()) + if (!m_scope->subScopes.count(&_block)) + m_scope->subScopes[&_block] = make_unique(Scope{ + {}, + {}, + m_scope + }); + m_scope = m_scope->subScopes[&_block].get(); +} + +void Interpreter::leaveScope() +{ + for (auto const& [var, funDeclaration]: m_scope->names) if (!funDeclaration) - solAssert(m_variables.erase(var) == 1, ""); - m_scopes.pop_back(); + m_variables.erase(var); + m_scope = m_scope->parent; + yulAssert(m_scope, ""); } void ExpressionEvaluator::operator()(Literal const& _literal) @@ -253,10 +269,15 @@ void ExpressionEvaluator::operator()(FunctionCall const& _funCall) return; } - auto [functionScopes, fun] = findFunctionAndScope(_funCall.functionName.name); + Scope* scope = &m_scope; + for (; scope; scope = scope->parent) + if (scope->names.count(_funCall.functionName.name)) + break; + yulAssert(scope, ""); - solAssert(fun, "Function not found."); - solAssert(m_values.size() == fun->parameters.size(), ""); + FunctionDefinition const* fun = scope->names.at(_funCall.functionName.name); + yulAssert(fun, "Function not found."); + yulAssert(m_values.size() == fun->parameters.size(), ""); map variables; for (size_t i = 0; i < fun->parameters.size(); ++i) variables[fun->parameters.at(i).name] = m_values.at(i); @@ -264,7 +285,7 @@ void ExpressionEvaluator::operator()(FunctionCall const& _funCall) variables[fun->returnVariables.at(i).name] = 0; m_state.controlFlowState = ControlFlowState::Default; - Interpreter interpreter(m_state, m_dialect, variables, functionScopes); + Interpreter interpreter(m_state, m_dialect, *scope, std::move(variables)); interpreter(fun->body); m_state.controlFlowState = ControlFlowState::Default; @@ -297,27 +318,3 @@ void ExpressionEvaluator::evaluateArgs(vector const& _expr) m_values = std::move(values); std::reverse(m_values.begin(), m_values.end()); } - -pair< - vector>, - FunctionDefinition const* -> ExpressionEvaluator::findFunctionAndScope(YulString _functionName) const -{ - FunctionDefinition const* fun = nullptr; - std::vector> newScopes; - for (auto const& scope: m_scopes) - { - // Copy over all functions. - newScopes.emplace_back(); - for (auto const& [name, funDef]: scope) - if (funDef) - newScopes.back().emplace(name, funDef); - // Stop at the called function. - if (scope.count(_functionName)) - { - fun = scope.at(_functionName); - break; - } - } - return {move(newScopes), fun}; -} diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index f50cbe6c4..3c9619d21 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -96,23 +96,37 @@ struct InterpreterState void dumpTraceAndState(std::ostream& _out) const; }; +/** + * Scope structure built and maintained during execution. + */ +struct Scope +{ + /// Used for variables and functions. Value is nullptr for variables. + std::map names; + std::map> subScopes; + Scope* parent = nullptr; +}; + /** * Yul interpreter. */ class Interpreter: public ASTWalker { public: + static void run(InterpreterState& _state, Dialect const& _dialect, Block const& _ast); + Interpreter( InterpreterState& _state, Dialect const& _dialect, - std::map _variables = {}, - std::vector> _scopes = {} + Scope& _scope, + std::map _variables = {} ): m_dialect(_dialect), m_state(_state), m_variables(std::move(_variables)), - m_scopes(std::move(_scopes)) - {} + m_scope(&_scope) + { + } void operator()(ExpressionStatement const& _statement) override; void operator()(Assignment const& _assignment) override; @@ -136,18 +150,14 @@ private: /// Evaluates the expression and returns its value. std::vector evaluateMulti(Expression const& _expression); - void openScope() { m_scopes.emplace_back(); } - /// Unregisters variables and functions. - void closeScope(); + void enterScope(Block const& _block); + void leaveScope(); Dialect const& m_dialect; InterpreterState& m_state; /// Values of variables. std::map m_variables; - /// Scopes of variables and functions. Used for lookup, clearing at end of blocks - /// and passing over the visible functions across function calls. - /// The pointer is nullptr if and only if the key is a variable. - std::vector> m_scopes; + Scope* m_scope; }; /** @@ -159,13 +169,13 @@ public: ExpressionEvaluator( InterpreterState& _state, Dialect const& _dialect, - std::map const& _variables, - std::vector> const& _scopes + Scope& _scope, + std::map const& _variables ): m_state(_state), m_dialect(_dialect), m_variables(_variables), - m_scopes(_scopes) + m_scope(_scope) {} void operator()(Literal const&) override; @@ -184,19 +194,11 @@ private: /// stores it in m_value. void evaluateArgs(std::vector const& _expr); - /// Finds the function called @a _functionName in the current scope stack and returns - /// the function's scope stack (with variables removed) and definition. - std::pair< - std::vector>, - FunctionDefinition const* - > findFunctionAndScope(YulString _functionName) const; - InterpreterState& m_state; Dialect const& m_dialect; /// Values of variables. std::map const& m_variables; - /// Stack of scopes in the current context. - std::vector> const& m_scopes; + Scope& m_scope; /// Current value of the expression std::vector m_values; }; diff --git a/test/tools/yulrun.cpp b/test/tools/yulrun.cpp index 1e82fba7f..494115540 100644 --- a/test/tools/yulrun.cpp +++ b/test/tools/yulrun.cpp @@ -88,11 +88,10 @@ void interpret(string const& _source) InterpreterState state; state.maxTraceSize = 10000; - Dialect const& dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{})); - Interpreter interpreter(state, dialect); try { - interpreter(*ast); + Dialect const& dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{})); + Interpreter::run(state, dialect, *ast); } catch (InterpreterTerminatedGeneric const&) { From 3cf5ed9514211d18d5171f9ddbf849c850fcd1e4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 9 Jul 2020 14:56:34 +0200 Subject: [PATCH 16/71] Use plain strings for comparison. --- .../EwasmBuiltinInterpreter.cpp | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index b09fb5a87..1d8e29e91 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -76,11 +76,12 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a for (u256 const& a: _arguments) arg.emplace_back(uint64_t(a & uint64_t(-1))); - if (_fun == "datasize"_yulstring) + string fun = _fun.str(); + if (fun == "datasize") return u256(keccak256(h256(_arguments.at(0)))) & 0xfff; - else if (_fun == "dataoffset"_yulstring) + else if (fun == "dataoffset") return u256(keccak256(h256(_arguments.at(0) + 2))) & 0xfff; - else if (_fun == "datacopy"_yulstring) + else if (fun == "datacopy") { // This is identical to codecopy. if (accessMemory(_arguments.at(0), _arguments.at(2))) @@ -93,49 +94,49 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a ); return 0; } - else if (_fun == "i32.drop"_yulstring || _fun == "i64.drop"_yulstring || _fun == "nop"_yulstring) + else if (fun == "i32.drop" || fun == "i64.drop" || fun == "nop") return {}; - else if (_fun == "i32.wrap_i64"_yulstring) + else if (fun == "i32.wrap_i64") return arg.at(0) & uint32_t(-1); - else if (_fun == "i64.extend_i32_u"_yulstring) + else if (fun == "i64.extend_i32_u") // Return the same as above because everything is u256 anyway. return arg.at(0) & uint32_t(-1); - else if (_fun == "unreachable"_yulstring) + else if (fun == "unreachable") { logTrace(evmasm::Instruction::INVALID, {}); throw ExplicitlyTerminated(); } - else if (_fun == "i64.store"_yulstring) + else if (fun == "i64.store") { accessMemory(arg[0], 8); writeMemoryWord(arg[0], arg[1]); return 0; } - else if (_fun == "i64.store8"_yulstring || _fun == "i32.store8"_yulstring) + else if (fun == "i64.store8" || fun == "i32.store8") { accessMemory(arg[0], 1); writeMemoryByte(arg[0], static_cast(arg[1] & 0xff)); return 0; } - else if (_fun == "i64.load"_yulstring) + else if (fun == "i64.load") { accessMemory(arg[0], 8); return readMemoryWord(arg[0]); } - else if (_fun == "i32.store"_yulstring) + else if (fun == "i32.store") { accessMemory(arg[0], 4); writeMemoryHalfWord(arg[0], arg[1]); return 0; } - else if (_fun == "i32.load"_yulstring) + else if (fun == "i32.load") { accessMemory(arg[0], 4); return readMemoryHalfWord(arg[0]); } - string prefix = _fun.str(); + string prefix = fun; string suffix; auto dot = prefix.find("."); if (dot != string::npos) From 3c57e047519758be464c3bbb19dc5bb1d798d3ab Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Wed, 3 Jun 2020 10:25:46 +0200 Subject: [PATCH 17/71] Adding -Wsign-conversion flag to cmake. --- cmake/EthCompilerSettings.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 1f7600d9b..3bcdad47b 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -50,6 +50,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA add_compile_options(-pedantic) add_compile_options(-Wno-unknown-pragmas) add_compile_options(-Wimplicit-fallthrough) + add_compile_options(-Wsign-conversion) # Configuration-specific compiler settings. set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG") From 872858078f8e4c583a6a6bf0ba154f143efd9f20 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 9 Jul 2020 16:16:17 +0200 Subject: [PATCH 18/71] Run "options" test first to get early failures. --- .circleci/soltest_all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 94a89704a..86f172a04 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -28,10 +28,10 @@ set -e REPODIR="$(realpath $(dirname $0)/..)" +EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh + for OPTIMIZE in 0 1; do for EVM in homestead byzantium constantinople petersburg istanbul; do EVM=$EVM OPTIMIZE=$OPTIMIZE BOOST_TEST_ARGS="-t !@nooptions" ${REPODIR}/.circleci/soltest.sh done done - -EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh From 547590b972138ffa2d49a388ccd889d93b024154 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Mon, 15 Jun 2020 12:51:58 +0200 Subject: [PATCH 19/71] Fixing additional signedness errors after adding -Wsign-conversion flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil ƚliwak --- liblangutil/SemVerHandler.cpp | 6 +++--- libsmtutil/CVC4Interface.cpp | 2 +- libsmtutil/SMTLib2Interface.cpp | 2 +- libsmtutil/Z3Interface.cpp | 2 +- libsolidity/codegen/ContractCompiler.cpp | 2 +- libsolidity/formal/SMTEncoder.cpp | 2 +- libyul/backends/evm/EVMCodeTransform.cpp | 10 +++++----- test/tools/ossfuzz/protoToYul.cpp | 4 ++-- test/tools/ossfuzz/solProtoFuzzer.cpp | 2 +- test/tools/ossfuzz/yulProtoFuzzer.cpp | 2 +- test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp | 2 +- test/yulPhaser/Mutations.cpp | 4 ++-- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/liblangutil/SemVerHandler.cpp b/liblangutil/SemVerHandler.cpp index a626c5aa7..d997cb073 100644 --- a/liblangutil/SemVerHandler.cpp +++ b/liblangutil/SemVerHandler.cpp @@ -245,14 +245,14 @@ unsigned SemVerMatchExpressionParser::parseVersionPart() return 0; else if ('1' <= c && c <= '9') { - unsigned v(c - '0'); + auto v = static_cast(c - '0'); // If we skip to the next token, the current number is terminated. while (m_pos == startPos && '0' <= currentChar() && currentChar() <= '9') { c = currentChar(); - if (v * 10 < v || v * 10 + unsigned(c - '0') < v * 10) + if (v * 10 < v || v * 10 + static_cast(c - '0') < v * 10) throw SemVerError(); - v = v * 10 + unsigned(c - '0'); + v = v * 10 + static_cast(c - '0'); nextChar(); } return v; diff --git a/libsmtutil/CVC4Interface.cpp b/libsmtutil/CVC4Interface.cpp index 7735d5a16..f58e46801 100644 --- a/libsmtutil/CVC4Interface.cpp +++ b/libsmtutil/CVC4Interface.cpp @@ -191,7 +191,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr) return m_context.mkExpr(CVC4::kind::BITVECTOR_AND, arguments[0], arguments[1]); else if (n == "int2bv") { - size_t size = std::stoi(_expr.arguments[1].name); + size_t size = std::stoul(_expr.arguments[1].name); auto i2bvOp = m_context.mkConst(CVC4::IntToBitVector(size)); // CVC4 treats all BVs as unsigned, so we need to manually apply 2's complement if needed. return m_context.mkExpr( diff --git a/libsmtutil/SMTLib2Interface.cpp b/libsmtutil/SMTLib2Interface.cpp index ce1efb5f6..1f87b9b72 100644 --- a/libsmtutil/SMTLib2Interface.cpp +++ b/libsmtutil/SMTLib2Interface.cpp @@ -139,7 +139,7 @@ string SMTLib2Interface::toSExpr(Expression const& _expr) std::string sexpr = "("; if (_expr.name == "int2bv") { - size_t size = std::stoi(_expr.arguments[1].name); + size_t size = std::stoul(_expr.arguments[1].name); auto arg = toSExpr(_expr.arguments.front()); auto int2bv = "(_ int2bv " + to_string(size) + ")"; // Some solvers treat all BVs as unsigned, so we need to manually apply 2's complement if needed. diff --git a/libsmtutil/Z3Interface.cpp b/libsmtutil/Z3Interface.cpp index a71d008ab..c2309ad4f 100644 --- a/libsmtutil/Z3Interface.cpp +++ b/libsmtutil/Z3Interface.cpp @@ -184,7 +184,7 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr) return arguments[0] & arguments[1]; else if (n == "int2bv") { - size_t size = std::stoi(_expr.arguments[1].name); + size_t size = std::stoul(_expr.arguments[1].name); return z3::int2bv(size, arguments[0]); } else if (n == "bv2int") diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 3d1b41e41..ad9c97474 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -646,7 +646,7 @@ bool ContractCompiler::visit(FunctionDefinition const& _function) } else { - m_context << swapInstruction(stackLayout.size() - static_cast(stackLayout.back()) - 1); + m_context << swapInstruction(stackLayout.size() - static_cast(stackLayout.back()) - 1u); swap(stackLayout[static_cast(stackLayout.back())], stackLayout.back()); } for (size_t i = 0; i < stackLayout.size(); ++i) diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 6faaaf600..8e8e34ab2 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -1253,7 +1253,7 @@ pair SMTEncoder::arithmeticOperation( // - RHS is -1 // the result is then -(type.min), which wraps back to type.min smtutil::Expression maxLeft = _left == smt::minValue(*intType); - smtutil::Expression minusOneRight = _right == -1; + smtutil::Expression minusOneRight = _right == numeric_limits::max(); smtutil::Expression wrap = smtutil::Expression::ite(maxLeft && minusOneRight, smt::minValue(*intType), valueUnbounded); return {wrap, valueUnbounded}; } diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 9182bb393..6b0f06e01 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -165,7 +165,7 @@ void CodeTransform::deleteVariable(Scope::Variable const& _var) { yulAssert(m_allowStackOpt, ""); yulAssert(m_context->variableStackHeights.count(&_var) > 0, ""); - m_unusedStackSlots.insert(m_context->variableStackHeights[&_var]); + m_unusedStackSlots.insert(static_cast(m_context->variableStackHeights[&_var])); m_context->variableStackHeights.erase(&_var); m_context->variableReferences.erase(&_var); m_variablesScheduledForDeletion.erase(&_var); @@ -402,7 +402,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) yulAssert(m_scope->identifiers.count(_function.name), ""); Scope::Function& function = std::get(m_scope->identifiers.at(_function.name)); - int height = m_evm15 ? 0 : 1; + size_t height = m_evm15 ? 0 : 1; yulAssert(m_info.scopes.at(&_function.body), ""); Scope* varScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get(); yulAssert(varScope, ""); @@ -420,7 +420,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) else m_assembly.appendLabel(functionEntryID(_function.name, function)); - m_assembly.setStackHeight(height); + m_assembly.setStackHeight(static_cast(height)); for (auto const& v: _function.returnVariables) { @@ -457,7 +457,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) StackTooDeepError error(_error); if (error.functionName.empty()) error.functionName = _function.name; - stackError(std::move(error), height); + stackError(std::move(error), static_cast(height)); } m_assembly.appendLabel(m_context->functionExitPoints.top().label); @@ -502,7 +502,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) } else { - m_assembly.appendInstruction(evmasm::swapInstruction(stackLayout.size() - static_cast(stackLayout.back()) - 1)); + m_assembly.appendInstruction(evmasm::swapInstruction(static_cast(stackLayout.size()) - static_cast(stackLayout.back()) - 1u)); swap(stackLayout[static_cast(stackLayout.back())], stackLayout.back()); } for (size_t i = 0; i < stackLayout.size(); ++i) diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 8d5ced0a8..05787a2df 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -184,13 +184,13 @@ void ProtoConverter::visit(VarRef const& _x) { // Ensure that there is at least one variable declaration to reference in function scope. yulAssert(m_currentFuncVars.size() > 0, "Proto fuzzer: No variables to reference."); - m_output << *m_currentFuncVars[_x.varnum() % m_currentFuncVars.size()]; + m_output << *m_currentFuncVars[static_cast(_x.varnum()) % m_currentFuncVars.size()]; } else { // Ensure that there is at least one variable declaration to reference in nested scopes. yulAssert(m_currentGlobalVars.size() > 0, "Proto fuzzer: No global variables to reference."); - m_output << *m_currentGlobalVars[_x.varnum() % m_currentGlobalVars.size()]; + m_output << *m_currentGlobalVars[static_cast(_x.varnum()) % m_currentGlobalVars.size()]; } } diff --git a/test/tools/ossfuzz/solProtoFuzzer.cpp b/test/tools/ossfuzz/solProtoFuzzer.cpp index 80facb3e1..663a94d36 100644 --- a/test/tools/ossfuzz/solProtoFuzzer.cpp +++ b/test/tools/ossfuzz/solProtoFuzzer.cpp @@ -202,7 +202,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_DUMP_PATH=x.yul ./a.out proto-input ofstream of(dump_path); - of.write(sol_source.data(), sol_source.size()); + of.write(sol_source.data(), static_cast(sol_source.size())); } if (char const* dump_path = getenv("SOL_DEBUG_FILE")) diff --git a/test/tools/ossfuzz/yulProtoFuzzer.cpp b/test/tools/ossfuzz/yulProtoFuzzer.cpp index b78f6fc5c..cc0205d16 100644 --- a/test/tools/ossfuzz/yulProtoFuzzer.cpp +++ b/test/tools/ossfuzz/yulProtoFuzzer.cpp @@ -43,7 +43,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_DUMP_PATH=x.yul ./a.out proto-input ofstream of(dump_path); - of.write(yul_source.data(), yul_source.size()); + of.write(yul_source.data(), static_cast(yul_source.size())); } if (yul_source.size() > 1200) diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index fd0f2e0a5..e5e6b203f 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -64,7 +64,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_DUMP_PATH=x.yul ./a.out proto-input ofstream of(dump_path); - of.write(yul_source.data(), yul_source.size()); + of.write(yul_source.data(), static_cast(yul_source.size())); } YulStringRepository::reset(); diff --git a/test/yulPhaser/Mutations.cpp b/test/yulPhaser/Mutations.cpp index aae16cced..2d6b65c88 100644 --- a/test/yulPhaser/Mutations.cpp +++ b/test/yulPhaser/Mutations.cpp @@ -179,8 +179,8 @@ BOOST_AUTO_TEST_CASE(alternativeMutations_should_choose_between_mutations_with_g for (size_t i = 0; i < 10; ++i) { Chromosome mutatedChromosome = mutation(chromosome); - cCount += (mutatedChromosome == Chromosome("c") ? 1 : 0); - fCount += (mutatedChromosome == Chromosome("f") ? 1 : 0); + cCount += (mutatedChromosome == Chromosome("c") ? 1u : 0u); + fCount += (mutatedChromosome == Chromosome("f") ? 1u : 0u); } // This particular seed results in 7 "c"s out of 10 which looks plausible given the 80% chance. From a0300835eb7b6c7e26a4cd5757675a5e68988fa8 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 8 Jul 2020 10:47:03 +0100 Subject: [PATCH 20/71] Change CHC to avoid sign mismatch --- libsolidity/formal/CHC.cpp | 4 ++-- libsolidity/formal/CHC.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index c3e9d6cb4..88f932bec 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -990,13 +990,13 @@ vector CHC::initialStateVariables(ContractDefinition const& return stateVariablesAtIndex(0, _contract); } -vector CHC::stateVariablesAtIndex(int _index) +vector CHC::stateVariablesAtIndex(unsigned _index) { solAssert(m_currentContract, ""); return stateVariablesAtIndex(_index, *m_currentContract); } -vector CHC::stateVariablesAtIndex(int _index, ContractDefinition const& _contract) +vector CHC::stateVariablesAtIndex(unsigned _index, ContractDefinition const& _contract) { return applyMap( stateVariablesIncludingInheritedAndPrivate(_contract), diff --git a/libsolidity/formal/CHC.h b/libsolidity/formal/CHC.h index dcba90606..e9357a38d 100644 --- a/libsolidity/formal/CHC.h +++ b/libsolidity/formal/CHC.h @@ -152,8 +152,8 @@ private: /// of the current transaction. std::vector initialStateVariables(); std::vector initialStateVariables(ContractDefinition const& _contract); - std::vector stateVariablesAtIndex(int _index); - std::vector stateVariablesAtIndex(int _index, ContractDefinition const& _contract); + std::vector stateVariablesAtIndex(unsigned _index); + std::vector stateVariablesAtIndex(unsigned _index, ContractDefinition const& _contract); /// @returns the current symbolic values of the current state variables. std::vector currentStateVariables(); std::vector currentStateVariables(ContractDefinition const& _contract); From 3781ee6349c2761f78e3a228fa04a068fd1626f0 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Wed, 8 Jul 2020 16:43:22 +0200 Subject: [PATCH 21/71] Removing -Wsign-conversion flag for ossfuzz targets --- test/tools/ossfuzz/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/tools/ossfuzz/CMakeLists.txt b/test/tools/ossfuzz/CMakeLists.txt index ccd71a983..ca923ae3a 100644 --- a/test/tools/ossfuzz/CMakeLists.txt +++ b/test/tools/ossfuzz/CMakeLists.txt @@ -8,6 +8,7 @@ add_dependencies(ossfuzz strictasm_assembly_ossfuzz ) + if (OSSFUZZ) add_custom_target(ossfuzz_proto) add_dependencies(ossfuzz_proto yul_proto_ossfuzz yul_proto_diff_ossfuzz sol_proto_ossfuzz) @@ -49,6 +50,7 @@ if (OSSFUZZ) protobuf.a ) set_target_properties(yul_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + target_compile_options(yul_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion) add_executable(yul_proto_diff_ossfuzz yulProto_diff_ossfuzz.cpp yulFuzzerCommon.cpp protoToYul.cpp yulProto.pb.cc) target_include_directories(yul_proto_diff_ossfuzz PRIVATE /usr/include/libprotobuf-mutator) @@ -59,6 +61,7 @@ if (OSSFUZZ) protobuf.a ) set_target_properties(yul_proto_diff_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + target_compile_options(yul_proto_diff_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion) add_executable(abiv2_proto_ossfuzz ../../EVMHost.cpp @@ -78,6 +81,7 @@ if (OSSFUZZ) protobuf.a ) set_target_properties(abiv2_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + target_compile_options(abiv2_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion) add_executable(sol_proto_ossfuzz solProtoFuzzer.cpp @@ -97,6 +101,7 @@ if (OSSFUZZ) protobuf.a ) set_target_properties(sol_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + target_compile_options(sol_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion) else() add_library(solc_opt_ossfuzz solc_opt_ossfuzz.cpp From 88030c65683f1f425d6d577609f09691a27d7429 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 10 Jul 2020 10:28:49 +0200 Subject: [PATCH 22/71] [SMTChecker] Refactor verification targets --- libsolidity/formal/BMC.cpp | 30 +++--- libsolidity/formal/BMC.h | 6 +- libsolidity/formal/CHC.cpp | 141 +++++++++++++++++-------- libsolidity/formal/CHC.h | 31 +++++- libsolidity/formal/EncodingContext.cpp | 10 +- libsolidity/formal/EncodingContext.h | 8 +- libsolidity/formal/ModelChecker.cpp | 7 +- libsolidity/formal/SMTEncoder.cpp | 2 +- 8 files changed, 160 insertions(+), 75 deletions(-) diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index 8f74dbb3e..921c71ccf 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -52,11 +52,11 @@ BMC::BMC( #endif } -void BMC::analyze(SourceUnit const& _source, set _safeAssertions) +void BMC::analyze(SourceUnit const& _source, map> _solvedTargets) { solAssert(_source.annotation().experimentalFeatures.count(ExperimentalFeature::SMTChecker), ""); - m_safeAssertions += move(_safeAssertions); + m_solvedTargets = move(_solvedTargets); m_context.setSolver(m_interface.get()); m_context.clear(); m_context.setAssertionAccumulation(true); @@ -684,16 +684,22 @@ void BMC::checkBalance(BMCVerificationTarget& _target) void BMC::checkAssert(BMCVerificationTarget& _target) { solAssert(_target.type == VerificationTarget::Type::Assert, ""); - if (!m_safeAssertions.count(_target.expression)) - checkCondition( - _target.constraints && !_target.value, - _target.callStack, - _target.modelExpressions, - _target.expression->location(), - 4661_error, - 7812_error, - "Assertion violation" - ); + + if ( + m_solvedTargets.count(_target.expression) && + m_solvedTargets.at(_target.expression).count(_target.type) + ) + return; + + checkCondition( + _target.constraints && !_target.value, + _target.callStack, + _target.modelExpressions, + _target.expression->location(), + 4661_error, + 7812_error, + "Assertion violation" + ); } void BMC::addVerificationTarget( diff --git a/libsolidity/formal/BMC.h b/libsolidity/formal/BMC.h index 4f0a98023..2eed58101 100644 --- a/libsolidity/formal/BMC.h +++ b/libsolidity/formal/BMC.h @@ -63,7 +63,7 @@ public: smtutil::SMTSolverChoice _enabledSolvers ); - void analyze(SourceUnit const& _sources, std::set _safeAssertions); + void analyze(SourceUnit const& _sources, std::map> _solvedTargets); /// This is used if the SMT solver is not directly linked into this binary. /// @returns a list of inputs to the SMT solver that were not part of the argument to @@ -180,8 +180,8 @@ private: std::vector m_verificationTargets; - /// Assertions that are known to be safe. - std::set m_safeAssertions; + /// Targets that were already proven. + std::map> m_solvedTargets; }; } diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index c3e9d6cb4..336dfaa37 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -96,48 +96,7 @@ void CHC::analyze(SourceUnit const& _source) for (auto const* source: sources) source->accept(*this); - for (auto const& [scope, target]: m_verificationTargets) - { - if (target.type == VerificationTarget::Type::Assert) - { - auto assertions = transactionAssertions(scope); - for (auto const* assertion: assertions) - { - createErrorBlock(); - connectBlocks(target.value, error(), target.constraints && (target.errorId == static_cast(assertion->id()))); - auto [result, model] = query(error(), assertion->location()); - // This should be fine but it's a bug in the old compiler - (void)model; - if (result == smtutil::CheckResult::UNSATISFIABLE) - m_safeAssertions.insert(assertion); - } - } - else if (target.type == VerificationTarget::Type::PopEmptyArray) - { - solAssert(dynamic_cast(scope), ""); - createErrorBlock(); - connectBlocks(target.value, error(), target.constraints && (target.errorId == static_cast(scope->id()))); - auto [result, model] = query(error(), scope->location()); - // This should be fine but it's a bug in the old compiler - (void)model; - if (result != smtutil::CheckResult::UNSATISFIABLE) - { - string msg = "Empty array \"pop\" "; - if (result == smtutil::CheckResult::SATISFIABLE) - msg += "detected here."; - else - msg += "might happen here."; - m_unsafeTargets.insert(scope); - m_outerErrorReporter.warning( - 2529_error, - scope->location(), - msg - ); - } - } - else - solAssert(false, ""); - } + checkVerificationTargets(); } vector CHC::unhandledQueries() const @@ -540,7 +499,7 @@ void CHC::visitAssert(FunctionCall const& _funCall) m_currentBlock, m_currentFunction->isConstructor() ? summary(*m_currentContract) : summary(*m_currentFunction), currentPathConditions() && !m_context.expression(*args.front())->currentValue() && ( - m_error.currentValue() == static_cast(_funCall.id()) + m_error.currentValue() == newErrorId(_funCall) ) ); @@ -638,7 +597,7 @@ void CHC::makeArrayPopVerificationTarget(FunctionCall const& _arrayPop) connectBlocks( m_currentBlock, m_currentFunction->isConstructor() ? summary(*m_currentContract) : summary(*m_currentFunction), - currentPathConditions() && symbArray->length() <= 0 && m_error.currentValue() == static_cast(_arrayPop.id()) + currentPathConditions() && symbArray->length() <= 0 && m_error.currentValue() == newErrorId(_arrayPop) ); m_context.addAssertion(m_error.currentValue() == previousError); @@ -647,9 +606,10 @@ void CHC::makeArrayPopVerificationTarget(FunctionCall const& _arrayPop) void CHC::resetSourceAnalysis() { m_verificationTargets.clear(); - m_safeAssertions.clear(); + m_safeTargets.clear(); m_unsafeTargets.clear(); m_functionAssertions.clear(); + m_errorIds.clear(); m_callGraph.clear(); m_summaries.clear(); } @@ -1167,7 +1127,98 @@ void CHC::addArrayPopVerificationTarget(ASTNode const* _scope, smtutil::Expressi } } +void CHC::checkVerificationTargets() +{ + for (auto const& [scope, target]: m_verificationTargets) + { + if (target.type == VerificationTarget::Type::Assert) + checkAssertTarget(scope, target); + else + { + string satMsg; + string unknownMsg; + + if (target.type == VerificationTarget::Type::PopEmptyArray) + { + solAssert(dynamic_cast(scope), ""); + satMsg = "Empty array \"pop\" detected here."; + unknownMsg = "Empty array \"pop\" might happen here."; + } + else + solAssert(false, ""); + + auto it = m_errorIds.find(scope->id()); + solAssert(it != m_errorIds.end(), ""); + checkAndReportTarget(scope, target, it->second, satMsg, unknownMsg); + } + } +} + +void CHC::checkAssertTarget(ASTNode const* _scope, CHCVerificationTarget const& _target) +{ + solAssert(_target.type == VerificationTarget::Type::Assert, ""); + auto assertions = transactionAssertions(_scope); + for (auto const* assertion: assertions) + { + auto it = m_errorIds.find(assertion->id()); + solAssert(it != m_errorIds.end(), ""); + unsigned errorId = it->second; + + createErrorBlock(); + connectBlocks(_target.value, error(), _target.constraints && (_target.errorId == errorId)); + auto [result, model] = query(error(), assertion->location()); + // This should be fine but it's a bug in the old compiler + (void)model; + if (result == smtutil::CheckResult::UNSATISFIABLE) + m_safeTargets[assertion].insert(_target.type); + } +} + +void CHC::checkAndReportTarget( + ASTNode const* _scope, + CHCVerificationTarget const& _target, + unsigned _errorId, + string _satMsg, + string _unknownMsg +) +{ + createErrorBlock(); + connectBlocks(_target.value, error(), _target.constraints && (_target.errorId == _errorId)); + auto [result, model] = query(error(), _scope->location()); + // This should be fine but it's a bug in the old compiler + (void)model; + if (result == smtutil::CheckResult::UNSATISFIABLE) + m_safeTargets[_scope].insert(_target.type); + else if (result == smtutil::CheckResult::SATISFIABLE) + { + solAssert(!_satMsg.empty(), ""); + m_unsafeTargets[_scope].insert(_target.type); + m_outerErrorReporter.warning( + 2529_error, + _scope->location(), + _satMsg + ); + } + else if (!_unknownMsg.empty()) + m_outerErrorReporter.warning( + 1147_error, + _scope->location(), + _unknownMsg + ); +} + string CHC::uniquePrefix() { return to_string(m_blockCounter++); } + +unsigned CHC::newErrorId(frontend::Expression const& _expr) +{ + unsigned errorId = m_context.newUniqueId(); + // We need to make sure the error id is not zero, + // because error id zero actually means no error in the CHC encoding. + if (errorId == 0) + errorId = m_context.newUniqueId(); + m_errorIds.emplace(_expr.id(), errorId); + return errorId; +} diff --git a/libsolidity/formal/CHC.h b/libsolidity/formal/CHC.h index dcba90606..07af4c76b 100644 --- a/libsolidity/formal/CHC.h +++ b/libsolidity/formal/CHC.h @@ -36,6 +36,7 @@ #include +#include #include namespace solidity::frontend @@ -54,7 +55,8 @@ public: void analyze(SourceUnit const& _sources); - std::set const& safeAssertions() const { return m_safeAssertions; } + std::map> const& safeTargets() const { return m_safeTargets; } + std::map> const& unsafeTargets() const { return m_unsafeTargets; } /// This is used if the Horn solver is not directly linked into this binary. /// @returns a list of inputs to the Horn solver that were not part of the argument to @@ -191,6 +193,18 @@ private: void addVerificationTarget(ASTNode const* _scope, VerificationTarget::Type _type, smtutil::Expression _from, smtutil::Expression _constraints, smtutil::Expression _errorId); void addAssertVerificationTarget(ASTNode const* _scope, smtutil::Expression _from, smtutil::Expression _constraints, smtutil::Expression _errorId); void addArrayPopVerificationTarget(ASTNode const* _scope, smtutil::Expression _errorId); + + void checkVerificationTargets(); + // Forward declaration. Definition is below. + struct CHCVerificationTarget; + void checkAssertTarget(ASTNode const* _scope, CHCVerificationTarget const& _target); + void checkAndReportTarget( + ASTNode const* _scope, + CHCVerificationTarget const& _target, + unsigned _errorId, + std::string _satMsg, + std::string _unknownMsg + ); //@} /// Misc. @@ -198,6 +212,10 @@ private: /// Returns a prefix to be used in a new unique block name /// and increases the block counter. std::string uniquePrefix(); + + /// @returns a new unique error id associated with _expr and stores + /// it into m_errorIds. + unsigned newErrorId(Expression const& _expr); //@} /// Predicates. @@ -257,10 +275,10 @@ private: std::map m_verificationTargets; - /// Assertions proven safe. - std::set m_safeAssertions; + /// Targets proven safe. + std::map> m_safeTargets; /// Targets proven unsafe. - std::set m_unsafeTargets; + std::map> m_unsafeTargets; //@} /// Control-flow. @@ -271,6 +289,11 @@ private: std::map, IdCompare> m_functionAssertions; + /// Maps ASTNode ids to error ids. + /// A multimap is used instead of map anticipating the UnderOverflow + /// target which has 2 error ids. + std::multimap m_errorIds; + /// The current block. smtutil::Expression m_currentBlock = smtutil::Expression(true); diff --git a/libsolidity/formal/EncodingContext.cpp b/libsolidity/formal/EncodingContext.cpp index 57686ace4..b58160230 100644 --- a/libsolidity/formal/EncodingContext.cpp +++ b/libsolidity/formal/EncodingContext.cpp @@ -32,21 +32,21 @@ EncodingContext::EncodingContext(): void EncodingContext::reset() { resetAllVariables(); - resetSlackId(); + resetUniqueId(); m_expressions.clear(); m_globalContext.clear(); m_state.reset(); m_assertions.clear(); } -void EncodingContext::resetSlackId() +void EncodingContext::resetUniqueId() { - m_nextSlackId = 0; + m_nextUniqueId = 0; } -unsigned EncodingContext::newSlackId() +unsigned EncodingContext::newUniqueId() { - return m_nextSlackId++; + return m_nextUniqueId++; } void EncodingContext::clear() diff --git a/libsolidity/formal/EncodingContext.h b/libsolidity/formal/EncodingContext.h index fcfd5e149..09316709a 100644 --- a/libsolidity/formal/EncodingContext.h +++ b/libsolidity/formal/EncodingContext.h @@ -41,9 +41,9 @@ public: /// To be used in the beginning of a root function visit. void reset(); /// Resets the fresh id for slack variables. - void resetSlackId(); + void resetUniqueId(); /// Returns the current fresh slack id and increments it. - unsigned newSlackId(); + unsigned newUniqueId(); /// Clears the entire context, erasing everything. /// To be used before a model checking engine starts. void clear(); @@ -173,8 +173,8 @@ private: bool m_accumulateAssertions = true; //@} - /// Fresh ids for slack variables to be created deterministically. - unsigned m_nextSlackId = 0; + /// Central source of unique ids. + unsigned m_nextUniqueId = 0; }; } diff --git a/libsolidity/formal/ModelChecker.cpp b/libsolidity/formal/ModelChecker.cpp index f74e1327d..718a41ae1 100644 --- a/libsolidity/formal/ModelChecker.cpp +++ b/libsolidity/formal/ModelChecker.cpp @@ -41,7 +41,12 @@ void ModelChecker::analyze(SourceUnit const& _source) return; m_chc.analyze(_source); - m_bmc.analyze(_source, m_chc.safeAssertions()); + + auto solvedTargets = m_chc.safeTargets(); + for (auto const& target: m_chc.unsafeTargets()) + solvedTargets[target.first] += target.second; + + m_bmc.analyze(_source, solvedTargets); } vector ModelChecker::unhandledQueries() diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 6faaaf600..bd2a9a754 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -1262,7 +1262,7 @@ pair SMTEncoder::arithmeticOperation( auto symbMax = smt::maxValue(*intType); smtutil::Expression intValueRange = (0 - symbMin) + symbMax + 1; - string suffix = to_string(_operation.id()) + "_" + to_string(m_context.newSlackId()); + string suffix = to_string(_operation.id()) + "_" + to_string(m_context.newUniqueId()); smt::SymbolicIntVariable k(intType, intType, "k_" + suffix, m_context); smt::SymbolicIntVariable m(intType, intType, "m_" + suffix, m_context); From efc5ee207d9532ad5113d6db53ca3898667fa1e3 Mon Sep 17 00:00:00 2001 From: a3d4 Date: Mon, 6 Jul 2020 21:40:50 +0200 Subject: [PATCH 23/71] Fix internal compiler error caused by oversized objects --- Changelog.md | 1 + libsolidity/analysis/StaticAnalyzer.cpp | 67 ----------- libsolidity/analysis/StaticAnalyzer.h | 17 --- libsolidity/analysis/TypeChecker.cpp | 43 +++++++ libsolidity/ast/Types.cpp | 107 ++++++++++++++++++ libsolidity/ast/Types.h | 8 ++ .../large_storage_array_mapping.sol | 2 +- .../largeTypes/large_storage_structs.sol | 17 +-- .../largeTypes/oversized_array.sol | 8 ++ .../largeTypes/oversized_contract.sol | 10 ++ .../largeTypes/oversized_struct.sol | 12 ++ .../largeTypes/storage_parameter.sol | 6 + 12 files changed, 205 insertions(+), 93 deletions(-) create mode 100644 test/libsolidity/syntaxTests/largeTypes/oversized_array.sol create mode 100644 test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol create mode 100644 test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol create mode 100644 test/libsolidity/syntaxTests/largeTypes/storage_parameter.sol diff --git a/Changelog.md b/Changelog.md index 7b0a87a9a..1c8ffe171 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ Compiler Features: Bugfixes: * Type Checker: Fix overload resolution in combination with ``{value: ...}``. + * Type Checker: Fix internal compiler error related to oversized types. Compiler Features: * Optimizer: Add rule to remove shifts inside the byte opcode. diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index b650f1fc1..62a1861d1 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -155,29 +155,6 @@ bool StaticAnalyzer::visit(VariableDeclaration const& _variable) // This is not a no-op, the entry might pre-exist. m_localVarUseCount[make_pair(_variable.id(), &_variable)] += 0; } - else if (_variable.isStateVariable()) - { - set structsSeen; - TypeSet oversizedSubTypes; - if (structureSizeEstimate(*_variable.type(), structsSeen, oversizedSubTypes) >= bigint(1) << 64) - m_errorReporter.warning( - 3408_error, - _variable.location(), - "Variable " + util::escapeAndQuoteString(_variable.name()) + - " covers a large part of storage and thus makes collisions likely. " - "Either use mappings or dynamic arrays and allow their size to be increased only " - "in small quantities per transaction." - ); - for (Type const* type: oversizedSubTypes) - m_errorReporter.warning( - 7325_error, - _variable.location(), - "Type " + util::escapeAndQuoteString(type->canonicalName()) + - " has large size and thus makes collisions likely. " - "Either use mappings or dynamic arrays and allow their size to be increased only " - "in small quantities per transaction." - ); - } return true; } @@ -349,47 +326,3 @@ bool StaticAnalyzer::visit(FunctionCall const& _functionCall) } return true; } - -bigint StaticAnalyzer::structureSizeEstimate( - Type const& _type, - set& _structsSeen, - TypeSet& _oversizedSubTypes -) -{ - switch (_type.category()) - { - case Type::Category::Array: - { - auto const& t = dynamic_cast(_type); - bigint baseTypeSize = structureSizeEstimate(*t.baseType(), _structsSeen, _oversizedSubTypes); - if (baseTypeSize >= bigint(1) << 64) - _oversizedSubTypes.insert(t.baseType()); - if (!t.isDynamicallySized()) - return structureSizeEstimate(*t.baseType(), _structsSeen, _oversizedSubTypes) * t.length(); - break; - } - case Type::Category::Struct: - { - auto const& t = dynamic_cast(_type); - bigint size = 1; - if (_structsSeen.count(&t.structDefinition())) - return size; - _structsSeen.insert(&t.structDefinition()); - for (auto const& m: t.members(nullptr)) - size += structureSizeEstimate(*m.type, _structsSeen, _oversizedSubTypes); - _structsSeen.erase(&t.structDefinition()); - return size; - } - case Type::Category::Mapping: - { - auto const* valueType = dynamic_cast(_type).valueType(); - bigint valueTypeSize = structureSizeEstimate(*valueType, _structsSeen, _oversizedSubTypes); - if (valueTypeSize >= bigint(1) << 64) - _oversizedSubTypes.insert(valueType); - break; - } - default: - break; - } - return bigint(1); -} diff --git a/libsolidity/analysis/StaticAnalyzer.h b/libsolidity/analysis/StaticAnalyzer.h index 8f7fbc597..7886b4288 100644 --- a/libsolidity/analysis/StaticAnalyzer.h +++ b/libsolidity/analysis/StaticAnalyzer.h @@ -73,23 +73,6 @@ private: bool visit(BinaryOperation const& _operation) override; bool visit(FunctionCall const& _functionCall) override; - struct TypeComp - { - bool operator()(Type const* lhs, Type const* rhs) const - { - solAssert(lhs && rhs, ""); - return lhs->richIdentifier() < rhs->richIdentifier(); - } - }; - using TypeSet = std::set; - - /// @returns the size of this type in storage, including all sub-types. - static bigint structureSizeEstimate( - Type const& _type, - std::set& _structsSeen, - TypeSet& _oversizedSubTypes - ); - langutil::ErrorReporter& m_errorReporter; /// Flag that indicates whether the current contract definition is a library. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 6bb9dd39f..aa316cb48 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -91,6 +92,20 @@ bool TypeChecker::visit(ContractDefinition const& _contract) for (auto const& n: _contract.subNodes()) n->accept(*this); + bigint size = 0; + vector variables; + for (ContractDefinition const* contract: boost::adaptors::reverse(m_currentContract->annotation().linearizedBaseContracts)) + for (VariableDeclaration const* variable: contract->stateVariables()) + if (!(variable->isConstant() || variable->immutable())) + { + size += storageSizeUpperBound(*(variable->annotation().type)); + if (size >= bigint(1) << 256) + { + m_errorReporter.typeError(7676_error, m_currentContract->location(), "Contract too large for storage."); + break; + } + } + return false; } @@ -523,6 +538,10 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) m_errorReporter.typeError(6744_error, _variable.location(), "Internal or recursive type is not allowed for public state variables."); } + bool isStructMemberDeclaration = dynamic_cast(_variable.scope()) != nullptr; + if (isStructMemberDeclaration) + return false; + if (auto referenceType = dynamic_cast(varType)) { auto result = referenceType->validForLocation(referenceType->location()); @@ -532,9 +551,33 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) { solAssert(!result.message().empty(), "Expected detailed error message"); m_errorReporter.typeError(1534_error, _variable.location(), result.message()); + return false; } } + if (varType->dataStoredIn(DataLocation::Storage)) + { + auto collisionMessage = [&](string const& variableOrType, bool isVariable) -> string { + return + (isVariable ? "Variable " : "Type ") + + util::escapeAndQuoteString(variableOrType) + + " covers a large part of storage and thus makes collisions likely." + " Either use mappings or dynamic arrays and allow their size to be increased only" + " in small quantities per transaction."; + }; + + if (storageSizeUpperBound(*varType) >= bigint(1) << 64) + { + if (_variable.isStateVariable()) + m_errorReporter.warning(3408_error, _variable.location(), collisionMessage(_variable.name(), true)); + else + m_errorReporter.warning(2332_error, _variable.typeName()->location(), collisionMessage(varType->canonicalName(), false)); + } + vector oversizedSubtypes = frontend::oversizedSubtypes(*varType); + for (Type const* subtype: oversizedSubtypes) + m_errorReporter.warning(7325_error, _variable.typeName()->location(), collisionMessage(subtype->canonicalName(), false)); + } + return false; } diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 992f0343d..546e6ee63 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -53,6 +53,88 @@ using namespace solidity::frontend; namespace { +struct TypeComp +{ + bool operator()(Type const* lhs, Type const* rhs) const + { + solAssert(lhs && rhs, ""); + return lhs->richIdentifier() < rhs->richIdentifier(); + } +}; +using TypeSet = std::set; + +bigint storageSizeUpperBoundInner( + Type const& _type, + set& _structsSeen +) +{ + switch (_type.category()) + { + case Type::Category::Array: + { + auto const& t = dynamic_cast(_type); + if (!t.isDynamicallySized()) + return storageSizeUpperBoundInner(*t.baseType(), _structsSeen) * t.length(); + break; + } + case Type::Category::Struct: + { + auto const& t = dynamic_cast(_type); + solAssert(!_structsSeen.count(&t.structDefinition()), "Recursive struct."); + bigint size = 1; + _structsSeen.insert(&t.structDefinition()); + for (auto const& m: t.members(nullptr)) + size += storageSizeUpperBoundInner(*m.type, _structsSeen); + _structsSeen.erase(&t.structDefinition()); + return size; + } + default: + break; + } + return bigint(1); +} + +void oversizedSubtypesInner( + Type const& _type, + bool _includeType, + set& _structsSeen, + TypeSet& _oversizedSubtypes +) +{ + switch (_type.category()) + { + case Type::Category::Array: + { + auto const& t = dynamic_cast(_type); + if (_includeType && storageSizeUpperBound(t) >= bigint(1) << 64) + _oversizedSubtypes.insert(&t); + oversizedSubtypesInner(*t.baseType(), t.isDynamicallySized(), _structsSeen, _oversizedSubtypes); + break; + } + case Type::Category::Struct: + { + auto const& t = dynamic_cast(_type); + if (_structsSeen.count(&t.structDefinition())) + return; + if (_includeType && storageSizeUpperBound(t) >= bigint(1) << 64) + _oversizedSubtypes.insert(&t); + _structsSeen.insert(&t.structDefinition()); + for (auto const& m: t.members(nullptr)) + oversizedSubtypesInner(*m.type, false, _structsSeen, _oversizedSubtypes); + _structsSeen.erase(&t.structDefinition()); + break; + } + case Type::Category::Mapping: + { + auto const* valueType = dynamic_cast(_type).valueType(); + oversizedSubtypesInner(*valueType, true, _structsSeen, _oversizedSubtypes); + break; + } + default: + break; + } +} + /// Check whether (_base ** _exp) fits into 4096 bits. bool fitsPrecisionExp(bigint const& _base, bigint const& _exp) { @@ -149,6 +231,22 @@ util::Result transformParametersToExternal(TypePointers const& _pa } +bigint solidity::frontend::storageSizeUpperBound(frontend::Type const& _type) +{ + set structsSeen; + return storageSizeUpperBoundInner(_type, structsSeen); +} + +vector solidity::frontend::oversizedSubtypes(frontend::Type const& _type) +{ + set structsSeen; + TypeSet oversized; + oversizedSubtypesInner(_type, false, structsSeen, oversized); + vector res; + copy(oversized.cbegin(), oversized.cend(), back_inserter(res)); + return res; +} + void Type::clearCache() const { m_members.clear(); @@ -1749,6 +1847,8 @@ BoolResult ArrayType::validForLocation(DataLocation _loc) const break; } case DataLocation::Storage: + if (storageSizeUpperBound(*this) >= bigint(1) << 256) + return BoolResult::err("Type too large for storage."); break; } return true; @@ -2388,6 +2488,13 @@ BoolResult StructType::validForLocation(DataLocation _loc) const if (!result) return result; } + + if ( + _loc == DataLocation::Storage && + storageSizeUpperBound(*this) >= bigint(1) << 256 + ) + return BoolResult::err("Type too large for storage."); + return true; } diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index b902a1c77..b05021630 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -54,6 +54,14 @@ using rational = boost::rational; using TypeResult = util::Result; using BoolResult = util::Result; +} + +namespace solidity::frontend +{ + +bigint storageSizeUpperBound(frontend::Type const& _type); +std::vector oversizedSubtypes(frontend::Type const& _type); + inline rational makeRational(bigint const& _numerator, bigint const& _denominator) { solAssert(_denominator != 0, "division by zero"); diff --git a/test/libsolidity/syntaxTests/largeTypes/large_storage_array_mapping.sol b/test/libsolidity/syntaxTests/largeTypes/large_storage_array_mapping.sol index 01a68bcda..2dfc50a41 100644 --- a/test/libsolidity/syntaxTests/largeTypes/large_storage_array_mapping.sol +++ b/test/libsolidity/syntaxTests/largeTypes/large_storage_array_mapping.sol @@ -2,4 +2,4 @@ contract C { mapping(uint => uint[2**100]) x; } // ---- -// Warning 7325: (17-48): Type "uint256[1267650600228229401496703205376]" has large size and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (17-46): Type "uint256[1267650600228229401496703205376]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/largeTypes/large_storage_structs.sol b/test/libsolidity/syntaxTests/largeTypes/large_storage_structs.sol index 2956a6549..a29401d94 100644 --- a/test/libsolidity/syntaxTests/largeTypes/large_storage_structs.sol +++ b/test/libsolidity/syntaxTests/largeTypes/large_storage_structs.sol @@ -23,9 +23,9 @@ contract C { struct Q0 { - uint[1][][10**20 + 4] x; - uint[10**20 + 4][][1] y; - uint[][10**20 + 4] z; + uint[1][][10**20 + 1] x; + uint[10**20 + 2][][1] y; + uint[][10**20 + 3] z; uint[10**20 + 4][] t; } Q0 q0; @@ -57,11 +57,12 @@ contract C { // ---- // Warning 3408: (106-111): Variable "s0" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. // Warning 3408: (171-176): Variable "s1" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// Warning 7325: (341-346): Type "C.P[103]" has large size and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// Warning 7325: (341-346): Type "C.P[104]" has large size and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (341-343): Type "C.P[103]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (341-343): Type "C.P[104]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. // Warning 3408: (505-510): Variable "q0" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// Warning 7325: (505-510): Type "uint256[100000000000000000004]" has large size and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (505-507): Type "uint256[100000000000000000002]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (505-507): Type "uint256[100000000000000000004]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. // Warning 3408: (576-581): Variable "q1" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// Warning 7325: (647-652): Type "uint256[100000000000000000006]" has large size and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (647-649): Type "uint256[100000000000000000006]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. // Warning 3408: (715-720): Variable "q3" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// Warning 7325: (783-788): Type "uint256[100000000000000000008]" has large size and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 7325: (783-785): Type "uint256[100000000000000000008]" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol new file mode 100644 index 000000000..951840fd4 --- /dev/null +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >= 0.0; +contract C { + uint[2**255][2] a; +} +// ---- +// TypeError 1534: (77-94): Type too large for storage. +// TypeError 7676: (60-97): Contract too large for storage. diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol new file mode 100644 index 000000000..69f8b1024 --- /dev/null +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >= 0.0; +contract C { + uint[2**255] a; + uint[2**255] b; +} +// ---- +// Warning 3408: (77-91): Variable "a" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 3408: (97-111): Variable "b" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// TypeError 7676: (60-114): Contract too large for storage. diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol new file mode 100644 index 000000000..a3f3a4160 --- /dev/null +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >= 0.0; +contract C { + struct S { + uint[2**255] a; + uint[2**255] b; + } + S s; +} +// ---- +// TypeError 1534: (146-149): Type too large for storage. +// TypeError 7676: (60-152): Contract too large for storage. diff --git a/test/libsolidity/syntaxTests/largeTypes/storage_parameter.sol b/test/libsolidity/syntaxTests/largeTypes/storage_parameter.sol new file mode 100644 index 000000000..b32815028 --- /dev/null +++ b/test/libsolidity/syntaxTests/largeTypes/storage_parameter.sol @@ -0,0 +1,6 @@ +contract C { + struct S { uint256[2**255] x; } + function f(S storage) internal {} +} +// ---- +// Warning 2332: (64-65): Type "C.S" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. From f5ae9c57619ebfa4fff58209b6dc78a4e1b229aa Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 8 Jul 2020 23:25:13 +0100 Subject: [PATCH 24/71] Fix yulInterpreter to correctly handle i32.clz --- .../yulInterpreter/EwasmBuiltinInterpreter.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index b09fb5a87..440ffcd7a 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -51,8 +51,9 @@ void copyZeroExtended( _target[_targetOffset + i] = _sourceOffset + i < _source.size() ? _source[_sourceOffset + i] : 0; } -/// Count leading zeros for uint64 -uint64_t clz(uint64_t _v) +/// Count leading zeros for uint64. Following WebAssembly rules, it returns 64 for @a _v being zero. +/// NOTE: the clz builtin of the compiler may or may not do this +uint64_t clz64(uint64_t _v) { if (_v == 0) return 64; @@ -133,7 +134,11 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a accessMemory(arg[0], 4); return readMemoryHalfWord(arg[0]); } - + else if (_fun == "i32.clz"_yulstring) + // NOTE: the clz implementation assumes 64-bit inputs, hence the adjustment + return clz64(arg[0] & uint32_t(-1)) - 32; + else if (_fun == "i64.clz"_yulstring) + return clz64(arg[0]); string prefix = _fun.str(); string suffix; @@ -202,8 +207,6 @@ u256 EwasmBuiltinInterpreter::evalWasmBuiltin(string const& _fun, vector c return arg[0] != arg[1] ? 1 : 0; else if (_fun == "eqz") return arg[0] == 0 ? 1 : 0; - else if (_fun == "clz") - return clz(arg[0]); else if (_fun == "lt_u") return arg[0] < arg[1] ? 1 : 0; else if (_fun == "gt_u") From 0fd13b7a9ec00906df5658af0cd1f49fd2c0ebd7 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 10 Jul 2020 19:42:24 +0200 Subject: [PATCH 25/71] Upgrade json-cpp to 1.9.3. --- Changelog.md | 1 + cmake/jsoncpp.cmake | 7 ++++--- libsolutil/JSON.cpp | 4 ++-- scripts/create_source_tarball.sh | 2 +- scripts/release_ppa.sh | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1c8ffe171..e4310c339 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ Bugfixes: * Type Checker: Fix internal compiler error related to oversized types. Compiler Features: + * Build System: Update internal dependency of jsoncpp to 1.9.3. * Optimizer: Add rule to remove shifts inside the byte opcode. diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 1377041b9..80a16f8d5 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -37,15 +37,16 @@ endif() ExternalProject_Add(jsoncpp-project PREFIX "${prefix}" DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" - DOWNLOAD_NAME jsoncpp-1.9.2.tar.gz - URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.2.tar.gz - URL_HASH SHA256=77a402fb577b2e0e5d0bdc1cf9c65278915cdb25171e3452c68b6da8a561f8f0 + DOWNLOAD_NAME jsoncpp-1.9.3.tar.gz + URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz + URL_HASH SHA256=8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d CMAKE_COMMAND ${JSONCPP_CMAKE_COMMAND} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_INSTALL_LIBDIR=lib # Build static lib but suitable to be included in a shared lib. -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} + -DJSONCPP_WITH_EXAMPLE=OFF -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF -DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS} diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index c66aab9b2..609b9bb04 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -32,8 +32,8 @@ using namespace std; static_assert( - (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 2), - "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.2." + (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 3), + "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.3." ); namespace solidity::util diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index a4b4fbec1..d75650a53 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -31,7 +31,7 @@ REPO_ROOT="$(dirname "$0")"/.. fi # Add dependencies mkdir -p "$SOLDIR/deps/downloads/" 2>/dev/null || true - wget -O "$SOLDIR/deps/downloads/jsoncpp-1.9.2.tar.gz" https://github.com/open-source-parsers/jsoncpp/archive/1.9.2.tar.gz + wget -O "$SOLDIR/deps/downloads/jsoncpp-1.9.3.tar.gz" https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz mkdir -p "$REPO_ROOT/upload" tar --owner 0 --group 0 -czf "$REPO_ROOT/upload/solidity_$versionstring.tar.gz" -C "$TEMPDIR" "solidity_$versionstring" rm -r "$TEMPDIR" diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index 267346e41..d15f8d221 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -107,7 +107,7 @@ mv solidity solc # Fetch jsoncpp dependency mkdir -p ./solc/deps/downloads/ 2>/dev/null || true -wget -O ./solc/deps/downloads/jsoncpp-1.9.2.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/1.9.2.tar.gz +wget -O ./solc/deps/downloads/jsoncpp-1.9.3.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz # Determine version cd solc From 20dd66f398077a149116dd84652908f92d8321b9 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 10 Jul 2020 21:06:09 +0100 Subject: [PATCH 26/71] Fix missing quote in error message for invalid Yul types --- libyul/AsmAnalysis.cpp | 2 +- test/libyul/yulSyntaxTests/invalid_type2.yul | 2 +- test/libyul/yulSyntaxTests/user_defined_functions_fail.yul | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index f0ac3c242..315699153 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -234,7 +234,7 @@ void AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) m_errorReporter.typeError( 3947_error, variable.location, - "Assigning value of type \"" + givenType.str() + "\" to variable of type \"" + variable.type.str() + "." + "Assigning value of type \"" + givenType.str() + "\" to variable of type \"" + variable.type.str() + "\"." ); } } diff --git a/test/libyul/yulSyntaxTests/invalid_type2.yul b/test/libyul/yulSyntaxTests/invalid_type2.yul index 25320b055..2ad035dcf 100644 --- a/test/libyul/yulSyntaxTests/invalid_type2.yul +++ b/test/libyul/yulSyntaxTests/invalid_type2.yul @@ -5,4 +5,4 @@ // dialect: evmTyped // ---- // TypeError 5473: (15-28): "invalidType" is not a valid type (user defined types are not yet supported). -// TypeError 3947: (10-11): Assigning value of type "invalidType" to variable of type "u256. +// TypeError 3947: (10-11): Assigning value of type "invalidType" to variable of type "u256". diff --git a/test/libyul/yulSyntaxTests/user_defined_functions_fail.yul b/test/libyul/yulSyntaxTests/user_defined_functions_fail.yul index e81474613..7b8d012bb 100644 --- a/test/libyul/yulSyntaxTests/user_defined_functions_fail.yul +++ b/test/libyul/yulSyntaxTests/user_defined_functions_fail.yul @@ -8,5 +8,5 @@ // ==== // dialect: evmTyped // ---- -// TypeError 3947: (126-127): Assigning value of type "bool" to variable of type "u256. -// TypeError 3947: (129-136): Assigning value of type "u256" to variable of type "bool. +// TypeError 3947: (126-127): Assigning value of type "bool" to variable of type "u256". +// TypeError 3947: (129-136): Assigning value of type "u256" to variable of type "bool". From c8f25142a72e153297ff88e430674c95cf3697c0 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 10 Jul 2020 11:22:57 +0200 Subject: [PATCH 27/71] Add nooptions label to smt checks. --- test/InteractiveTests.h | 5 +++-- test/boostTest.cpp | 10 ++++++++-- test/libsolidity/SMTChecker.cpp | 4 ++-- test/libsolidity/SMTCheckerTest.cpp | 2 +- test/libsolidity/SMTCheckerTest.h | 4 ++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/test/InteractiveTests.h b/test/InteractiveTests.h index 409d8607d..4e8365796 100644 --- a/test/InteractiveTests.h +++ b/test/InteractiveTests.h @@ -46,6 +46,7 @@ struct Testsuite bool smt; bool needsVM; TestCase::TestCaseCreator testCaseCreator; + std::vector labels{}; }; @@ -64,8 +65,8 @@ Testsuite const g_interactiveTestsuites[] = { {"Semantic", "libsolidity", "semanticTests", false, true, &SemanticTest::create}, {"JSON AST", "libsolidity", "ASTJSON", false, false, &ASTJSONTest::create}, {"JSON ABI", "libsolidity", "ABIJson", false, false, &ABIJsonTest::create}, - {"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SMTCheckerTest::create}, - {"SMT Checker JSON", "libsolidity", "smtCheckerTestsJSON", true, false, &SMTCheckerJSONTest::create}, + {"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SMTCheckerTest::create, {"nooptions"}}, + {"SMT Checker JSON", "libsolidity", "smtCheckerTestsJSON", true, false, &SMTCheckerJSONTest::create, {"nooptions"}}, {"Gas Estimates", "libsolidity", "gasTests", false, false, &GasTest::create} }; diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 5b45cc758..19cdfc423 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -65,6 +65,7 @@ int registerTests( boost::filesystem::path const& _basepath, boost::filesystem::path const& _path, bool _enforceViaYul, + vector const& _labels, TestCase::TestCaseCreator _testCaseCreator ) { @@ -83,6 +84,7 @@ int registerTests( *sub_suite, _basepath, _path / entry.path().filename(), _enforceViaYul, + _labels, _testCaseCreator ); _suite.add(sub_suite); @@ -95,7 +97,7 @@ int registerTests( static vector> filenames; filenames.emplace_back(make_unique(_path.string())); - _suite.add(make_test_case( + auto test_case = make_test_case( [config, _testCaseCreator] { BOOST_REQUIRE_NO_THROW({ @@ -125,7 +127,10 @@ int registerTests( _path.stem().string(), *filenames.back(), 0 - )); + ); + for (auto const& _label: _labels) + test_case->add_label(_label); + _suite.add(test_case); numTestsAdded = 1; } return numTestsAdded; @@ -174,6 +179,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) options.testPath / ts.path, ts.subpath, options.enforceViaYul, + ts.labels, ts.testCaseCreator ) > 0, std::string("no ") + ts.title + " tests found"); } diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 66398381e..a7347a21a 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -55,7 +55,7 @@ protected: BOOST_FIXTURE_TEST_SUITE(SMTChecker, SMTCheckerFramework) -BOOST_AUTO_TEST_CASE(import_base) +BOOST_AUTO_TEST_CASE(import_base, *boost::unit_test::label("no_options")) { CompilerStack c; c.setSources({ @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(import_base) BOOST_CHECK_EQUAL(asserts, 1); } -BOOST_AUTO_TEST_CASE(import_library) +BOOST_AUTO_TEST_CASE(import_library, *boost::unit_test::label("no_options")) { CompilerStack c; c.setSources({ diff --git a/test/libsolidity/SMTCheckerTest.cpp b/test/libsolidity/SMTCheckerTest.cpp index 7daa6f182..ac858747d 100644 --- a/test/libsolidity/SMTCheckerTest.cpp +++ b/test/libsolidity/SMTCheckerTest.cpp @@ -26,7 +26,7 @@ using namespace solidity::langutil; using namespace solidity::frontend; using namespace solidity::frontend::test; -SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion _evmVersion): SyntaxTest(_filename, _evmVersion) +SMTCheckerTest::SMTCheckerTest(string const& _filename): SyntaxTest(_filename, EVMVersion{}) { auto const& choice = m_reader.stringSetting("SMTSolvers", "any"); if (choice == "any") diff --git a/test/libsolidity/SMTCheckerTest.h b/test/libsolidity/SMTCheckerTest.h index 34f526cd9..b710cde45 100644 --- a/test/libsolidity/SMTCheckerTest.h +++ b/test/libsolidity/SMTCheckerTest.h @@ -31,9 +31,9 @@ class SMTCheckerTest: public SyntaxTest public: static std::unique_ptr create(Config const& _config) { - return std::make_unique(_config.filename, _config.evmVersion); + return std::make_unique(_config.filename); } - SMTCheckerTest(std::string const& _filename, langutil::EVMVersion _evmVersion); + SMTCheckerTest(std::string const& _filename); TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override; From 87557896ed8bf88f5860629f73c332cfdb5bd4ed Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 11 Dec 2019 13:23:43 +0000 Subject: [PATCH 28/71] Add ctz and popcnt to WasmDialect --- Changelog.md | 3 +++ libyul/backends/wasm/WasmDialect.cpp | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index e4310c339..a63b80697 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ ### 0.6.12 (unreleased) +Language Features: + * Wasm backend: Add ``i32.ctz``, ``i64.ctz``, ``i32.popcnt``, and ``i64.popcnt``. + Compiler Features: * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. diff --git a/libyul/backends/wasm/WasmDialect.cpp b/libyul/backends/wasm/WasmDialect.cpp index 39138dfb2..9dddddd69 100644 --- a/libyul/backends/wasm/WasmDialect.cpp +++ b/libyul/backends/wasm/WasmDialect.cpp @@ -38,13 +38,18 @@ WasmDialect::WasmDialect() "add", "sub", "mul", + // TODO: div_s "div_u", + // TODO: rem_s "rem_u", "and", "or", "xor", "shl", + // TODO: shr_s "shr_u", + // TODO: rotl + // TODO: rotr }) addFunction(t.str() + "." + name, {t, t}, {t}); @@ -52,9 +57,13 @@ WasmDialect::WasmDialect() for (auto const& name: { "eq", "ne", + // TODO: lt_s "lt_u", + // TODO: gt_s "gt_u", + // TODO: le_s "le_u", + // TODO: ge_s "ge_u" }) addFunction(t.str() + "." + name, {t, t}, {i32}); @@ -62,8 +71,13 @@ WasmDialect::WasmDialect() addFunction("i32.eqz", {i32}, {i32}); addFunction("i64.eqz", {i64}, {i32}); - addFunction("i32.clz", {i32}, {i32}); - addFunction("i64.clz", {i64}, {i64}); + for (auto t: types) + for (auto const& name: { + "clz", + "ctz", + "popcnt", + }) + addFunction(t.str() + "." + name, {t}, {t}); addFunction("i32.wrap_i64", {i64}, {i32}); @@ -73,6 +87,7 @@ WasmDialect::WasmDialect() m_functions["i32.store"_yulstring].sideEffects.invalidatesStorage = false; addFunction("i64.store", {i32, i64}, {}, false); m_functions["i64.store"_yulstring].sideEffects.invalidatesStorage = false; + // TODO: add i32.store16, i64.store8, i64.store16, i64.store32 addFunction("i32.store8", {i32, i32}, {}, false); m_functions["i32.store8"_yulstring].sideEffects.invalidatesStorage = false; @@ -89,6 +104,7 @@ WasmDialect::WasmDialect() m_functions["i64.load"_yulstring].sideEffects.invalidatesMemory = false; m_functions["i64.load"_yulstring].sideEffects.sideEffectFree = true; m_functions["i64.load"_yulstring].sideEffects.sideEffectFreeIfNoMSize = true; + // TODO: add i32.load8, i32.load16, i64.load8, i64.load16, i64.load32 // Drop is actually overloaded for all types, but Yul does not support that. // Because of that, we introduce "i32.drop" and "i64.drop". From 8df4baac4292d72cc1fffd4851cb3c5e4c248d28 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 8 Jul 2020 23:16:43 +0100 Subject: [PATCH 29/71] Implement ctz/popcnt in yulInterpreter --- .../EwasmBuiltinInterpreter.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index 440ffcd7a..5ad07c5bb 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -67,6 +67,50 @@ uint64_t clz64(uint64_t _v) return r; } +/// Count trailing zeros for uint32. Following WebAssembly rules, it returns 32 for @a _v being zero. +/// NOTE: the ctz builtin of the compiler may or may not do this +uint32_t ctz32(uint32_t _v) +{ + if (_v == 0) + return 32; + + uint32_t r = 0; + while (!(_v & 1)) + { + r++; + _v >>= 1; + } + return r; +} + +/// Count trailing zeros for uint64. Following WebAssembly rules, it returns 64 for @a _v being zero. +/// NOTE: the ctz builtin of the compiler may or may not do this +uint64_t ctz64(uint64_t _v) +{ + if (_v == 0) + return 64; + + uint64_t r = 0; + while (!(_v & 1)) + { + r++; + _v >>= 1; + } + return r; +} + +/// Count number of bits set for uint64 +uint64_t popcnt(uint64_t _v) +{ + uint64_t r = 0; + while (_v) + { + r += (_v & 1); + _v >>= 1; + } + return r; +} + } using u512 = boost::multiprecision::number>; @@ -139,6 +183,10 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a return clz64(arg[0] & uint32_t(-1)) - 32; else if (_fun == "i64.clz"_yulstring) return clz64(arg[0]); + else if (_fun == "i32.ctz"_yulstring) + return ctz32(uint32_t(arg[0] & uint32_t(-1))); + else if (_fun == "i64.ctz"_yulstring) + return ctz64(arg[0]); string prefix = _fun.str(); string suffix; @@ -207,6 +255,8 @@ u256 EwasmBuiltinInterpreter::evalWasmBuiltin(string const& _fun, vector c return arg[0] != arg[1] ? 1 : 0; else if (_fun == "eqz") return arg[0] == 0 ? 1 : 0; + else if (_fun == "popcnt") + return popcnt(arg[0]); else if (_fun == "lt_u") return arg[0] < arg[1] ? 1 : 0; else if (_fun == "gt_u") From a72b0deea6b637d44f97350e42422dd5654abdbe Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Mon, 13 Jul 2020 14:01:53 +0200 Subject: [PATCH 30/71] Disabling -Wsign-conversion for yul_proto_diff_custom_mutate_ossfuzz target --- test/tools/ossfuzz/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/tools/ossfuzz/CMakeLists.txt b/test/tools/ossfuzz/CMakeLists.txt index 419b2021e..9ad7b9c80 100644 --- a/test/tools/ossfuzz/CMakeLists.txt +++ b/test/tools/ossfuzz/CMakeLists.txt @@ -83,6 +83,7 @@ if (OSSFUZZ) protobuf.a ) set_target_properties(yul_proto_diff_custom_mutate_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) + target_compile_options(yul_proto_diff_custom_mutate_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion) add_executable(abiv2_proto_ossfuzz ../../EVMHost.cpp From 080f33a72c31b07e185e04088873285fcf2db1db Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 13 Jul 2020 11:16:30 +0200 Subject: [PATCH 31/71] Remove swap after dup. --- Changelog.md | 1 + libevmasm/PeepholeOptimiser.cpp | 26 +++++++++- test/cmdlineTests/dup_opt_peephole/args | 1 + test/cmdlineTests/dup_opt_peephole/err | 5 ++ test/cmdlineTests/dup_opt_peephole/input.sol | 9 ++++ test/cmdlineTests/dup_opt_peephole/output | 54 ++++++++++++++++++++ 6 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 test/cmdlineTests/dup_opt_peephole/args create mode 100644 test/cmdlineTests/dup_opt_peephole/err create mode 100644 test/cmdlineTests/dup_opt_peephole/input.sol create mode 100644 test/cmdlineTests/dup_opt_peephole/output diff --git a/Changelog.md b/Changelog.md index e4310c339..f82e99119 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ Bugfixes: Compiler Features: * Build System: Update internal dependency of jsoncpp to 1.9.3. * Optimizer: Add rule to remove shifts inside the byte opcode. + * Peephole Optimizer: Add rule to remove swap after dup. ### 0.6.11 (2020-07-07) diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp index 861cae0f2..343f2f824 100644 --- a/libevmasm/PeepholeOptimiser.cpp +++ b/libevmasm/PeepholeOptimiser.cpp @@ -205,6 +205,30 @@ struct SwapComparison: SimplePeepholeOptimizerMethod } }; +/// Remove swapN after dupN +struct DupSwap: SimplePeepholeOptimizerMethod +{ + static size_t applySimple( + AssemblyItem const& _dupN, + AssemblyItem const& _swapN, + std::back_insert_iterator _out + ) + { + if ( + SemanticInformation::isDupInstruction(_dupN) && + SemanticInformation::isSwapInstruction(_swapN) && + getDupNumber(_dupN.instruction()) == getSwapNumber(_swapN.instruction()) + ) + { + *_out = _dupN; + return true; + } + else + return false; + } +}; + + struct IsZeroIsZeroJumpI: SimplePeepholeOptimizerMethod { static size_t applySimple( @@ -357,7 +381,7 @@ bool PeepholeOptimiser::optimise() applyMethods( state, PushPop(), OpPop(), DoublePush(), DoubleSwap(), CommutativeSwap(), SwapComparison(), - IsZeroIsZeroJumpI(), JumpToNext(), UnreachableCode(), + DupSwap(), IsZeroIsZeroJumpI(), JumpToNext(), UnreachableCode(), TagConjunctions(), TruthyAnd(), Identity() ); if (m_optimisedItems.size() < m_items.size() || ( diff --git a/test/cmdlineTests/dup_opt_peephole/args b/test/cmdlineTests/dup_opt_peephole/args new file mode 100644 index 000000000..d3047670e --- /dev/null +++ b/test/cmdlineTests/dup_opt_peephole/args @@ -0,0 +1 @@ +--asm \ No newline at end of file diff --git a/test/cmdlineTests/dup_opt_peephole/err b/test/cmdlineTests/dup_opt_peephole/err new file mode 100644 index 000000000..cfaa88dcf --- /dev/null +++ b/test/cmdlineTests/dup_opt_peephole/err @@ -0,0 +1,5 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> dup_opt_peephole/input.sol + +Warning: Source file does not specify required compiler version! +--> dup_opt_peephole/input.sol diff --git a/test/cmdlineTests/dup_opt_peephole/input.sol b/test/cmdlineTests/dup_opt_peephole/input.sol new file mode 100644 index 000000000..1474a8f44 --- /dev/null +++ b/test/cmdlineTests/dup_opt_peephole/input.sol @@ -0,0 +1,9 @@ +contract C { + fallback() external { + assembly { + let x := calldataload(0) + x := x + sstore(0, x) + } + } +} diff --git a/test/cmdlineTests/dup_opt_peephole/output b/test/cmdlineTests/dup_opt_peephole/output new file mode 100644 index 000000000..020260c2b --- /dev/null +++ b/test/cmdlineTests/dup_opt_peephole/output @@ -0,0 +1,54 @@ + +======= dup_opt_peephole/input.sol:C ======= +EVM assembly: + /* "dup_opt_peephole/input.sol":0:111 contract C {... */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + /* "dup_opt_peephole/input.sol":0:111 contract C {... */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_3 + jumpi + 0x00 + dup1 + revert + tag_3: + pop + /* "dup_opt_peephole/input.sol":74:75 0 */ + 0x00 + /* "dup_opt_peephole/input.sol":61:76 calldataload(0) */ + calldataload + /* "dup_opt_peephole/input.sol":100:101 x */ + dup1 + /* "dup_opt_peephole/input.sol":97:98 0 */ + 0x00 + /* "dup_opt_peephole/input.sol":90:102 sstore(0, x) */ + sstore + /* "dup_opt_peephole/input.sol":47:106 {... */ + pop + /* "dup_opt_peephole/input.sol":0:111 contract C {... */ + stop + + auxdata: AUXDATA REMOVED +} From def0ebbb3e4a8eeb68d2e29155778eb7ede59188 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 10 Jul 2020 17:39:23 +0200 Subject: [PATCH 32/71] Free variables directly after visiting RHS of Variable Declarations during EVMCodeTransform. --- Changelog.md | 1 + libyul/backends/evm/EVMCodeTransform.cpp | 14 +++--- libyul/backends/evm/EVMCodeTransform.h | 5 +- test/libyul/StackReuseCodegen.cpp | 63 ++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/Changelog.md b/Changelog.md index e140ebea5..047b06ddf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Language Features: Compiler Features: * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. * Peephole Optimizer: Remove unnecessary masking of tags. + * Yul EVM Code Transform: Free stack slots directly after visiting the right-hand-side of variable declarations instead of at the end of the statement only. Bugfixes: * Type Checker: Fix overload resolution in combination with ``{value: ...}``. diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 6b0f06e01..041e00380 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -141,7 +141,7 @@ bool CodeTransform::unreferenced(Scope::Variable const& _var) const return !m_context->variableReferences.count(&_var) || m_context->variableReferences[&_var] == 0; } -void CodeTransform::freeUnusedVariables() +void CodeTransform::freeUnusedVariables(bool _popUnusedSlotsAtStackTop) { if (!m_allowStackOpt) return; @@ -154,11 +154,12 @@ void CodeTransform::freeUnusedVariables() deleteVariable(var); } - while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1)) - { - yulAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), ""); - m_assembly.appendInstruction(evmasm::Instruction::POP); - } + if (_popUnusedSlotsAtStackTop) + while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1)) + { + yulAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), ""); + m_assembly.appendInstruction(evmasm::Instruction::POP); + } } void CodeTransform::deleteVariable(Scope::Variable const& _var) @@ -181,6 +182,7 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) { std::visit(*this, *_varDecl.value); expectDeposit(static_cast(numVariables), static_cast(heightAtStart)); + freeUnusedVariables(false); } else { diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index 3c9506b47..1cfa6afd7 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -161,8 +161,9 @@ protected: bool unreferenced(Scope::Variable const& _var) const; /// Marks slots of variables that are not used anymore /// and were defined in the current scope for reuse. - /// Also POPs unused topmost stack slots. - void freeUnusedVariables(); + /// Also POPs unused topmost stack slots, + /// unless @a _popUnusedSlotsAtStackTop is set to false. + void freeUnusedVariables(bool _popUnusedSlotsAtStackTop = true); /// Marks the stack slot of @a _var to be reused. void deleteVariable(Scope::Variable const& _var); diff --git a/test/libyul/StackReuseCodegen.cpp b/test/libyul/StackReuseCodegen.cpp index eec882e8c..1b6b91657 100644 --- a/test/libyul/StackReuseCodegen.cpp +++ b/test/libyul/StackReuseCodegen.cpp @@ -345,6 +345,69 @@ BOOST_AUTO_TEST_CASE(reuse_slots_function_with_gaps) ); } +BOOST_AUTO_TEST_CASE(reuse_on_decl_assign_to_last_used) +{ + string in = R"({ + let x := 5 + let y := x // y should reuse the stack slot of x + sstore(y, y) + })"; + BOOST_CHECK_EQUAL(assemble(in), + "PUSH1 0x5 " + "DUP1 SWAP1 POP " + "DUP1 DUP2 SSTORE " + "POP " + ); +} + +BOOST_AUTO_TEST_CASE(reuse_on_decl_assign_to_last_used_expr) +{ + string in = R"({ + let x := 5 + let y := add(x, 2) // y should reuse the stack slot of x + sstore(y, y) + })"; + BOOST_CHECK_EQUAL(assemble(in), + "PUSH1 0x5 " + "PUSH1 0x2 DUP2 ADD " + "SWAP1 POP " + "DUP1 DUP2 SSTORE " + "POP " + ); +} + +BOOST_AUTO_TEST_CASE(reuse_on_decl_assign_to_not_last_used) +{ + string in = R"({ + let x := 5 + let y := x // y should not reuse the stack slot of x, since x is still used below + sstore(y, x) + })"; + BOOST_CHECK_EQUAL(assemble(in), + "PUSH1 0x5 " + "DUP1 " + "DUP2 DUP2 SSTORE " + "POP POP " + ); +} + +BOOST_AUTO_TEST_CASE(reuse_on_decl_assign_not_same_scope) +{ + string in = R"({ + let x := 5 + { + let y := x // y should not reuse the stack slot of x, since x is not in the same scope + sstore(y, y) + } + })"; + BOOST_CHECK_EQUAL(assemble(in), + "PUSH1 0x5 " + "DUP1 " + "DUP1 DUP2 SSTORE " + "POP POP " + ); +} + BOOST_AUTO_TEST_SUITE_END() From 870ea98c21d4b0d6b3eea67a1ce37753610b8817 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 13 Jul 2020 15:20:29 +0100 Subject: [PATCH 33/71] Prefix EIP-615 opcodes with EIP615 in Instructions --- libevmasm/Instruction.h | 20 ++++++++--------- libyul/backends/evm/EVMAssembly.cpp | 10 ++++----- .../EVMInstructionInterpreter.cpp | 22 +++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 511e3cf1b..67a77f0c9 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -174,16 +174,16 @@ enum class Instruction: uint8_t LOG3, ///< Makes a log entry; 3 topics. LOG4, ///< Makes a log entry; 4 topics. - JUMPTO = 0xb0, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp - JUMPIF, ///< conditionally alter the program counter -- not part of Instructions.cpp - JUMPV, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp - JUMPSUB, ///< alter the program counter to a beginsub -- not part of Instructions.cpp - JUMPSUBV, ///< alter the program counter to a beginsub -- not part of Instructions.cpp - BEGINSUB, ///< set a potential jumpsub destination -- not part of Instructions.cpp - BEGINDATA, ///< begin the data section -- not part of Instructions.cpp - RETURNSUB, ///< return to subroutine jumped from -- not part of Instructions.cpp - PUTLOCAL, ///< pop top of stack to local variable -- not part of Instructions.cpp - GETLOCAL, ///< push local variable to top of stack -- not part of Instructions.cpp + EIP615_JUMPTO = 0xb0, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp + EIP615_JUMPIF, ///< conditionally alter the program counter -- not part of Instructions.cpp + EIP615_JUMPV, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp + EIP615_JUMPSUB, ///< alter the program counter to a beginsub -- not part of Instructions.cpp + EIP615_JUMPSUBV, ///< alter the program counter to a beginsub -- not part of Instructions.cpp + EIP615_BEGINSUB, ///< set a potential jumpsub destination -- not part of Instructions.cpp + EIP615_BEGINDATA, ///< begin the data section -- not part of Instructions.cpp + EIP615_RETURNSUB, ///< return to subroutine jumped from -- not part of Instructions.cpp + EIP615_PUTLOCAL, ///< pop top of stack to local variable -- not part of Instructions.cpp + EIP615_GETLOCAL, ///< push local variable to top of stack -- not part of Instructions.cpp CREATE = 0xf0, ///< create a new account with associated code CALL, ///< message-call into an account diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 73194ef8a..7cf3d0662 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -102,7 +102,7 @@ void EVMAssembly::appendJumpTo(LabelID _labelId, int _stackDiffAfter, JumpType _ { if (m_evm15) { - m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPTO)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::EIP615_JUMPTO)); appendLabelReferenceInternal(_labelId); m_stackHeight += _stackDiffAfter; } @@ -117,7 +117,7 @@ void EVMAssembly::appendJumpToIf(LabelID _labelId, JumpType) { if (m_evm15) { - m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPIF)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::EIP615_JUMPIF)); appendLabelReferenceInternal(_labelId); m_stackHeight--; } @@ -133,7 +133,7 @@ void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments) yulAssert(m_evm15, "BEGINSUB used for EVM 1.0"); yulAssert(_arguments >= 0, ""); setLabelToCurrentPosition(_labelId); - m_bytecode.push_back(uint8_t(evmasm::Instruction::BEGINSUB)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::EIP615_BEGINSUB)); m_stackHeight += _arguments; } @@ -141,7 +141,7 @@ void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns) { yulAssert(m_evm15, "JUMPSUB used for EVM 1.0"); yulAssert(_arguments >= 0 && _returns >= 0, ""); - m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPSUB)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::EIP615_JUMPSUB)); appendLabelReferenceInternal(_labelId); m_stackHeight += _returns - _arguments; } @@ -150,7 +150,7 @@ void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter) { yulAssert(m_evm15, "RETURNSUB used for EVM 1.0"); yulAssert(_returns >= 0, ""); - m_bytecode.push_back(uint8_t(evmasm::Instruction::RETURNSUB)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::EIP615_RETURNSUB)); m_stackHeight += _stackDiffAfter - _returns; } diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index c17fa33e8..956db124f 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -409,17 +409,17 @@ u256 EVMInstructionInterpreter::eval( case Instruction::SWAP14: case Instruction::SWAP15: case Instruction::SWAP16: - // --------------- EVM 2.0 --------------- - case Instruction::JUMPTO: - case Instruction::JUMPIF: - case Instruction::JUMPV: - case Instruction::JUMPSUB: - case Instruction::JUMPSUBV: - case Instruction::BEGINSUB: - case Instruction::BEGINDATA: - case Instruction::RETURNSUB: - case Instruction::PUTLOCAL: - case Instruction::GETLOCAL: + // --------------- EIP-615 --------------- + case Instruction::EIP615_JUMPTO: + case Instruction::EIP615_JUMPIF: + case Instruction::EIP615_JUMPV: + case Instruction::EIP615_JUMPSUB: + case Instruction::EIP615_JUMPSUBV: + case Instruction::EIP615_BEGINSUB: + case Instruction::EIP615_BEGINDATA: + case Instruction::EIP615_RETURNSUB: + case Instruction::EIP615_PUTLOCAL: + case Instruction::EIP615_GETLOCAL: { yulAssert(false, ""); return 0; From 6a1ad7e59ceccd8a56a17d2af3e1025a321eb079 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 13 Jul 2020 19:05:34 +0100 Subject: [PATCH 34/71] Fix formatting hex strings in isoltest update --- test/libsolidity/util/BytesUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/libsolidity/util/BytesUtils.cpp b/test/libsolidity/util/BytesUtils.cpp index fd2cd2fcf..7416ca9a2 100644 --- a/test/libsolidity/util/BytesUtils.cpp +++ b/test/libsolidity/util/BytesUtils.cpp @@ -22,6 +22,7 @@ #include +#include #include #include @@ -198,8 +199,7 @@ string BytesUtils::formatString(bytes const& _bytes, size_t _cutOff) if (isprint(v)) os << v; else - os << "\\x" << setw(2) << setfill('0') << hex << v; - + os << "\\x" << toHex(v); } } os << "\""; From 950612cf42b3812e5ad292d9f6e3a56f96b8f0f4 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 13 Jul 2020 18:23:42 +0100 Subject: [PATCH 35/71] Add more tests for strings with unicode (escapes) --- .../semanticTests/strings/unicode_escapes.sol | 22 +++++++++++++++++++ .../semanticTests/strings/unicode_string.sol | 7 ++++++ .../invalid_utf8_explicit_string.sol} | 0 .../string/invalid_utf8_hex_string.sol | 5 +++++ .../invalid_utf8_implicit_string.sol} | 0 .../string/invalid_utf8_in_bytes.sol | 6 +++++ .../large_utf8_codepoint.sol} | 0 .../syntaxTests/string/string_unicode.sol | 6 +++++ .../{ => string}/unicode_escape_literals.sol | 12 +--------- ...code_escape_literals_invalid_codepoint.sol | 7 ++++++ ...unicode_escape_literals_invalid_format.sol | 10 +++++++++ 11 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 test/libsolidity/semanticTests/strings/unicode_escapes.sol create mode 100644 test/libsolidity/semanticTests/strings/unicode_string.sol rename test/libsolidity/syntaxTests/{nameAndTypeResolution/186_invalid_utf8_explicit.sol => string/invalid_utf8_explicit_string.sol} (100%) create mode 100644 test/libsolidity/syntaxTests/string/invalid_utf8_hex_string.sol rename test/libsolidity/syntaxTests/{nameAndTypeResolution/185_invalid_utf8_implicit.sol => string/invalid_utf8_implicit_string.sol} (100%) create mode 100644 test/libsolidity/syntaxTests/string/invalid_utf8_in_bytes.sol rename test/libsolidity/syntaxTests/{nameAndTypeResolution/187_large_utf8_codepoint.sol => string/large_utf8_codepoint.sol} (100%) create mode 100644 test/libsolidity/syntaxTests/string/string_unicode.sol rename test/libsolidity/syntaxTests/{ => string}/unicode_escape_literals.sol (60%) create mode 100644 test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_codepoint.sol create mode 100644 test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_format.sol diff --git a/test/libsolidity/semanticTests/strings/unicode_escapes.sol b/test/libsolidity/semanticTests/strings/unicode_escapes.sol new file mode 100644 index 000000000..401d8b61e --- /dev/null +++ b/test/libsolidity/semanticTests/strings/unicode_escapes.sol @@ -0,0 +1,22 @@ +contract C { + function oneByteUTF8() public pure returns (string memory) { + return "aaa\u0024aaa"; // usdollar + } + + function twoBytesUTF8() public pure returns (string memory) { + return "aaa\u00A2aaa"; // cent + } + + function threeBytesUTF8() public pure returns (string memory) { + return "aaa\u20ACaaa"; // euro + } + + function combined() public pure returns (string memory) { + return "\u0024\u00A2\u20AC"; + } +} +// ---- +// oneByteUTF8() -> 0x20, 7, "aaa$aaa" +// twoBytesUTF8() -> 0x20, 8, "aaa\xc2\xa2aaa" +// threeBytesUTF8() -> 0x20, 9, "aaa\xe2\x82\xacaaa" +// combined() -> 0x20, 6, "$\xc2\xa2\xe2\x82\xac" diff --git a/test/libsolidity/semanticTests/strings/unicode_string.sol b/test/libsolidity/semanticTests/strings/unicode_string.sol new file mode 100644 index 000000000..c139d6b8b --- /dev/null +++ b/test/libsolidity/semanticTests/strings/unicode_string.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns (string memory) { + return "😃, 😭, and 😈"; + } +} +// ---- +// f() -> 0x20, 0x14, "\xf0\x9f\x98\x83, \xf0\x9f\x98\xad, and \xf0\x9f\x98\x88" diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol b/test/libsolidity/syntaxTests/string/invalid_utf8_explicit_string.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol rename to test/libsolidity/syntaxTests/string/invalid_utf8_explicit_string.sol diff --git a/test/libsolidity/syntaxTests/string/invalid_utf8_hex_string.sol b/test/libsolidity/syntaxTests/string/invalid_utf8_hex_string.sol new file mode 100644 index 000000000..d72ee5af0 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/invalid_utf8_hex_string.sol @@ -0,0 +1,5 @@ +contract C { + string s = hex"a000"; +} +// ---- +// TypeError 7407: (28-37): Type literal_string (contains invalid UTF-8 sequence at position 0) is not implicitly convertible to expected type string storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol b/test/libsolidity/syntaxTests/string/invalid_utf8_implicit_string.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol rename to test/libsolidity/syntaxTests/string/invalid_utf8_implicit_string.sol diff --git a/test/libsolidity/syntaxTests/string/invalid_utf8_in_bytes.sol b/test/libsolidity/syntaxTests/string/invalid_utf8_in_bytes.sol new file mode 100644 index 000000000..c5af0d094 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/invalid_utf8_in_bytes.sol @@ -0,0 +1,6 @@ +contract C { + bytes b1 = "\xa0\x00"; + bytes32 b2 = "\xa0\x00"; + bytes b3 = hex"a000"; +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol b/test/libsolidity/syntaxTests/string/large_utf8_codepoint.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol rename to test/libsolidity/syntaxTests/string/large_utf8_codepoint.sol diff --git a/test/libsolidity/syntaxTests/string/string_unicode.sol b/test/libsolidity/syntaxTests/string/string_unicode.sol new file mode 100644 index 000000000..380ad9e39 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_unicode.sol @@ -0,0 +1,6 @@ +contract test { + function f() public pure returns (string memory) { + return "😃, 😭, and 😈"; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/unicode_escape_literals.sol b/test/libsolidity/syntaxTests/string/unicode_escape_literals.sol similarity index 60% rename from test/libsolidity/syntaxTests/unicode_escape_literals.sol rename to test/libsolidity/syntaxTests/string/unicode_escape_literals.sol index d78e6aa09..011f58b40 100644 --- a/test/libsolidity/syntaxTests/unicode_escape_literals.sol +++ b/test/libsolidity/syntaxTests/string/unicode_escape_literals.sol @@ -1,5 +1,4 @@ contract test { - function oneByteUTF8() public pure returns (bytes32) { bytes32 usdollar = "aaa\u0024aaa"; return usdollar; @@ -15,17 +14,8 @@ contract test { return eur; } - function together() public pure returns (bytes32) { + function combined() public pure returns (bytes32) { bytes32 res = "\u0024\u00A2\u20AC"; return res; } - - // this function returns an invalid unicode character - function invalidLiteral() public pure returns(bytes32) { - bytes32 invalid = "\u00xx"; - return invalid; - } - } -// ---- -// ParserError 8936: (678-681): Invalid escape sequence. diff --git a/test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_codepoint.sol b/test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_codepoint.sol new file mode 100644 index 000000000..46a0de5f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_codepoint.sol @@ -0,0 +1,7 @@ +contract test { + function f() public pure returns (string memory) { + return "\xc1"; + } +} +// ---- +// TypeError 6359: (86-92): Return argument type literal_string (contains invalid UTF-8 sequence at position 0) is not implicitly convertible to expected type (type of first return variable) string memory. diff --git a/test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_format.sol b/test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_format.sol new file mode 100644 index 000000000..6afcd94af --- /dev/null +++ b/test/libsolidity/syntaxTests/string/unicode_escape_literals_invalid_format.sol @@ -0,0 +1,10 @@ +contract test { + // this function returns an invalid unicode character + function invalidLiteral() public pure returns (bytes32) { + bytes32 invalid = "\u00xx"; + return invalid; + } + +} +// ---- +// ParserError 8936: (162-165): Invalid escape sequence. From f28bede34a632a0c2417be8399c3daa864092bb0 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 14 Jul 2020 10:32:11 +0200 Subject: [PATCH 36/71] Refactor storageSizeUpperBound. --- libsolidity/analysis/ContractLevelChecker.cpp | 18 ++++++ libsolidity/analysis/ContractLevelChecker.h | 2 + libsolidity/analysis/TypeChecker.cpp | 16 +---- libsolidity/ast/Types.cpp | 61 ++++++------------- libsolidity/ast/Types.h | 7 ++- .../largeTypes/oversized_array.sol | 2 +- .../largeTypes/oversized_contract.sol | 2 +- .../oversized_contract_inheritance.sol | 12 ++++ .../largeTypes/oversized_struct.sol | 2 +- 9 files changed, 63 insertions(+), 59 deletions(-) create mode 100644 test/libsolidity/syntaxTests/largeTypes/oversized_contract_inheritance.sol diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index c0da54564..fc391f196 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -60,6 +60,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract) checkLibraryRequirements(_contract); checkBaseABICompatibility(_contract); checkPayableFallbackWithoutReceive(_contract); + checkStorageSize(_contract); return Error::containsOnlyWarnings(m_errorReporter.errors()); } @@ -458,3 +459,20 @@ void ContractLevelChecker::checkPayableFallbackWithoutReceive(ContractDefinition SecondarySourceLocation{}.append("The payable fallback function is defined here.", fallback->location()) ); } + +void ContractLevelChecker::checkStorageSize(ContractDefinition const& _contract) +{ + bigint size = 0; + vector variables; + for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts)) + for (VariableDeclaration const* variable: contract->stateVariables()) + if (!(variable->isConstant() || variable->immutable())) + { + size += variable->annotation().type->storageSizeUpperBound(); + if (size >= bigint(1) << 256) + { + m_errorReporter.typeError(7676_error, _contract.location(), "Contract too large for storage."); + break; + } + } +} diff --git a/libsolidity/analysis/ContractLevelChecker.h b/libsolidity/analysis/ContractLevelChecker.h index e40cb8b0d..3a0d7d740 100644 --- a/libsolidity/analysis/ContractLevelChecker.h +++ b/libsolidity/analysis/ContractLevelChecker.h @@ -83,6 +83,8 @@ private: /// Warns if the contract has a payable fallback, but no receive ether function. void checkPayableFallbackWithoutReceive(ContractDefinition const& _contract); + /// Error if the contract requires too much storage + void checkStorageSize(ContractDefinition const& _contract); OverrideChecker m_overrideChecker; langutil::ErrorReporter& m_errorReporter; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index aa316cb48..0c47f2073 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -92,19 +92,7 @@ bool TypeChecker::visit(ContractDefinition const& _contract) for (auto const& n: _contract.subNodes()) n->accept(*this); - bigint size = 0; - vector variables; - for (ContractDefinition const* contract: boost::adaptors::reverse(m_currentContract->annotation().linearizedBaseContracts)) - for (VariableDeclaration const* variable: contract->stateVariables()) - if (!(variable->isConstant() || variable->immutable())) - { - size += storageSizeUpperBound(*(variable->annotation().type)); - if (size >= bigint(1) << 256) - { - m_errorReporter.typeError(7676_error, m_currentContract->location(), "Contract too large for storage."); - break; - } - } + m_currentContract = nullptr; return false; } @@ -566,7 +554,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) " in small quantities per transaction."; }; - if (storageSizeUpperBound(*varType) >= bigint(1) << 64) + if (varType->storageSizeUpperBound() >= bigint(1) << 64) { if (_variable.isStateVariable()) m_errorReporter.warning(3408_error, _variable.location(), collisionMessage(_variable.name(), true)); diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 546e6ee63..825fc8d0c 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -63,37 +63,6 @@ struct TypeComp }; using TypeSet = std::set; -bigint storageSizeUpperBoundInner( - Type const& _type, - set& _structsSeen -) -{ - switch (_type.category()) - { - case Type::Category::Array: - { - auto const& t = dynamic_cast(_type); - if (!t.isDynamicallySized()) - return storageSizeUpperBoundInner(*t.baseType(), _structsSeen) * t.length(); - break; - } - case Type::Category::Struct: - { - auto const& t = dynamic_cast(_type); - solAssert(!_structsSeen.count(&t.structDefinition()), "Recursive struct."); - bigint size = 1; - _structsSeen.insert(&t.structDefinition()); - for (auto const& m: t.members(nullptr)) - size += storageSizeUpperBoundInner(*m.type, _structsSeen); - _structsSeen.erase(&t.structDefinition()); - return size; - } - default: - break; - } - return bigint(1); -} - void oversizedSubtypesInner( Type const& _type, bool _includeType, @@ -106,7 +75,7 @@ void oversizedSubtypesInner( case Type::Category::Array: { auto const& t = dynamic_cast(_type); - if (_includeType && storageSizeUpperBound(t) >= bigint(1) << 64) + if (_includeType && t.storageSizeUpperBound() >= bigint(1) << 64) _oversizedSubtypes.insert(&t); oversizedSubtypesInner(*t.baseType(), t.isDynamicallySized(), _structsSeen, _oversizedSubtypes); break; @@ -116,7 +85,7 @@ void oversizedSubtypesInner( auto const& t = dynamic_cast(_type); if (_structsSeen.count(&t.structDefinition())) return; - if (_includeType && storageSizeUpperBound(t) >= bigint(1) << 64) + if (_includeType && t.storageSizeUpperBound() >= bigint(1) << 64) _oversizedSubtypes.insert(&t); _structsSeen.insert(&t.structDefinition()); for (auto const& m: t.members(nullptr)) @@ -231,12 +200,6 @@ util::Result transformParametersToExternal(TypePointers const& _pa } -bigint solidity::frontend::storageSizeUpperBound(frontend::Type const& _type) -{ - set structsSeen; - return storageSizeUpperBoundInner(_type, structsSeen); -} - vector solidity::frontend::oversizedSubtypes(frontend::Type const& _type) { set structsSeen; @@ -1847,7 +1810,7 @@ BoolResult ArrayType::validForLocation(DataLocation _loc) const break; } case DataLocation::Storage: - if (storageSizeUpperBound(*this) >= bigint(1) << 256) + if (storageSizeUpperBound() >= bigint(1) << 256) return BoolResult::err("Type too large for storage."); break; } @@ -1888,6 +1851,14 @@ bool ArrayType::isDynamicallyEncoded() const return isDynamicallySized() || baseType()->isDynamicallyEncoded(); } +bigint ArrayType::storageSizeUpperBound() const +{ + if (isDynamicallySized()) + return 1; + else + return length() * baseType()->storageSizeUpperBound(); +} + u256 ArrayType::storageSize() const { if (isDynamicallySized()) @@ -2347,6 +2318,14 @@ u256 StructType::memoryDataSize() const return size; } +bigint StructType::storageSizeUpperBound() const +{ + bigint size = 1; + for (auto const& member: members(nullptr)) + size += member.type->storageSizeUpperBound(); + return size; +} + u256 StructType::storageSize() const { return max(1, members(nullptr).storageSize()); @@ -2491,7 +2470,7 @@ BoolResult StructType::validForLocation(DataLocation _loc) const if ( _loc == DataLocation::Storage && - storageSizeUpperBound(*this) >= bigint(1) << 256 + storageSizeUpperBound() >= bigint(1) << 256 ) return BoolResult::err("Type too large for storage."); diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index b05021630..155fa7f14 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -59,7 +59,6 @@ using BoolResult = util::Result; namespace solidity::frontend { -bigint storageSizeUpperBound(frontend::Type const& _type); std::vector oversizedSubtypes(frontend::Type const& _type); inline rational makeRational(bigint const& _numerator, bigint const& _denominator) @@ -251,6 +250,10 @@ public: /// @returns the number of storage slots required to hold this value in storage. /// For dynamically "allocated" types, it returns the size of the statically allocated head, virtual u256 storageSize() const { return 1; } + /// @returns an upper bound on the total storage size required by this type, descending + /// into structs and statically-sized arrays. This is mainly to ensure that the storage + /// slot allocation algorithm does not overflow, it is not a protection against collisions. + virtual bigint storageSizeUpperBound() const { return 1; } /// Multiple small types can be packed into a single storage slot. If such a packing is possible /// this function @returns the size in bytes smaller than 32. Data is moved to the next slot if /// it does not fit. @@ -788,6 +791,7 @@ public: unsigned calldataEncodedTailSize() const override; bool isDynamicallySized() const override { return m_hasDynamicLength; } bool isDynamicallyEncoded() const override; + bigint storageSizeUpperBound() const override; u256 storageSize() const override; bool canLiveOutsideStorage() const override { return m_baseType->canLiveOutsideStorage(); } bool nameable() const override { return true; } @@ -952,6 +956,7 @@ public: unsigned calldataEncodedTailSize() const override; bool isDynamicallyEncoded() const override; u256 memoryDataSize() const override; + bigint storageSizeUpperBound() const override; u256 storageSize() const override; bool canLiveOutsideStorage() const override { return true; } bool nameable() const override { return true; } diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol index 951840fd4..123773403 100644 --- a/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_array.sol @@ -4,5 +4,5 @@ contract C { uint[2**255][2] a; } // ---- -// TypeError 1534: (77-94): Type too large for storage. // TypeError 7676: (60-97): Contract too large for storage. +// TypeError 1534: (77-94): Type too large for storage. diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol index 69f8b1024..44c7274e6 100644 --- a/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_contract.sol @@ -5,6 +5,6 @@ contract C { uint[2**255] b; } // ---- +// TypeError 7676: (60-114): Contract too large for storage. // Warning 3408: (77-91): Variable "a" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. // Warning 3408: (97-111): Variable "b" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// TypeError 7676: (60-114): Contract too large for storage. diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_contract_inheritance.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_contract_inheritance.sol new file mode 100644 index 000000000..24073d4c0 --- /dev/null +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_contract_inheritance.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >= 0.0; +contract C { + uint[2**255] a; +} +contract D is C { + uint[2**255] b; +} +// ---- +// TypeError 7676: (95-134): Contract too large for storage. +// Warning 3408: (77-91): Variable "a" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 3408: (117-131): Variable "b" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol b/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol index a3f3a4160..757ec9e4a 100644 --- a/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol +++ b/test/libsolidity/syntaxTests/largeTypes/oversized_struct.sol @@ -8,5 +8,5 @@ contract C { S s; } // ---- -// TypeError 1534: (146-149): Type too large for storage. // TypeError 7676: (60-152): Contract too large for storage. +// TypeError 1534: (146-149): Type too large for storage. From 9c62ea182dad60467bbc39a6914aba7b703b9286 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 14 Jul 2020 10:08:24 +0200 Subject: [PATCH 37/71] Fix segfault in oversized objects check in combination with var. --- libsolidity/analysis/TypeChecker.cpp | 6 +++++- .../iceRegressionTests/oversized_var.sol | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index aa316cb48..02cbaaadd 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -571,7 +571,11 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) if (_variable.isStateVariable()) m_errorReporter.warning(3408_error, _variable.location(), collisionMessage(_variable.name(), true)); else - m_errorReporter.warning(2332_error, _variable.typeName()->location(), collisionMessage(varType->canonicalName(), false)); + m_errorReporter.warning( + 2332_error, + _variable.typeName() ? _variable.typeName()->location() : _variable.location(), + collisionMessage(varType->canonicalName(), false) + ); } vector oversizedSubtypes = frontend::oversizedSubtypes(*varType); for (Type const* subtype: oversizedSubtypes) diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol b/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol new file mode 100644 index 000000000..0e50ae138 --- /dev/null +++ b/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol @@ -0,0 +1,15 @@ +contract b { + struct c { + uint [2 ** 253] a; + } + + c d; + function e() public { + var d = d; + } +} +// ---- +// Warning 2519: (105-110): This declaration shadows an existing declaration. +// Warning 3408: (66-69): Variable "d" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// Warning 2332: (105-110): Type "b.c" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. +// SyntaxError 1719: (105-114): Use of the "var" keyword is disallowed. Use explicit declaration `struct b.c storage pointer d = ...® instead. From eab12ecf77e3d352981fa4a71297ccfc8a9f3aea Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 14 Jul 2020 14:25:17 +0100 Subject: [PATCH 38/71] Nicer error message for private payable functions --- libsolidity/analysis/TypeChecker.cpp | 2 +- .../syntaxTests/nameAndTypeResolution/356_payable_internal.sol | 2 +- .../syntaxTests/nameAndTypeResolution/357_payable_private.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 762361080..94d9544df 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -337,7 +337,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) if (_function.libraryFunction()) m_errorReporter.typeError(7708_error, _function.location(), "Library functions cannot be payable."); if (_function.isOrdinary() && !_function.isPartOfExternalInterface()) - m_errorReporter.typeError(5587_error, _function.location(), "Internal functions cannot be payable."); + m_errorReporter.typeError(5587_error, _function.location(), "\"internal\" and \"private\" functions cannot be payable."); } auto checkArgumentAndReturnParameter = [&](VariableDeclaration const& var) { if (type(var)->category() == Type::Category::Mapping) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol index 2bf491b5d..a21a18d9c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol @@ -2,4 +2,4 @@ contract test { function f() payable internal {} } // ---- -// TypeError 5587: (20-52): Internal functions cannot be payable. +// TypeError 5587: (20-52): "internal" and "private" functions cannot be payable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol index fcc0dba35..3436ce76f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol @@ -2,4 +2,4 @@ contract test { function f() payable private {} } // ---- -// TypeError 5587: (20-51): Internal functions cannot be payable. +// TypeError 5587: (20-51): "internal" and "private" functions cannot be payable. From aed424f23e9f671e968377381ef138eb3c34489d Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Tue, 23 Jun 2020 12:17:15 -0500 Subject: [PATCH 39/71] Initial docker image creation workflows. --- .circleci/config.yml | 19 +----- .github/workflows/buildpack-deps.yml | 42 ++++++++++++ .gitignore | 2 +- scripts/ci/build.sh | 23 +++++++ scripts/ci/build_ossfuzz.sh | 15 ++++ scripts/ci/buildpack-deps_test_emscripten.sh | 1 + ...pack-deps_test_ubuntu1604.clang.ossfuzz.sh | 1 + scripts/ci/buildpack-deps_test_ubuntu1804.sh | 1 + .../buildpack-deps_test_ubuntu2004.clang.sh | 1 + scripts/ci/buildpack-deps_test_ubuntu2004.sh | 1 + scripts/ci/docker_upgrade.sh | 68 +++++++++++++++++++ .../buildpack-deps}/Dockerfile.emscripten | 2 + .../Dockerfile.ubuntu1604.clang.ossfuzz | 2 + .../buildpack-deps}/Dockerfile.ubuntu1804 | 2 + .../buildpack-deps}/Dockerfile.ubuntu2004 | 2 + .../Dockerfile.ubuntu2004.clang | 2 + scripts/docker/buildpack-deps/README.md | 35 ++++++++++ .../docker/buildpack-deps}/emscripten.jam | 0 18 files changed, 201 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/buildpack-deps.yml create mode 100755 scripts/ci/build.sh create mode 100755 scripts/ci/build_ossfuzz.sh create mode 120000 scripts/ci/buildpack-deps_test_emscripten.sh create mode 120000 scripts/ci/buildpack-deps_test_ubuntu1604.clang.ossfuzz.sh create mode 120000 scripts/ci/buildpack-deps_test_ubuntu1804.sh create mode 120000 scripts/ci/buildpack-deps_test_ubuntu2004.clang.sh create mode 120000 scripts/ci/buildpack-deps_test_ubuntu2004.sh create mode 100755 scripts/ci/docker_upgrade.sh rename {.circleci/docker => scripts/docker/buildpack-deps}/Dockerfile.emscripten (99%) rename {.circleci/docker => scripts/docker/buildpack-deps}/Dockerfile.ubuntu1604.clang.ossfuzz (99%) rename {.circleci/docker => scripts/docker/buildpack-deps}/Dockerfile.ubuntu1804 (99%) rename {.circleci/docker => scripts/docker/buildpack-deps}/Dockerfile.ubuntu2004 (99%) rename {.circleci/docker => scripts/docker/buildpack-deps}/Dockerfile.ubuntu2004.clang (99%) create mode 100644 scripts/docker/buildpack-deps/README.md rename {.circleci/docker => scripts/docker/buildpack-deps}/emscripten.jam (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index d17f13baa..288749974 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,26 +33,11 @@ defaults: - run_build: &run_build name: Build - command: | - set -ex - if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n > prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; fi - echo -n "$CIRCLE_SHA1" > commit_hash.txt - mkdir -p build - cd build - [ -n "$COVERAGE" -a "$CIRCLE_BRANCH" != release -a -z "$CIRCLE_TAG" ] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON" - cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} $CMAKE_OPTIONS -G "Unix Makefiles" - make -j4 + command: scripts/ci/build.sh - run_build_ossfuzz: &run_build_ossfuzz name: Build_ossfuzz - command: | - mkdir -p build - cd build - protoc --proto_path=../test/tools/ossfuzz yulProto.proto --cpp_out=../test/tools/ossfuzz - protoc --proto_path=../test/tools/ossfuzz abiV2Proto.proto --cpp_out=../test/tools/ossfuzz - protoc --proto_path=../test/tools/ossfuzz solProto.proto --cpp_out=../test/tools/ossfuzz - cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} $CMAKE_OPTIONS - make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j4 + command: scripts/ci/build_ossfuzz.sh - run_proofs: &run_proofs name: Correctness proofs for optimization rules diff --git a/.github/workflows/buildpack-deps.yml b/.github/workflows/buildpack-deps.yml new file mode 100644 index 000000000..48d83b77c --- /dev/null +++ b/.github/workflows/buildpack-deps.yml @@ -0,0 +1,42 @@ +name: buildpack-deps + +on: + pull_request: + branches: [ develop ] + paths: + - 'scripts/docker/buildpack-deps/Dockerfile.emscripten' + - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz' + - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu1804' + - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang' + - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004' + +jobs: + buildpack-deps: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + IMAGE_NAME: buildpack-deps + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + image_variant: [emscripten, ubuntu1604.clang.ossfuzz, ubuntu1804, ubuntu2004.clang, ubuntu2004] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Upgrade ${{ env.IMAGE_NAME }}-${{ matrix.image_variant }} + run: | + echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + scripts/ci/docker_upgrade.sh ${{ env.IMAGE_NAME }} ${{ matrix.image_variant }} ${{ env.DOCKER_REPOSITORY }} + docker logout docker.pkg.github.com + + - name: comment PR + if: "env.DOCKER_IMAGE" + uses: aarlt/comment-on-pr@v1.2.0 + with: + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." \ No newline at end of file diff --git a/.gitignore b/.gitignore index 67e450759..749860301 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ prerelease.txt # Build directory build/ -build*/ +/build*/ emscripten_build/ docs/_build __pycache__ diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh new file mode 100755 index 000000000..1c8824abf --- /dev/null +++ b/scripts/ci/build.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -ex + +ROOTDIR="$(dirname "$0")/../.." +cd "${ROOTDIR}" + +# shellcheck disable=SC2166 +if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n >prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" >prerelease.txt; fi +if [ -n "$CIRCLE_SHA1" ] +then + echo -n "$CIRCLE_SHA1" >commit_hash.txt +fi + +mkdir -p build +cd build + +# shellcheck disable=SC2166 +[ -n "$COVERAGE" -a "$CIRCLE_BRANCH" != release -a -z "$CIRCLE_TAG" ] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON" + +# shellcheck disable=SC2086 +cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS -G "Unix Makefiles" + +make -j 4 diff --git a/scripts/ci/build_ossfuzz.sh b/scripts/ci/build_ossfuzz.sh new file mode 100755 index 000000000..42f7b3a39 --- /dev/null +++ b/scripts/ci/build_ossfuzz.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +ROOTDIR="$(dirname "$0")/../.." +BUILDDIR="${ROOTDIR}/build" + +mkdir -p "${BUILDDIR}" +cd "${BUILDDIR}" + +protoc --proto_path=../test/tools/ossfuzz yulProto.proto --cpp_out=../test/tools/ossfuzz +protoc --proto_path=../test/tools/ossfuzz abiV2Proto.proto --cpp_out=../test/tools/ossfuzz +protoc --proto_path=../test/tools/ossfuzz solProto.proto --cpp_out=../test/tools/ossfuzz +cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/libfuzzer.cmake + +make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4 diff --git a/scripts/ci/buildpack-deps_test_emscripten.sh b/scripts/ci/buildpack-deps_test_emscripten.sh new file mode 120000 index 000000000..6e838fba7 --- /dev/null +++ b/scripts/ci/buildpack-deps_test_emscripten.sh @@ -0,0 +1 @@ +../../scripts/travis-emscripten/build_emscripten.sh \ No newline at end of file diff --git a/scripts/ci/buildpack-deps_test_ubuntu1604.clang.ossfuzz.sh b/scripts/ci/buildpack-deps_test_ubuntu1604.clang.ossfuzz.sh new file mode 120000 index 000000000..86beda7dd --- /dev/null +++ b/scripts/ci/buildpack-deps_test_ubuntu1604.clang.ossfuzz.sh @@ -0,0 +1 @@ +build_ossfuzz.sh \ No newline at end of file diff --git a/scripts/ci/buildpack-deps_test_ubuntu1804.sh b/scripts/ci/buildpack-deps_test_ubuntu1804.sh new file mode 120000 index 000000000..c07a74de4 --- /dev/null +++ b/scripts/ci/buildpack-deps_test_ubuntu1804.sh @@ -0,0 +1 @@ +build.sh \ No newline at end of file diff --git a/scripts/ci/buildpack-deps_test_ubuntu2004.clang.sh b/scripts/ci/buildpack-deps_test_ubuntu2004.clang.sh new file mode 120000 index 000000000..c07a74de4 --- /dev/null +++ b/scripts/ci/buildpack-deps_test_ubuntu2004.clang.sh @@ -0,0 +1 @@ +build.sh \ No newline at end of file diff --git a/scripts/ci/buildpack-deps_test_ubuntu2004.sh b/scripts/ci/buildpack-deps_test_ubuntu2004.sh new file mode 120000 index 000000000..c07a74de4 --- /dev/null +++ b/scripts/ci/buildpack-deps_test_ubuntu2004.sh @@ -0,0 +1 @@ +build.sh \ No newline at end of file diff --git a/scripts/ci/docker_upgrade.sh b/scripts/ci/docker_upgrade.sh new file mode 100755 index 000000000..a8212c2c2 --- /dev/null +++ b/scripts/ci/docker_upgrade.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +set -e + +function error() { + echo >&2 "ERROR: ${1} Aborting." && false +} + +function warning() { + echo >&2 "WARNING: ${1}" +} + +[[ $# == 3 ]] || error "Expected exactly 3 parameters: '${0} '." + +IMAGE_NAME="${1}" +IMAGE_VARIANT="${2}" +DOCKER_REPOSITORY="${3}" +DOCKERFILE="scripts/docker/${IMAGE_NAME}/Dockerfile.${IMAGE_VARIANT}" + +echo "-- check_dockerfile_was_changed" + +# exit, if the dockerfile was not changed. +if git diff --quiet origin/develop HEAD -- "${DOCKERFILE}"; then + echo "${DOCKERFILE} was not changed. Nothing to do." + exit 0 +fi + +echo "-- check_version" + +PREV_VERSION=$(git diff origin/develop HEAD -- "${DOCKERFILE}" | grep -e '^\s*-LABEL\s\+version=".*"\s*$' | awk -F'"' '{ print $2 }') +NEXT_VERSION=$(git diff origin/develop HEAD -- "${DOCKERFILE}" | grep -e '^\s*+LABEL\s\+version=".*"\s*$' | awk -F'"' '{ print $2 }') + +[[ $NEXT_VERSION != "" ]] || error "No version label defined in Dockerfile. You may need to add 'LABEL version' in '${DOCKERFILE}'." + +[[ $PREV_VERSION != "" ]] || { + warning "no previous version found. Will set \$PREV_VERSION = 0." + PREV_VERSION=0 +} + +if [[ $((PREV_VERSION + 1)) != $((NEXT_VERSION)) ]]; then + error "Version label in Dockerfile was not incremented. You may need to change 'LABEL version' in '${DOCKERFILE}'." +fi + +echo "-- build_docker" + +# This is a workaround: we run `docker build` twice to prevent the `layer does not exist` problem. +# See https://github.com/moby/moby/issues/37965. +docker build "scripts/docker/${IMAGE_NAME}" --file "scripts/docker/${IMAGE_NAME}/Dockerfile.${IMAGE_VARIANT}" --tag "${IMAGE_NAME}" || + docker build "scripts/docker/${IMAGE_NAME}" --file "scripts/docker/${IMAGE_NAME}/Dockerfile.${IMAGE_VARIANT}" --tag "${IMAGE_NAME}" + +echo "-- test_docker @ '${PWD}'" + +docker run --rm --volume "${PWD}:/root/project" "${IMAGE_NAME}" "/root/project/scripts/ci/${IMAGE_NAME}_test_${IMAGE_VARIANT}.sh" + +echo "-- push_docker" + +VERSION=$(docker inspect --format='{{.Config.Labels.version}}' "${IMAGE_NAME}") +DOCKER_IMAGE_ID="${DOCKER_REPOSITORY}/${IMAGE_NAME}-${IMAGE_VARIANT}" + +docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}:${VERSION}" +docker push "${DOCKER_IMAGE_ID}:${VERSION}" + +REPO_DIGEST=$(docker inspect --format='{{.RepoDigests}}' "${DOCKER_IMAGE_ID}:${VERSION}") + +docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}:latest" +docker push "${DOCKER_IMAGE_ID}:latest" + +echo "::set-env name=DOCKER_IMAGE::${DOCKER_IMAGE_ID}:${VERSION}" +echo "::set-env name=DOCKER_REPO_DIGEST::${REPO_DIGEST}" diff --git a/.circleci/docker/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten similarity index 99% rename from .circleci/docker/Dockerfile.emscripten rename to scripts/docker/buildpack-deps/Dockerfile.emscripten index d2456bb2a..8885e1302 100644 --- a/.circleci/docker/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -29,6 +29,7 @@ # make version=1.39.15 build # FROM emscripten/emsdk:1.39.15 AS base +LABEL version="0" ADD emscripten.jam /usr/src RUN set -ex; \ @@ -63,3 +64,4 @@ RUN set -ex; \ cxxflags="-s DISABLE_EXCEPTION_CATCHING=0 -Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ --prefix=/emsdk/emscripten/sdk/system install; \ rm -r /usr/src/boost_1_73_0 + diff --git a/.circleci/docker/Dockerfile.ubuntu1604.clang.ossfuzz b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz similarity index 99% rename from .circleci/docker/Dockerfile.ubuntu1604.clang.ossfuzz rename to scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz index f7dfc7001..add0bfec4 100644 --- a/.circleci/docker/Dockerfile.ubuntu1604.clang.ossfuzz +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM gcr.io/oss-fuzz-base/base-clang as base +LABEL version="0" ARG DEBIAN_FRONTEND=noninteractive @@ -99,3 +100,4 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include + diff --git a/.circleci/docker/Dockerfile.ubuntu1804 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 similarity index 99% rename from .circleci/docker/Dockerfile.ubuntu1804 rename to scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 index fa651900b..34f1e674b 100644 --- a/.circleci/docker/Dockerfile.ubuntu1804 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:bionic AS base +LABEL version="0" ARG DEBIAN_FRONTEND=noninteractive @@ -91,3 +92,4 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include + diff --git a/.circleci/docker/Dockerfile.ubuntu2004 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 similarity index 99% rename from .circleci/docker/Dockerfile.ubuntu2004 rename to scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 index a021b6533..6c5486bd2 100644 --- a/.circleci/docker/Dockerfile.ubuntu2004 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base +LABEL version="0" ARG DEBIAN_FRONTEND=noninteractive @@ -60,3 +61,4 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include + diff --git a/.circleci/docker/Dockerfile.ubuntu2004.clang b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang similarity index 99% rename from .circleci/docker/Dockerfile.ubuntu2004.clang rename to scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang index c8d057eb1..b38fe4f1a 100644 --- a/.circleci/docker/Dockerfile.ubuntu2004.clang +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base +LABEL version="0" ARG DEBIAN_FRONTEND=noninteractive @@ -62,3 +63,4 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include + diff --git a/scripts/docker/buildpack-deps/README.md b/scripts/docker/buildpack-deps/README.md new file mode 100644 index 000000000..004a89e91 --- /dev/null +++ b/scripts/docker/buildpack-deps/README.md @@ -0,0 +1,35 @@ +# buildpack-deps docker images + +The `buildpack-deps` docker images are used to compile and test solidity within our CI. + +## GitHub Workflow + +The creation of the images are triggered by a single workflow, defined in `.github/workflows/buildpack-deps.yml`. +For each resulting `buildpack-deps` docker image a strategy is defined in the workflow file - the image variant. +The workflow gets triggered, if any Dockerfile defined in `scripts/docker/buildpack-deps/Dockerfile.*` were changed +within the PR. + +### Versioning + +The version of the docker images can be defined within the Dockerfile with `LABEL version`. A new docker image +will only be created and pushed, if the new version is incremented by `1` compared with the version of the Dockerfile +located in `develop`. + +### Build, Test & Push + +Note that the whole workflow - including all defined strategies (image variants) - will be triggered, +even if only a single Dockerfile was change. The full workflow will only gets executed, if the corresponding +Dockerfile was changed. The execution of workflows of unchanged Dockerfiles will not continue and just return success. +See `scripts/ci/docker_upgrade.sh`. + +If the version check was successful, the docker image will be built using the Dockerfile located in +`scripts/docker/buildpack-deps/Dockerfile.*`. + +The resulting docker image will be tested by executing +the corresponding `scripts/ci/buildpack-deps_test_*` scripts. These scripts are normally symlinked to `scripts/ci/build.sh`, +except for the `buildpack-deps-ubuntu1604.clang.ossfuzz` docker image, that is symlinked to `scripts/ci/build_ossfuzz.sh`. +These scripts `scripts/ci/build.sh` and `scripts/ci/build_ossfuzz.sh` are also used by CircleCI, see `.circleci/config.yml`. + +If the tests passed successfully, the docker image will get tagged by the version defined within the corresponding `Dockerfile`. +Finally, a comment will be added to the PR that contains the full repository, version and repository digest +of the freshly created docker image. \ No newline at end of file diff --git a/.circleci/docker/emscripten.jam b/scripts/docker/buildpack-deps/emscripten.jam similarity index 100% rename from .circleci/docker/emscripten.jam rename to scripts/docker/buildpack-deps/emscripten.jam From ca313e40030a8c52e8427947820f0594d94edffb Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 15 Jul 2020 12:10:56 +0200 Subject: [PATCH 40/71] Use more processors to build base builds. --- .circleci/config.yml | 5 +++++ .travis.yml | 1 + scripts/ci/build.sh | 2 +- scripts/travis-emscripten/build_emscripten.sh | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 288749974..826c04785 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -407,8 +407,11 @@ jobs: - persist_to_workspace: *artifacts_executables b_ubu: &build_ubuntu2004 + resource_class: xlarge docker: - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + environment: + MAKEFLAGS: -j 10 steps: - checkout - run: *run_build @@ -583,9 +586,11 @@ jobs: - store_artifacts: *artifacts_test_results b_ems: + resource_class: xlarge docker: - image: ethereum/solidity-buildpack-deps:emsdk-1.39.15-2 environment: + MAKEFLAGS: -j 10 TERM: xterm steps: - checkout diff --git a/.travis.yml b/.travis.yml index ef7832777..e20a4d202 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,7 @@ env: - SOLC_TESTS=On - SOLC_STOREBYTECODE=Off - SOLC_DOCKER=Off + - MAKEFLAGS="-j 4" matrix: include: diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 1c8824abf..a939412f6 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -20,4 +20,4 @@ cd build # shellcheck disable=SC2086 cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS -G "Unix Makefiles" -make -j 4 +make diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index 5c7e3f052..3162e13b6 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -53,7 +53,7 @@ cmake \ -DBoost_USE_STATIC_RUNTIME=1 \ -DTESTS=0 \ .. -make -j 4 soljson +make soljson # Patch soljson.js for backwards compatibility. # TODO: remove this with 0.7. # "viiiii" encodes the signature of the callback function. From 46653b2d434f026933aa4a8a244a1152ceb7009d Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 15 Jul 2020 18:10:14 +0200 Subject: [PATCH 41/71] Fix ICE when bitwise operator on fixed bytes --- Changelog.md | 1 + libsmtutil/SolverInterface.h | 23 +++++++++++-------- libsolidity/formal/SMTEncoder.cpp | 6 +++-- libsolidity/formal/SymbolicTypes.cpp | 4 ++++ .../operators/bitwise_and_fixed_bytes.sol | 8 +++++++ .../operators/bitwise_xor_fixed_bytes.sol | 9 ++++++++ 6 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 test/libsolidity/smtCheckerTests/operators/bitwise_and_fixed_bytes.sol create mode 100644 test/libsolidity/smtCheckerTests/operators/bitwise_xor_fixed_bytes.sol diff --git a/Changelog.md b/Changelog.md index 047b06ddf..4953a4e49 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ Compiler Features: * Yul EVM Code Transform: Free stack slots directly after visiting the right-hand-side of variable declarations instead of at the end of the statement only. Bugfixes: + * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. * Type Checker: Fix overload resolution in combination with ``{value: ...}``. * Type Checker: Fix internal compiler error related to oversized types. diff --git a/libsmtutil/SolverInterface.h b/libsmtutil/SolverInterface.h index be12c3a80..a62a39b37 100644 --- a/libsmtutil/SolverInterface.h +++ b/libsmtutil/SolverInterface.h @@ -59,10 +59,10 @@ class Expression public: explicit Expression(bool _v): Expression(_v ? "true" : "false", Kind::Bool) {} explicit Expression(std::shared_ptr _sort, std::string _name = ""): Expression(std::move(_name), {}, _sort) {} - Expression(size_t _number): Expression(std::to_string(_number), Kind::Int) {} - Expression(u256 const& _number): Expression(_number.str(), Kind::Int) {} - Expression(s256 const& _number): Expression(_number.str(), Kind::Int) {} - Expression(bigint const& _number): Expression(_number.str(), Kind::Int) {} + Expression(size_t _number): Expression(std::to_string(_number), {}, SortProvider::sintSort) {} + Expression(u256 const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {} + Expression(s256 const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {} + Expression(bigint const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {} Expression(Expression const&) = default; Expression(Expression&&) = default; @@ -262,23 +262,28 @@ public: } friend Expression operator+(Expression _a, Expression _b) { - return Expression("+", std::move(_a), std::move(_b), Kind::Int); + auto intSort = _a.sort; + return Expression("+", {std::move(_a), std::move(_b)}, intSort); } friend Expression operator-(Expression _a, Expression _b) { - return Expression("-", std::move(_a), std::move(_b), Kind::Int); + auto intSort = _a.sort; + return Expression("-", {std::move(_a), std::move(_b)}, intSort); } friend Expression operator*(Expression _a, Expression _b) { - return Expression("*", std::move(_a), std::move(_b), Kind::Int); + auto intSort = _a.sort; + return Expression("*", {std::move(_a), std::move(_b)}, intSort); } friend Expression operator/(Expression _a, Expression _b) { - return Expression("/", std::move(_a), std::move(_b), Kind::Int); + auto intSort = _a.sort; + return Expression("/", {std::move(_a), std::move(_b)}, intSort); } friend Expression operator%(Expression _a, Expression _b) { - return Expression("mod", std::move(_a), std::move(_b), Kind::Int); + auto intSort = _a.sort; + return Expression("mod", {std::move(_a), std::move(_b)}, intSort); } friend Expression operator&(Expression _a, Expression _b) { diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index eea0b24e5..6a4030511 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -1376,9 +1376,11 @@ void SMTEncoder::bitwiseOperation(BinaryOperation const& _op) bvSize = fixedType->numBits(); isSigned = fixedType->isSigned(); } + else if (auto const* fixedBytesType = dynamic_cast(commonType)) + bvSize = fixedBytesType->numBytes() * 8; - auto bvLeft = smtutil::Expression::int2bv(expr(_op.leftExpression()), bvSize); - auto bvRight = smtutil::Expression::int2bv(expr(_op.rightExpression()), bvSize); + auto bvLeft = smtutil::Expression::int2bv(expr(_op.leftExpression(), commonType), bvSize); + auto bvRight = smtutil::Expression::int2bv(expr(_op.rightExpression(), commonType), bvSize); optional result; if (_op.getOperator() == Token::BitAnd) diff --git a/libsolidity/formal/SymbolicTypes.cpp b/libsolidity/formal/SymbolicTypes.cpp index a46b88e03..096f496c4 100644 --- a/libsolidity/formal/SymbolicTypes.cpp +++ b/libsolidity/formal/SymbolicTypes.cpp @@ -441,7 +441,11 @@ optional symbolicTypeConversion(TypePointer _from, TypePoin // case they'd need to be encoded as numbers. if (auto strType = dynamic_cast(_from)) if (_to->category() == frontend::Type::Category::FixedBytes) + { + if (strType->value().empty()) + return smtutil::Expression(size_t(0)); return smtutil::Expression(u256(toHex(util::asBytes(strType->value()), util::HexPrefix::Add))); + } return std::nullopt; } diff --git a/test/libsolidity/smtCheckerTests/operators/bitwise_and_fixed_bytes.sol b/test/libsolidity/smtCheckerTests/operators/bitwise_and_fixed_bytes.sol new file mode 100644 index 000000000..c3212bb23 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/bitwise_and_fixed_bytes.sol @@ -0,0 +1,8 @@ +pragma experimental SMTChecker; +contract C { + function f() public pure returns (byte) { + return (byte("") & ("")); + } +} +// ---- +// Warning 5084: (101-109): Type conversion is not yet fully supported and might yield false positives. diff --git a/test/libsolidity/smtCheckerTests/operators/bitwise_xor_fixed_bytes.sol b/test/libsolidity/smtCheckerTests/operators/bitwise_xor_fixed_bytes.sol new file mode 100644 index 000000000..3852563be --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/bitwise_xor_fixed_bytes.sol @@ -0,0 +1,9 @@ +pragma experimental SMTChecker; +contract Simp { + function f3() public pure returns (byte) { + bytes memory y = "def"; + return y[0] ^ "e"; + } +} +// ---- +// Warning 1093: (142-152): Assertion checker does not yet implement this bitwise operator. From 99d831d7d150fc03941cbd0482d51dc54d228fae Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 15 Jul 2020 19:50:19 +0200 Subject: [PATCH 42/71] Extract recursive function detection from Semantics into the CallGraph. --- libyul/optimiser/CallGraphGenerator.cpp | 41 +++++++++++++++++++++++++ libyul/optimiser/CallGraphGenerator.h | 4 +++ libyul/optimiser/Semantics.cpp | 22 +------------ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/libyul/optimiser/CallGraphGenerator.cpp b/libyul/optimiser/CallGraphGenerator.cpp index d3805e7f7..565518af0 100644 --- a/libyul/optimiser/CallGraphGenerator.cpp +++ b/libyul/optimiser/CallGraphGenerator.cpp @@ -30,6 +30,47 @@ using namespace solidity; using namespace solidity::yul; using namespace solidity::util; +namespace +{ +// TODO: This algorithm is non-optimal. +struct CallGraphCycleFinder +{ + CallGraph const& callGraph; + set containedInCycle{}; + set visited{}; + vector currentPath{}; + + void visit(YulString _function) + { + if (visited.count(_function)) + return; + if ( + auto it = find(currentPath.begin(), currentPath.end(), _function); + it != currentPath.end() + ) + containedInCycle.insert(it, currentPath.end()); + else + { + currentPath.emplace_back(_function); + if (callGraph.functionCalls.count(_function)) + for (auto const& child: callGraph.functionCalls.at(_function)) + visit(child); + currentPath.pop_back(); + visited.insert(_function); + } + } +}; +} + +set CallGraph::recursiveFunctions() const +{ + CallGraphCycleFinder cycleFinder{*this}; + // Visiting the root only is not enough, since there may be disconnected recursive functions. + for (auto const& call: functionCalls) + cycleFinder.visit(call.first); + return cycleFinder.containedInCycle; +} + CallGraph CallGraphGenerator::callGraph(Block const& _ast) { CallGraphGenerator gen; diff --git a/libyul/optimiser/CallGraphGenerator.h b/libyul/optimiser/CallGraphGenerator.h index 2a05c7564..2b57f8592 100644 --- a/libyul/optimiser/CallGraphGenerator.h +++ b/libyul/optimiser/CallGraphGenerator.h @@ -35,6 +35,10 @@ struct CallGraph { std::map> functionCalls; std::set functionsWithLoops; + /// @returns the set of functions contained in cycles in the call graph, i.e. + /// functions that are part of a (mutual) recursion. + /// Note that this does not include functions that merely call recursive functions. + std::set recursiveFunctions() const; }; /** diff --git a/libyul/optimiser/Semantics.cpp b/libyul/optimiser/Semantics.cpp index f9d831b7a..6100b1cdc 100644 --- a/libyul/optimiser/Semantics.cpp +++ b/libyul/optimiser/Semantics.cpp @@ -102,33 +102,13 @@ map SideEffectsPropagator::sideEffects( // is actually a bit different from "not movable". map ret; - for (auto const& function: _directCallGraph.functionsWithLoops) + for (auto const& function: _directCallGraph.functionsWithLoops + _directCallGraph.recursiveFunctions()) { ret[function].movable = false; ret[function].sideEffectFree = false; ret[function].sideEffectFreeIfNoMSize = false; } - // Detect recursive functions. - for (auto const& call: _directCallGraph.functionCalls) - { - // TODO we could shortcut the search as soon as we find a - // function that has as bad side-effects as we can - // ever achieve via recursion. - auto search = [&](YulString const& _functionName, util::CycleDetector& _cycleDetector, size_t) { - for (auto const& callee: _directCallGraph.functionCalls.at(_functionName)) - if (!_dialect.builtin(callee)) - if (_cycleDetector.run(callee)) - return; - }; - if (util::CycleDetector(search).run(call.first)) - { - ret[call.first].movable = false; - ret[call.first].sideEffectFree = false; - ret[call.first].sideEffectFreeIfNoMSize = false; - } - } - for (auto const& call: _directCallGraph.functionCalls) { YulString funName = call.first; From 0b9bb84c39a25b0361d8fe30eddf47c8c4c441d4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 15 Jul 2020 13:05:08 +0200 Subject: [PATCH 43/71] Run tests in parallel. --- .circleci/config.yml | 1 + .circleci/soltest_all.sh | 47 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 826c04785..df0eba03d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -139,6 +139,7 @@ defaults: - test_ubuntu2004: &test_ubuntu2004 docker: - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + parallelism: 6 steps: - checkout - attach_workspace: diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 86f172a04..7b1fb053b 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -28,10 +28,49 @@ set -e REPODIR="$(realpath $(dirname $0)/..)" -EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh +EVM_VALUES=(homestead byzantium constantinople petersburg istanbul) +OPTIMIZE_VALUES=(0 1) +STEPS=$(( 1 + ${#EVM_VALUES[@]} * ${#OPTIMIZE_VALUES[@]} )) -for OPTIMIZE in 0 1; do - for EVM in homestead byzantium constantinople petersburg istanbul; do - EVM=$EVM OPTIMIZE=$OPTIMIZE BOOST_TEST_ARGS="-t !@nooptions" ${REPODIR}/.circleci/soltest.sh +if (( $CIRCLE_NODE_TOTAL )) && (( $CIRCLE_NODE_TOTAL > 1 )) +then + # Run step 1 as the only step on the first executor + # and evenly distribute the other steps among + # the other executors. + # The first step takes much longer than the other steps. + if (( $CIRCLE_NODE_INDEX == 0 )) + then + RUN_STEPS="1" + else + export CIRCLE_NODE_INDEX=$(($CIRCLE_NODE_INDEX - 1)) + export CIRCLE_NODE_TOTAL=$(($CIRCLE_NODE_TOTAL - 1)) + RUN_STEPS=$(seq 2 "$STEPS" | circleci tests split) + fi +else + RUN_STEPS=$(seq "$STEPS") +fi + +# turn newlines into spaces +RUN_STEPS=$(echo $RUN_STEPS) + +echo "Running steps $RUN_STEPS..." + +STEP=1 + +[[ " $RUN_STEPS " =~ " $STEP " ]] && EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 "${REPODIR}/.circleci/soltest.sh" +STEP=$(($STEP + 1)) + +for OPTIMIZE in ${OPTIMIZE_VALUES[@]} +do + for EVM in ${EVM_VALUES[@]} + do + [[ " $RUN_STEPS " =~ " $STEP " ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh" + STEP=$(($STEP + 1)) done done + +if (($STEP != $STEPS + 1)) +then + echo "Step counter not properly adjusted!" >2 + exit 1 +fi From f47981d484606172af1a393ea2d107eee48e11be Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Mon, 8 Jun 2020 17:50:55 +0200 Subject: [PATCH 44/71] Prepare testcase for avoiding double cleanup --- test/libsolidity/SolidityOptimizer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 4062b1928..68c500e8c 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -708,6 +708,18 @@ BOOST_AUTO_TEST_CASE(shift_optimizer_bug) compareVersions("g(uint256)", u256(-1)); } +BOOST_AUTO_TEST_CASE(avoid_double_cleanup) +{ + char const* sourceCode = R"( + contract C { + receive() external payable { + abi.encodePacked(uint200(0)); + } + } + )"; + compileBothVersions(sourceCode, 0, "C", 50); + BOOST_CHECK_EQUAL(numInstructions(m_nonOptimizedBytecode, Instruction::AND), 2); +} BOOST_AUTO_TEST_SUITE_END() From d3af598c49b42f62c56f250f72546686a2bd83a6 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Mon, 8 Jun 2020 17:52:40 +0200 Subject: [PATCH 45/71] CodeGen: Avoid double cleanup when copying to memory --- Changelog.md | 1 + libsolidity/codegen/CompilerUtils.cpp | 19 +++++++++++++------ libsolidity/codegen/CompilerUtils.h | 6 ++++-- test/libsolidity/SolidityOptimizer.cpp | 3 ++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4953a4e49..0f0e533b9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,7 @@ Bugfixes: * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. * Type Checker: Fix overload resolution in combination with ``{value: ...}``. * Type Checker: Fix internal compiler error related to oversized types. + * Code Generator: Avoid double cleanup when copying to memory. Compiler Features: * Build System: Update internal dependency of jsoncpp to 1.9.3. diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index b3fc9da2e..2d7b38b25 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -180,7 +180,7 @@ void CompilerUtils::storeInMemory(unsigned _offset) m_context << u256(_offset) << Instruction::MSTORE; } -void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBoundaries) +void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBoundaries, bool _cleanup) { // process special types (Reference, StringLiteral, Function) if (auto ref = dynamic_cast(&_type)) @@ -189,7 +189,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound ref->location() == DataLocation::Memory, "Only in-memory reference type can be stored." ); - storeInMemoryDynamic(*TypeProvider::uint256(), _padToWordBoundaries); + storeInMemoryDynamic(*TypeProvider::uint256(), _padToWordBoundaries, _cleanup); } else if (auto str = dynamic_cast(&_type)) { @@ -212,7 +212,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound } else if (_type.isValueType()) { - unsigned numBytes = prepareMemoryStore(_type, _padToWordBoundaries); + unsigned numBytes = prepareMemoryStore(_type, _padToWordBoundaries, _cleanup); m_context << Instruction::DUP2 << Instruction::MSTORE; m_context << u256(numBytes) << Instruction::ADD; } @@ -463,6 +463,7 @@ void CompilerUtils::encodeToMemory( } else { + bool needCleanup = true; copyToStackTop(argSize - stackPos + dynPointers + 2, _givenTypes[i]->sizeOnStack()); solAssert(!!targetType, "Externalable type expected."); TypePointer type = targetType; @@ -481,7 +482,11 @@ void CompilerUtils::encodeToMemory( ) type = _givenTypes[i]; // delay conversion else + { convertType(*_givenTypes[i], *targetType, true); + needCleanup = false; + } + if (auto arrayType = dynamic_cast(type)) ArrayUtils(m_context).copyArrayToMemory(*arrayType, _padToWordBoundaries); else if (auto arraySliceType = dynamic_cast(type)) @@ -495,7 +500,7 @@ void CompilerUtils::encodeToMemory( ArrayUtils(m_context).copyArrayToMemory(arraySliceType->arrayType(), _padToWordBoundaries); } else - storeInMemoryDynamic(*type, _padToWordBoundaries); + storeInMemoryDynamic(*type, _padToWordBoundaries, needCleanup); } stackPos += _givenTypes[i]->sizeOnStack(); } @@ -1499,7 +1504,7 @@ void CompilerUtils::rightShiftNumberOnStack(unsigned _bits) m_context << (u256(1) << _bits) << Instruction::SWAP1 << Instruction::DIV; } -unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords) +unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords, bool _cleanup) { solAssert( _type.sizeOnStack() == 1, @@ -1522,7 +1527,9 @@ unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords) bool leftAligned = _type.category() == Type::Category::FixedBytes; - convertType(_type, _type, true); + if (_cleanup) + convertType(_type, _type, true); + if (numBytes != 32 && !leftAligned && !_padToWords) // shift the value accordingly before storing leftShiftNumberOnStack((32 - numBytes) * 8); diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index a3c266bde..a65edb8f2 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -107,10 +107,11 @@ public: /// and also updates that. For reference types, only copies the data pointer. Fails for /// non-memory-references. /// @param _padToWords if true, adds zeros to pad to multiple of 32 bytes. Array elements + /// @param _cleanup if true, adds code to cleanup the value before storing it. /// are always padded (except for byte arrays), regardless of this parameter. /// Stack pre: memory_offset value... /// Stack post: (memory_offset+length) - void storeInMemoryDynamic(Type const& _type, bool _padToWords = true); + void storeInMemoryDynamic(Type const& _type, bool _padToWords = true, bool _cleanup = true); /// Creates code that unpacks the arguments according to their types specified by a vector of TypePointers. /// From memory if @a _fromMemory is true, otherwise from call data. @@ -309,7 +310,8 @@ private: void cleanHigherOrderBits(IntegerType const& _typeOnStack); /// Prepares the given type for storing in memory by shifting it if necessary. - unsigned prepareMemoryStore(Type const& _type, bool _padToWords); + /// @param _cleanup if true, also cleanup the value when preparing to store it in memory + unsigned prepareMemoryStore(Type const& _type, bool _padToWords, bool _cleanup = true); /// Loads type from memory assuming memory offset is on stack top. unsigned loadFromMemoryHelper(Type const& _type, bool _fromCalldata, bool _padToWords); diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 68c500e8c..c4f7a2e71 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -718,7 +718,8 @@ BOOST_AUTO_TEST_CASE(avoid_double_cleanup) } )"; compileBothVersions(sourceCode, 0, "C", 50); - BOOST_CHECK_EQUAL(numInstructions(m_nonOptimizedBytecode, Instruction::AND), 2); + // Check that there is no double AND instruction in the resulting code + BOOST_CHECK_EQUAL(numInstructions(m_nonOptimizedBytecode, Instruction::AND), 1); } BOOST_AUTO_TEST_SUITE_END() From f7e180fb8f1283a4e0bd16d9f16bafd8daaf196d Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Wed, 15 Jul 2020 10:42:15 -0500 Subject: [PATCH 46/71] Push images to docker hub. --- .github/workflows/buildpack-deps.yml | 7 ++++--- scripts/ci/docker_upgrade.sh | 13 +++++-------- scripts/docker/buildpack-deps/Dockerfile.emscripten | 2 +- .../Dockerfile.ubuntu1604.clang.ossfuzz | 2 +- scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 | 2 +- scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 | 2 +- .../buildpack-deps/Dockerfile.ubuntu2004.clang | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/buildpack-deps.yml b/.github/workflows/buildpack-deps.yml index 48d83b77c..2e2ea547f 100644 --- a/.github/workflows/buildpack-deps.yml +++ b/.github/workflows/buildpack-deps.yml @@ -14,7 +14,8 @@ jobs: buildpack-deps: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + DOCKER_REPOSITORY: solbuildpackpusher/solidity-buildpack-deps IMAGE_NAME: buildpack-deps runs-on: ubuntu-latest @@ -31,9 +32,9 @@ jobs: - name: Upgrade ${{ env.IMAGE_NAME }}-${{ matrix.image_variant }} run: | - echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + echo ${DOCKERHUB_TOKEN} | docker login -u solbuildpackpusher --password-stdin scripts/ci/docker_upgrade.sh ${{ env.IMAGE_NAME }} ${{ matrix.image_variant }} ${{ env.DOCKER_REPOSITORY }} - docker logout docker.pkg.github.com + docker logout - name: comment PR if: "env.DOCKER_IMAGE" diff --git a/scripts/ci/docker_upgrade.sh b/scripts/ci/docker_upgrade.sh index a8212c2c2..16d622230 100755 --- a/scripts/ci/docker_upgrade.sh +++ b/scripts/ci/docker_upgrade.sh @@ -54,15 +54,12 @@ docker run --rm --volume "${PWD}:/root/project" "${IMAGE_NAME}" "/root/project/s echo "-- push_docker" VERSION=$(docker inspect --format='{{.Config.Labels.version}}' "${IMAGE_NAME}") -DOCKER_IMAGE_ID="${DOCKER_REPOSITORY}/${IMAGE_NAME}-${IMAGE_VARIANT}" +DOCKER_IMAGE_ID="${DOCKER_REPOSITORY}:${IMAGE_VARIANT}" -docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}:${VERSION}" -docker push "${DOCKER_IMAGE_ID}:${VERSION}" +docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}-${VERSION}" +docker push "${DOCKER_IMAGE_ID}-${VERSION}" -REPO_DIGEST=$(docker inspect --format='{{.RepoDigests}}' "${DOCKER_IMAGE_ID}:${VERSION}") +REPO_DIGEST=$(docker inspect --format='{{.RepoDigests}}' "${DOCKER_IMAGE_ID}-${VERSION}") -docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}:latest" -docker push "${DOCKER_IMAGE_ID}:latest" - -echo "::set-env name=DOCKER_IMAGE::${DOCKER_IMAGE_ID}:${VERSION}" +echo "::set-env name=DOCKER_IMAGE::${DOCKER_IMAGE_ID}-${VERSION}" echo "::set-env name=DOCKER_REPO_DIGEST::${REPO_DIGEST}" diff --git a/scripts/docker/buildpack-deps/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten index 8885e1302..2d9ce401d 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -29,7 +29,7 @@ # make version=1.39.15 build # FROM emscripten/emsdk:1.39.15 AS base -LABEL version="0" +LABEL version="1" ADD emscripten.jam /usr/src RUN set -ex; \ diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz index add0bfec4..ceea17d81 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM gcr.io/oss-fuzz-base/base-clang as base -LABEL version="0" +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 index 34f1e674b..51eed0a9e 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1804 @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:bionic AS base -LABEL version="0" +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 index 6c5486bd2..591e430af 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="0" +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang index b38fe4f1a..c1663fdba 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="0" +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive From 34c34bda264d2adee6ac54adea9bdcaf7f383662 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 15 Jul 2020 12:44:35 +0200 Subject: [PATCH 47/71] Switch CI to new docker images. --- .circleci/config.yml | 45 ++++++++++++++++++++----------------- .travis.yml | 2 +- scripts/build_emscripten.sh | 3 ++- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index df0eba03d..4a48caf54 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,18 +7,21 @@ # - ems: Emscripten version: 2.1 parameters: - ubuntu-1804-docker-image-rev: + ubuntu-1804-docker-image: type: string - default: "4" - ubuntu-2004-docker-image-rev: + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:4484ac3da8fdc337cc77a7a7be1af71cd0f28f9c890d934f1d6ae7532beb66b1" + ubuntu-2004-docker-image: type: string - default: "2" - ubuntu-2004-clang-docker-image-rev: + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:48b5bb6b91ac7dddfe9345c88876ebed126c652258800f114caed69db73b29bf" + ubuntu-2004-clang-docker-image: type: string - default: "2" - ubuntu-1604-clang-ossfuzz-docker-image-rev: + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d8775de58167db5a11690fdb6ef639317fe1e579ec5d46e9732d2d903b55d135" + ubuntu-1604-clang-ossfuzz-docker-image: type: string - default: "2" + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:db52f3257396814215744a19904e42c07e040ab36b68be72a27ba71ad2f1083c" + emscripten-docker-image: + type: string + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc" defaults: @@ -116,7 +119,7 @@ defaults: - test_ubuntu1604_clang: &test_ubuntu1604_clang docker: - - image: ethereum/solidity-buildpack-deps:ubuntu1604-clang-ossfuzz-<< pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >> steps: - checkout - attach_workspace: @@ -127,7 +130,7 @@ defaults: - test_ubuntu2004_clang: &test_ubuntu2004_clang docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-clang-<< pipeline.parameters.ubuntu-2004-clang-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-clang-docker-image >> steps: - checkout - attach_workspace: @@ -138,7 +141,7 @@ defaults: - test_ubuntu2004: &test_ubuntu2004 docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-docker-image >> parallelism: 6 steps: - checkout @@ -374,7 +377,7 @@ jobs: chk_docs_pragma_min_version: docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-docker-image >> environment: TERM: xterm steps: @@ -383,7 +386,7 @@ jobs: b_ubu_clang: &build_ubuntu2004_clang docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-clang-<< pipeline.parameters.ubuntu-2004-clang-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-clang-docker-image >> environment: CC: clang CXX: clang++ @@ -396,7 +399,7 @@ jobs: b_ubu_asan_clang: &build_ubuntu2004_clang docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-clang-<< pipeline.parameters.ubuntu-2004-clang-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-clang-docker-image >> environment: CC: clang CXX: clang++ @@ -410,7 +413,7 @@ jobs: b_ubu: &build_ubuntu2004 resource_class: xlarge docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-docker-image >> environment: MAKEFLAGS: -j 10 steps: @@ -427,7 +430,7 @@ jobs: b_ubu18: &build_ubuntu1804 docker: - - image: ethereum/solidity-buildpack-deps:ubuntu1804-<< pipeline.parameters.ubuntu-1804-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-1804-docker-image >> environment: CMAKE_OPTIONS: -DCMAKE_CXX_FLAGS=-O2 CMAKE_BUILD_TYPE: RelWithDebugInfo @@ -481,7 +484,7 @@ jobs: b_ubu_ossfuzz: &build_ubuntu1604_clang docker: - - image: ethereum/solidity-buildpack-deps:ubuntu1604-clang-ossfuzz-<< pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >> environment: CC: clang CXX: clang++ @@ -589,7 +592,7 @@ jobs: b_ems: resource_class: xlarge docker: - - image: ethereum/solidity-buildpack-deps:emsdk-1.39.15-2 + - image: << pipeline.parameters.emscripten-docker-image >> environment: MAKEFLAGS: -j 10 TERM: xterm @@ -625,7 +628,7 @@ jobs: b_docs: docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-docker-image >> steps: - checkout - run: *setup_prerelease_commit_hash @@ -641,7 +644,7 @@ jobs: t_ubu_soltest_enforce_yul: &t_ubu_soltest_enforce_yul docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-docker-image >> environment: EVM: constantinople SOLTEST_FLAGS: --enforce-via-yul @@ -667,7 +670,7 @@ jobs: t_ubu_cli: &t_ubu_cli docker: - - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + - image: << pipeline.parameters.ubuntu-2004-docker-image >> environment: TERM: xterm steps: diff --git a/.travis.yml b/.travis.yml index e20a4d202..3d00a974d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,7 +113,7 @@ matrix: before_install: - nvm install 10 - nvm use 10 - - docker pull ethereum/solidity-buildpack-deps:emsdk-1.39.15-2 + - docker pull solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc env: - SOLC_EMSCRIPTEN=On - SOLC_INSTALL_DEPS_TRAVIS=Off diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 7a052aa77..f4b0fe647 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -34,5 +34,6 @@ else BUILD_DIR="$1" fi -docker run -v $(pwd):/root/project -w /root/project ethereum/solidity-buildpack-deps:emsdk-1.39.15-2 \ +docker run -v $(pwd):/root/project -w /root/project \ + solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc \ ./scripts/travis-emscripten/build_emscripten.sh $BUILD_DIR From 579e4b5a6949581eb9cac3cc1be2114b804c7fff Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 8 Jul 2020 12:54:52 +0200 Subject: [PATCH 48/71] Report all stack errors in the EVM code transform. --- libyul/CompilabilityChecker.cpp | 9 +---- libyul/backends/evm/AsmCodeGen.cpp | 12 ++---- libyul/backends/evm/EVMCodeTransform.cpp | 47 +++++++++-------------- libyul/backends/evm/EVMObjectCompiler.cpp | 3 +- test/libyul/CompilabilityChecker.cpp | 4 +- 5 files changed, 27 insertions(+), 48 deletions(-) diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 344266a12..0d80a510f 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -59,14 +59,7 @@ map CompilabilityChecker::run( builtinContext, _optimizeStackAllocation ); - try - { - transform(*_object.code); - } - catch (StackTooDeepError const&) - { - yulAssert(!transform.stackErrors().empty(), "Got stack too deep exception that was not stored."); - } + transform(*_object.code); std::map functions; for (StackTooDeepError const& error: transform.stackErrors()) diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 327ce8895..8c6f672ab 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -231,18 +231,12 @@ void CodeGenerator::assemble( _identifierAccess, _useNamedLabelsForFunctions ); - try - { - transform(_parsedData); - } - catch (StackTooDeepError const& _e) - { + transform(_parsedData); + if (!transform.stackErrors().empty()) assertThrow( false, langutil::StackTooDeepError, "Stack too deep when compiling inline assembly" + - (_e.comment() ? ": " + *_e.comment() : ".") + (transform.stackErrors().front().comment() ? ": " + *transform.stackErrors().front().comment() : ".") ); - } - yulAssert(transform.stackErrors().empty(), "Stack errors present but not thrown."); } diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 041e00380..0287f585d 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -435,31 +435,24 @@ void CodeTransform::operator()(FunctionDefinition const& _function) m_context->functionExitPoints.push( CodeTransformContext::JumpInfo{m_assembly.newLabelId(), m_assembly.stackHeight()} ); - try + CodeTransform subTransform( + m_assembly, + m_info, + _function.body, + m_allowStackOpt, + m_dialect, + m_builtinContext, + m_evm15, + m_identifierAccess, + m_useNamedLabelsForFunctions, + m_context + ); + subTransform(_function.body); + for (auto& stackError: subTransform.m_stackErrors) { - CodeTransform( - m_assembly, - m_info, - _function.body, - m_allowStackOpt, - m_dialect, - m_builtinContext, - m_evm15, - m_identifierAccess, - m_useNamedLabelsForFunctions, - m_context - )(_function.body); - } - catch (StackTooDeepError const& _error) - { - // This exception will be re-thrown after the end of the surrounding block. - // It enables us to see which functions compiled successfully and which did not. - // Even if we emit actual code, add an illegal instruction to make sure that tests - // will catch it. - StackTooDeepError error(_error); - if (error.functionName.empty()) - error.functionName = _function.name; - stackError(std::move(error), static_cast(height)); + if (stackError.functionName.empty()) + stackError.functionName = _function.name; + m_stackErrors.emplace_back(std::move(stackError)); } m_assembly.appendLabel(m_context->functionExitPoints.top().label); @@ -605,9 +598,6 @@ void CodeTransform::operator()(Block const& _block) finalizeBlock(_block, blockStartStackHeight); m_scope = originalScope; - - if (!m_stackErrors.empty()) - BOOST_THROW_EXCEPTION(m_stackErrors.front()); } AbstractAssembly::LabelID CodeTransform::functionEntryID(YulString _name, Scope::Function const& _function) @@ -728,7 +718,8 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString to_string(heightDiff - limit) + " slot(s) too deep inside the stack." ); - BOOST_THROW_EXCEPTION(m_stackErrors.back()); + // TODO: maybe make this return something special that results in producing INVALID instead. + return _forSwap ? 2 : 1; } return heightDiff; } diff --git a/libyul/backends/evm/EVMObjectCompiler.cpp b/libyul/backends/evm/EVMObjectCompiler.cpp index 6463b4a46..685ca517e 100644 --- a/libyul/backends/evm/EVMObjectCompiler.cpp +++ b/libyul/backends/evm/EVMObjectCompiler.cpp @@ -59,5 +59,6 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize) // which should be native to this part of the code. CodeTransform transform{m_assembly, *_object.analysisInfo, *_object.code, m_dialect, context, _optimize, m_evm15}; transform(*_object.code); - yulAssert(transform.stackErrors().empty(), "Stack errors present but not thrown."); + if (!transform.stackErrors().empty()) + BOOST_THROW_EXCEPTION(transform.stackErrors().front()); } diff --git a/test/libyul/CompilabilityChecker.cpp b/test/libyul/CompilabilityChecker.cpp index 51aefc610..ad1a6fd5e 100644 --- a/test/libyul/CompilabilityChecker.cpp +++ b/test/libyul/CompilabilityChecker.cpp @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(nested) x := add(add(add(add(add(add(add(add(add(add(add(add(x, r12), r11), r10), r9), r8), r7), r6), r5), r4), r3), r2), r1) } })"); - BOOST_CHECK_EQUAL(out, "h: 9 "); + BOOST_CHECK_EQUAL(out, "h: 9 g: 5 f: 5 "); } BOOST_AUTO_TEST_CASE(also_in_outer_block) @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(also_in_outer_block) function g(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19) -> w, v { } })"); - BOOST_CHECK_EQUAL(out, ": 9 "); + BOOST_CHECK_EQUAL(out, "g: 5 : 9 "); } BOOST_AUTO_TEST_SUITE_END() From 92cd1ddb7d6c39965101e8638440832f7e4a6bea Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 15 Jul 2020 11:32:34 +0200 Subject: [PATCH 49/71] Add markAsInvalid to the various assemblies. --- libevmasm/Assembly.cpp | 1 + libevmasm/Assembly.h | 4 ++++ libyul/backends/evm/AbstractAssembly.h | 3 +++ libyul/backends/evm/AsmCodeGen.cpp | 5 +++++ libyul/backends/evm/AsmCodeGen.h | 2 ++ libyul/backends/evm/EVMAssembly.cpp | 1 + libyul/backends/evm/EVMAssembly.h | 3 +++ libyul/backends/evm/EVMCodeTransform.cpp | 15 ++++++++++----- libyul/backends/evm/NoOutputAssembly.h | 2 ++ 9 files changed, 31 insertions(+), 5 deletions(-) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 8588832fe..d70ef9fed 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -521,6 +521,7 @@ map Assembly::optimiseInternal( LinkerObject const& Assembly::assemble() const { + assertThrow(!m_invalid, AssemblyException, "Attempted to assemble invalid Assembly object."); // Return the already assembled object, if present. if (!m_assembledObject.bytecode.empty()) return m_assembledObject; diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index e82fee7dd..3b8c7e3a8 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -142,6 +142,9 @@ public: std::map const& _sourceIndices = std::map() ) const; + /// Mark this assembly as invalid. Calling ``assemble`` on it will throw. + void markAsInvalid() { m_invalid = true; } + protected: /// Does the same operations as @a optimise, but should only be applied to a sub and /// returns the replaced tags. Also takes an argument containing the tags of this assembly @@ -161,6 +164,7 @@ private: ); static std::string toStringInHex(u256 _value); + bool m_invalid = false; protected: /// 0 is reserved for exception unsigned m_usedTags = 1; diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 42622272c..d138968ba 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -111,6 +111,9 @@ public: virtual void appendImmutable(std::string const& _identifier) = 0; /// Appends an assignment to an immutable variable. virtual void appendImmutableAssignment(std::string const& _identifier) = 0; + + /// Mark this assembly as invalid. Any attempt to request bytecode from it should throw. + virtual void markAsInvalid() = 0; }; enum class IdentifierContext { LValue, RValue, VariableDeclaration }; diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 8c6f672ab..8e245f99d 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -182,6 +182,11 @@ void EthAssemblyAdapter::appendImmutableAssignment(std::string const& _identifie m_assembly.appendImmutableAssignment(_identifier); } +void EthAssemblyAdapter::markAsInvalid() +{ + m_assembly.markAsInvalid(); +} + EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag) { u256 id = _tag.data(); diff --git a/libyul/backends/evm/AsmCodeGen.h b/libyul/backends/evm/AsmCodeGen.h index 6ff02009c..4933fbfd2 100644 --- a/libyul/backends/evm/AsmCodeGen.h +++ b/libyul/backends/evm/AsmCodeGen.h @@ -64,6 +64,8 @@ public: void appendImmutable(std::string const& _identifier) override; void appendImmutableAssignment(std::string const& _identifier) override; + void markAsInvalid() override; + private: static LabelID assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag); void appendJumpInstruction(evmasm::Instruction _instruction, JumpType _jumpType); diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 7cf3d0662..0158e7bfa 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -156,6 +156,7 @@ void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter) evmasm::LinkerObject EVMAssembly::finalize() { + yulAssert(!m_invalid, "Attempted to finalize invalid assembly object."); size_t bytecodeSize = m_bytecode.size(); for (auto const& ref: m_assemblySizePositions) updateReference(ref, assemblySizeReferenceSize, u256(bytecodeSize)); diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index 9ee974bbb..858ae3def 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -86,6 +86,8 @@ public: void appendImmutable(std::string const& _identifier) override; void appendImmutableAssignment(std::string const& _identifier) override; + void markAsInvalid() override { m_invalid = true; } + /// Resolves references inside the bytecode and returns the linker object. evmasm::LinkerObject finalize(); @@ -102,6 +104,7 @@ private: std::map m_labelPositions; std::map m_labelReferences; std::vector m_assemblySizePositions; + bool m_invalid = false; }; } diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 0287f585d..df8fb9343 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -237,6 +237,7 @@ void CodeTransform::stackError(StackTooDeepError _error, int _targetStackHeight) m_assembly.appendConstant(u256(0)); // Store error. m_stackErrors.emplace_back(std::move(_error)); + m_assembly.markAsInvalid(); } void CodeTransform::operator()(Assignment const& _assignment) @@ -448,11 +449,15 @@ void CodeTransform::operator()(FunctionDefinition const& _function) m_context ); subTransform(_function.body); - for (auto& stackError: subTransform.m_stackErrors) + if (!subTransform.m_stackErrors.empty()) { - if (stackError.functionName.empty()) - stackError.functionName = _function.name; - m_stackErrors.emplace_back(std::move(stackError)); + m_assembly.markAsInvalid(); + for (StackTooDeepError& stackError: subTransform.m_stackErrors) + { + if (stackError.functionName.empty()) + stackError.functionName = _function.name; + m_stackErrors.emplace_back(std::move(stackError)); + } } m_assembly.appendLabel(m_context->functionExitPoints.top().label); @@ -718,7 +723,7 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString to_string(heightDiff - limit) + " slot(s) too deep inside the stack." ); - // TODO: maybe make this return something special that results in producing INVALID instead. + m_assembly.markAsInvalid(); return _forSwap ? 2 : 1; } return heightDiff; diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index ec7e5f2ec..a5bcecd2c 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -74,6 +74,8 @@ public: void appendImmutable(std::string const& _identifier) override; void appendImmutableAssignment(std::string const& _identifier) override; + void markAsInvalid() override {} + private: bool m_evm15 = false; ///< if true, switch to evm1.5 mode int m_stackHeight = 0; From 672633af0adc369aea4394464e2d8fa3519a37de Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Thu, 16 Jul 2020 16:47:36 +0200 Subject: [PATCH 50/71] [SMTChecker] Fix ICE on compound assignment to array index --- Changelog.md | 1 + libsolidity/formal/SMTEncoder.cpp | 6 +++++- .../operators/compound_bitwise_or_1.sol | 11 ++++------- .../operators/compound_bitwise_or_2.sol | 10 ++++++++++ .../operators/compound_bitwise_or_3.sol | 16 ++++++++++++++++ .../operators/compound_bitwise_or_4.sol | 17 +++++++++++++++++ 6 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_2.sol create mode 100644 test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_3.sol create mode 100644 test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_4.sol diff --git a/Changelog.md b/Changelog.md index 0f0e533b9..46c02667e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ Compiler Features: Bugfixes: * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. + * SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches. * Type Checker: Fix overload resolution in combination with ``{value: ...}``. * Type Checker: Fix internal compiler error related to oversized types. * Code Generator: Avoid double cleanup when copying to memory. diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 6a4030511..ac87bade1 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -363,8 +363,12 @@ void SMTEncoder::endVisit(Assignment const& _assignment) Token op = _assignment.assignmentOperator(); if (op != Token::Assign && !compoundOps.count(op)) { + Expression const* identifier = &_assignment.leftHandSide(); + if (auto const* indexAccess = dynamic_cast(identifier)) + identifier = leftmostBase(*indexAccess); // Give it a new index anyway to keep the SSA scheme sound. - if (auto varDecl = identifierToVariable(_assignment.leftHandSide())) + solAssert(identifier, ""); + if (auto varDecl = identifierToVariable(*identifier)) m_context.newValue(*varDecl); m_errorReporter.warning( diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_1.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_1.sol index a17f2f466..24e61cf58 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_1.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_1.sol @@ -1,13 +1,10 @@ pragma experimental SMTChecker; - contract C { - function f(bool b) public pure { - uint v = 0; + int[1] c; + function f(bool b) public { if (b) - v |= 1; - assert(v == 1); + c[0] |= 1; } } // ---- -// Warning 9149: (106-112): Assertion checker does not yet implement this assignment operator. -// Warning 4661: (116-130): Assertion violation happens here +// Warning 9149: (97-106): Assertion checker does not yet implement this assignment operator. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_2.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_2.sol new file mode 100644 index 000000000..4569afa88 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_2.sol @@ -0,0 +1,10 @@ +pragma experimental SMTChecker; +contract C { + int[1][20] c; + function f(bool b) public { + if (b) + c[10][0] |= 1; + } +} +// ---- +// Warning 9149: (101-114): Assertion checker does not yet implement this assignment operator. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_3.sol new file mode 100644 index 000000000..617ae7af3 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_3.sol @@ -0,0 +1,16 @@ +pragma experimental SMTChecker; +contract C { + struct S { + uint x; + } + S s; + function f(bool b) public { + if (b) + s.x |= 1; + } +} +// ---- +// Warning 8115: (71-74): Assertion checker does not yet support the type of this variable. +// Warning 7650: (117-120): Assertion checker does not yet support this expression. +// Warning 8364: (117-118): Assertion checker does not yet implement type struct C.S storage ref +// Warning 9149: (117-125): Assertion checker does not yet implement this assignment operator. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_4.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_4.sol new file mode 100644 index 000000000..091f0ca0d --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_4.sol @@ -0,0 +1,17 @@ +pragma experimental SMTChecker; +contract C { + struct S { + uint[] x; + } + S s; + function f(bool b) public { + if (b) + s.x[2] |= 1; + } +} +// ---- +// Warning 8115: (73-76): Assertion checker does not yet support the type of this variable. +// Warning 7650: (119-122): Assertion checker does not yet support this expression. +// Warning 8364: (119-120): Assertion checker does not yet implement type struct C.S storage ref +// Warning 9118: (119-125): Assertion checker does not yet implement this expression. +// Warning 9149: (119-130): Assertion checker does not yet implement this assignment operator. From 2e1067a05ac5ab672f56fc51abac0d28a61195ff Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 17 Jul 2020 10:49:36 +0200 Subject: [PATCH 51/71] Set type properly for event parameters --- Changelog.md | 1 + libsolidity/analysis/TypeChecker.cpp | 2 +- .../smtCheckerTests/types/event_with_rational_size_array.sol | 2 ++ .../syntaxTests/types/event_with_rational_size_array.sol | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/smtCheckerTests/types/event_with_rational_size_array.sol create mode 100644 test/libsolidity/syntaxTests/types/event_with_rational_size_array.sol diff --git a/Changelog.md b/Changelog.md index 46c02667e..e0987a919 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ Compiler Features: Bugfixes: * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. * SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches. + * SMTChecker: Fix error in events with indices of type static array. * Type Checker: Fix overload resolution in combination with ``{value: ...}``. * Type Checker: Fix internal compiler error related to oversized types. * Code Generator: Avoid double cleanup when copying to memory. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 94d9544df..a81520b05 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -664,7 +664,7 @@ bool TypeChecker::visit(EventDefinition const& _eventDef) m_errorReporter.typeError(8598_error, _eventDef.location(), "More than 4 indexed arguments for anonymous event."); else if (!_eventDef.isAnonymous() && numIndexed > 3) m_errorReporter.typeError(7249_error, _eventDef.location(), "More than 3 indexed arguments for event."); - return false; + return true; } void TypeChecker::endVisit(FunctionTypeName const& _funType) diff --git a/test/libsolidity/smtCheckerTests/types/event_with_rational_size_array.sol b/test/libsolidity/smtCheckerTests/types/event_with_rational_size_array.sol new file mode 100644 index 000000000..98dfcec33 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/event_with_rational_size_array.sol @@ -0,0 +1,2 @@ +pragma experimental SMTChecker; +contract a { event b(uint[(1 / 1)]); } diff --git a/test/libsolidity/syntaxTests/types/event_with_rational_size_array.sol b/test/libsolidity/syntaxTests/types/event_with_rational_size_array.sol new file mode 100644 index 000000000..d0846345a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/event_with_rational_size_array.sol @@ -0,0 +1 @@ +contract a { event b(uint[(1 / 1)]); } From b7adb2aa424cdec2ff0d51042dcf5aa7cadb3e3e Mon Sep 17 00:00:00 2001 From: Sachin Grover Date: Fri, 17 Jul 2020 20:24:12 +0530 Subject: [PATCH 52/71] Add SPDX license identifier if not present already in source file Fixes: #9220 --- libevmasm/Assembly.cpp | 1 + libevmasm/Assembly.h | 1 + libevmasm/AssemblyItem.cpp | 1 + libevmasm/AssemblyItem.h | 1 + libevmasm/BlockDeduplicator.cpp | 1 + libevmasm/BlockDeduplicator.h | 1 + libevmasm/CommonSubexpressionEliminator.cpp | 1 + libevmasm/CommonSubexpressionEliminator.h | 1 + libevmasm/ConstantOptimiser.cpp | 1 + libevmasm/ConstantOptimiser.h | 1 + libevmasm/ControlFlowGraph.cpp | 1 + libevmasm/ControlFlowGraph.h | 1 + libevmasm/Exceptions.h | 1 + libevmasm/ExpressionClasses.cpp | 1 + libevmasm/ExpressionClasses.h | 1 + libevmasm/GasMeter.cpp | 1 + libevmasm/GasMeter.h | 1 + libevmasm/Instruction.cpp | 1 + libevmasm/Instruction.h | 1 + libevmasm/JumpdestRemover.cpp | 1 + libevmasm/JumpdestRemover.h | 1 + libevmasm/KnownState.cpp | 1 + libevmasm/KnownState.h | 1 + libevmasm/LinkerObject.cpp | 1 + libevmasm/LinkerObject.h | 1 + libevmasm/PathGasMeter.cpp | 1 + libevmasm/PathGasMeter.h | 1 + libevmasm/PeepholeOptimiser.cpp | 1 + libevmasm/PeepholeOptimiser.h | 1 + libevmasm/RuleList.h | 1 + libevmasm/SemanticInformation.cpp | 1 + libevmasm/SemanticInformation.h | 1 + libevmasm/SimplificationRule.h | 1 + libevmasm/SimplificationRules.cpp | 1 + libevmasm/SimplificationRules.h | 1 + liblangutil/EVMVersion.cpp | 1 + liblangutil/EVMVersion.h | 1 + liblangutil/ErrorReporter.cpp | 1 + liblangutil/ErrorReporter.h | 1 + liblangutil/Exceptions.cpp | 1 + liblangutil/Exceptions.h | 1 + liblangutil/ParserBase.cpp | 1 + liblangutil/ParserBase.h | 1 + liblangutil/SemVerHandler.cpp | 1 + liblangutil/SemVerHandler.h | 1 + liblangutil/SourceLocation.cpp | 1 + liblangutil/SourceLocation.h | 1 + liblangutil/SourceReferenceExtractor.cpp | 1 + liblangutil/SourceReferenceExtractor.h | 1 + liblangutil/SourceReferenceFormatter.cpp | 1 + liblangutil/SourceReferenceFormatter.h | 1 + liblangutil/SourceReferenceFormatterHuman.cpp | 1 + liblangutil/SourceReferenceFormatterHuman.h | 1 + liblangutil/UndefMacros.h | 1 + libsmtutil/CHCSmtLib2Interface.cpp | 1 + libsmtutil/CHCSmtLib2Interface.h | 1 + libsmtutil/CHCSolverInterface.h | 1 + libsmtutil/CVC4Interface.cpp | 1 + libsmtutil/CVC4Interface.h | 1 + libsmtutil/Exceptions.h | 1 + libsmtutil/SMTLib2Interface.cpp | 1 + libsmtutil/SMTLib2Interface.h | 1 + libsmtutil/SMTPortfolio.cpp | 1 + libsmtutil/SMTPortfolio.h | 1 + libsmtutil/SolverInterface.h | 1 + libsmtutil/Sorts.cpp | 1 + libsmtutil/Sorts.h | 1 + libsmtutil/Z3CHCInterface.cpp | 1 + libsmtutil/Z3CHCInterface.h | 1 + libsmtutil/Z3Interface.cpp | 1 + libsmtutil/Z3Interface.h | 1 + libsolc/libsolc.cpp | 1 + libsolc/libsolc.h | 1 + libsolidity/analysis/ConstantEvaluator.cpp | 1 + libsolidity/analysis/ConstantEvaluator.h | 1 + libsolidity/analysis/ContractLevelChecker.cpp | 1 + libsolidity/analysis/ContractLevelChecker.h | 1 + libsolidity/analysis/ControlFlowAnalyzer.cpp | 1 + libsolidity/analysis/ControlFlowAnalyzer.h | 1 + libsolidity/analysis/ControlFlowBuilder.cpp | 1 + libsolidity/analysis/ControlFlowBuilder.h | 1 + libsolidity/analysis/ControlFlowGraph.cpp | 1 + libsolidity/analysis/ControlFlowGraph.h | 1 + libsolidity/analysis/DeclarationContainer.cpp | 1 + libsolidity/analysis/DeclarationContainer.h | 1 + libsolidity/analysis/DeclarationTypeChecker.cpp | 1 + libsolidity/analysis/DeclarationTypeChecker.h | 1 + libsolidity/analysis/DocStringAnalyser.cpp | 1 + libsolidity/analysis/DocStringAnalyser.h | 1 + libsolidity/analysis/GlobalContext.cpp | 1 + libsolidity/analysis/GlobalContext.h | 1 + libsolidity/analysis/ImmutableValidator.cpp | 1 + libsolidity/analysis/ImmutableValidator.h | 1 + libsolidity/analysis/NameAndTypeResolver.cpp | 1 + libsolidity/analysis/NameAndTypeResolver.h | 1 + libsolidity/analysis/OverrideChecker.cpp | 1 + libsolidity/analysis/OverrideChecker.h | 1 + libsolidity/analysis/PostTypeChecker.cpp | 1 + libsolidity/analysis/PostTypeChecker.h | 1 + libsolidity/analysis/ReferencesResolver.cpp | 1 + libsolidity/analysis/ReferencesResolver.h | 1 + libsolidity/analysis/StaticAnalyzer.cpp | 1 + libsolidity/analysis/StaticAnalyzer.h | 1 + libsolidity/analysis/SyntaxChecker.cpp | 1 + libsolidity/analysis/SyntaxChecker.h | 1 + libsolidity/analysis/TypeChecker.cpp | 1 + libsolidity/analysis/TypeChecker.h | 1 + libsolidity/analysis/ViewPureChecker.cpp | 1 + libsolidity/analysis/ViewPureChecker.h | 1 + libsolidity/ast/AST.cpp | 1 + libsolidity/ast/AST.h | 1 + libsolidity/ast/ASTAnnotations.cpp | 1 + libsolidity/ast/ASTAnnotations.h | 1 + libsolidity/ast/ASTEnums.h | 1 + libsolidity/ast/ASTForward.h | 1 + libsolidity/ast/ASTJsonConverter.cpp | 1 + libsolidity/ast/ASTJsonConverter.h | 1 + libsolidity/ast/ASTJsonImporter.cpp | 1 + libsolidity/ast/ASTJsonImporter.h | 1 + libsolidity/ast/ASTUtils.cpp | 1 + libsolidity/ast/ASTUtils.h | 1 + libsolidity/ast/ASTVisitor.h | 1 + libsolidity/ast/AST_accept.h | 1 + libsolidity/ast/AsmJsonImporter.cpp | 1 + libsolidity/ast/AsmJsonImporter.h | 1 + libsolidity/ast/ExperimentalFeatures.h | 1 + libsolidity/ast/TypeProvider.cpp | 1 + libsolidity/ast/TypeProvider.h | 1 + libsolidity/ast/Types.cpp | 1 + libsolidity/ast/Types.h | 1 + libsolidity/codegen/ABIFunctions.cpp | 1 + libsolidity/codegen/ABIFunctions.h | 1 + libsolidity/codegen/ArrayUtils.cpp | 1 + libsolidity/codegen/ArrayUtils.h | 1 + libsolidity/codegen/Compiler.cpp | 1 + libsolidity/codegen/Compiler.h | 1 + libsolidity/codegen/CompilerContext.cpp | 1 + libsolidity/codegen/CompilerContext.h | 1 + libsolidity/codegen/CompilerUtils.cpp | 1 + libsolidity/codegen/CompilerUtils.h | 1 + libsolidity/codegen/ContractCompiler.cpp | 1 + libsolidity/codegen/ContractCompiler.h | 1 + libsolidity/codegen/ExpressionCompiler.cpp | 1 + libsolidity/codegen/ExpressionCompiler.h | 1 + libsolidity/codegen/LValue.cpp | 1 + libsolidity/codegen/LValue.h | 1 + libsolidity/codegen/MultiUseYulFunctionCollector.cpp | 1 + libsolidity/codegen/MultiUseYulFunctionCollector.h | 1 + libsolidity/codegen/ReturnInfo.cpp | 1 + libsolidity/codegen/ReturnInfo.h | 1 + libsolidity/codegen/YulUtilFunctions.cpp | 1 + libsolidity/codegen/YulUtilFunctions.h | 1 + libsolidity/codegen/ir/Common.cpp | 1 + libsolidity/codegen/ir/Common.h | 1 + libsolidity/codegen/ir/IRGenerationContext.cpp | 1 + libsolidity/codegen/ir/IRGenerationContext.h | 1 + libsolidity/codegen/ir/IRGenerator.cpp | 1 + libsolidity/codegen/ir/IRGenerator.h | 1 + libsolidity/codegen/ir/IRGeneratorForStatements.cpp | 1 + libsolidity/codegen/ir/IRGeneratorForStatements.h | 1 + libsolidity/codegen/ir/IRLValue.h | 1 + libsolidity/codegen/ir/IRVariable.cpp | 1 + libsolidity/codegen/ir/IRVariable.h | 1 + libsolidity/formal/BMC.cpp | 1 + libsolidity/formal/BMC.h | 1 + libsolidity/formal/CHC.cpp | 1 + libsolidity/formal/CHC.h | 1 + libsolidity/formal/EncodingContext.cpp | 1 + libsolidity/formal/EncodingContext.h | 1 + libsolidity/formal/ModelChecker.cpp | 1 + libsolidity/formal/ModelChecker.h | 1 + libsolidity/formal/SMTEncoder.cpp | 1 + libsolidity/formal/SMTEncoder.h | 1 + libsolidity/formal/SSAVariable.cpp | 1 + libsolidity/formal/SSAVariable.h | 1 + libsolidity/formal/SymbolicState.cpp | 1 + libsolidity/formal/SymbolicState.h | 1 + libsolidity/formal/SymbolicTypes.cpp | 1 + libsolidity/formal/SymbolicTypes.h | 1 + libsolidity/formal/SymbolicVariables.cpp | 1 + libsolidity/formal/SymbolicVariables.h | 1 + libsolidity/formal/VariableUsage.cpp | 1 + libsolidity/formal/VariableUsage.h | 1 + libsolidity/interface/ABI.cpp | 1 + libsolidity/interface/ABI.h | 1 + libsolidity/interface/CompilerStack.cpp | 1 + libsolidity/interface/CompilerStack.h | 1 + libsolidity/interface/DebugSettings.h | 1 + libsolidity/interface/GasEstimator.cpp | 1 + libsolidity/interface/GasEstimator.h | 1 + libsolidity/interface/Natspec.cpp | 1 + libsolidity/interface/Natspec.h | 1 + libsolidity/interface/OptimiserSettings.h | 1 + libsolidity/interface/ReadFile.h | 1 + libsolidity/interface/StandardCompiler.cpp | 1 + libsolidity/interface/StandardCompiler.h | 1 + libsolidity/interface/StorageLayout.cpp | 1 + libsolidity/interface/StorageLayout.h | 1 + libsolidity/interface/Version.cpp | 1 + libsolidity/interface/Version.h | 1 + libsolidity/parsing/DocStringParser.cpp | 1 + libsolidity/parsing/DocStringParser.h | 1 + libsolidity/parsing/Parser.cpp | 1 + libsolidity/parsing/Parser.h | 1 + libsolidity/parsing/Token.h | 1 + libsolutil/Algorithms.h | 1 + libsolutil/AnsiColorized.h | 1 + libsolutil/Assertions.h | 1 + libsolutil/Common.h | 1 + libsolutil/CommonData.cpp | 1 + libsolutil/CommonData.h | 1 + libsolutil/CommonIO.cpp | 1 + libsolutil/CommonIO.h | 1 + libsolutil/Exceptions.cpp | 1 + libsolutil/Exceptions.h | 1 + libsolutil/FixedHash.h | 1 + libsolutil/IndentedWriter.cpp | 1 + libsolutil/IndentedWriter.h | 1 + libsolutil/InvertibleMap.h | 1 + libsolutil/IpfsHash.cpp | 1 + libsolutil/IpfsHash.h | 1 + libsolutil/JSON.cpp | 1 + libsolutil/JSON.h | 1 + libsolutil/Keccak256.cpp | 1 + libsolutil/Keccak256.h | 1 + libsolutil/LazyInit.h | 1 + libsolutil/Result.h | 1 + libsolutil/StringUtils.cpp | 1 + libsolutil/StringUtils.h | 1 + libsolutil/SwarmHash.cpp | 1 + libsolutil/SwarmHash.h | 1 + libsolutil/UTF8.cpp | 1 + libsolutil/UTF8.h | 1 + libsolutil/Visitor.h | 1 + libsolutil/Whiskers.cpp | 1 + libsolutil/Whiskers.h | 1 + libyul/AsmAnalysis.cpp | 1 + libyul/AsmAnalysis.h | 1 + libyul/AsmAnalysisInfo.h | 1 + libyul/AsmData.h | 1 + libyul/AsmDataForward.h | 1 + libyul/AsmJsonConverter.cpp | 1 + libyul/AsmJsonConverter.h | 1 + libyul/AsmParser.cpp | 1 + libyul/AsmParser.h | 1 + libyul/AsmPrinter.cpp | 1 + libyul/AsmPrinter.h | 1 + libyul/AsmScope.cpp | 1 + libyul/AsmScope.h | 1 + libyul/AsmScopeFiller.cpp | 1 + libyul/AsmScopeFiller.h | 1 + libyul/AssemblyStack.cpp | 1 + libyul/AssemblyStack.h | 1 + libyul/CompilabilityChecker.h | 1 + libyul/ControlFlowSideEffects.h | 1 + libyul/Dialect.cpp | 1 + libyul/Dialect.h | 1 + libyul/Exceptions.h | 1 + libyul/Object.cpp | 1 + libyul/Object.h | 1 + libyul/ObjectParser.cpp | 1 + libyul/ObjectParser.h | 1 + libyul/SideEffects.h | 1 + libyul/Utilities.cpp | 1 + libyul/Utilities.h | 1 + libyul/YulString.h | 1 + libyul/backends/evm/AbstractAssembly.h | 1 + libyul/backends/evm/AsmCodeGen.cpp | 1 + libyul/backends/evm/AsmCodeGen.h | 1 + libyul/backends/evm/ConstantOptimiser.cpp | 1 + libyul/backends/evm/ConstantOptimiser.h | 1 + libyul/backends/evm/EVMAssembly.cpp | 1 + libyul/backends/evm/EVMAssembly.h | 1 + libyul/backends/evm/EVMCodeTransform.cpp | 1 + libyul/backends/evm/EVMCodeTransform.h | 1 + libyul/backends/evm/EVMDialect.cpp | 1 + libyul/backends/evm/EVMDialect.h | 1 + libyul/backends/evm/EVMMetrics.cpp | 1 + libyul/backends/evm/EVMMetrics.h | 1 + libyul/backends/evm/EVMObjectCompiler.cpp | 1 + libyul/backends/evm/EVMObjectCompiler.h | 1 + libyul/backends/evm/NoOutputAssembly.cpp | 1 + libyul/backends/evm/NoOutputAssembly.h | 1 + libyul/backends/wasm/BinaryTransform.cpp | 1 + libyul/backends/wasm/BinaryTransform.h | 1 + libyul/backends/wasm/EVMToEwasmTranslator.cpp | 1 + libyul/backends/wasm/EVMToEwasmTranslator.h | 1 + libyul/backends/wasm/TextTransform.cpp | 1 + libyul/backends/wasm/TextTransform.h | 1 + libyul/backends/wasm/WasmAST.h | 1 + libyul/backends/wasm/WasmCodeTransform.cpp | 1 + libyul/backends/wasm/WasmCodeTransform.h | 1 + libyul/backends/wasm/WasmDialect.cpp | 1 + libyul/backends/wasm/WasmDialect.h | 1 + libyul/backends/wasm/WasmObjectCompiler.cpp | 1 + libyul/backends/wasm/WasmObjectCompiler.h | 1 + libyul/backends/wasm/WordSizeTransform.cpp | 1 + libyul/backends/wasm/WordSizeTransform.h | 1 + libyul/optimiser/ASTCopier.cpp | 1 + libyul/optimiser/ASTCopier.h | 1 + libyul/optimiser/ASTWalker.cpp | 1 + libyul/optimiser/ASTWalker.h | 1 + libyul/optimiser/BlockFlattener.cpp | 1 + libyul/optimiser/BlockFlattener.h | 1 + libyul/optimiser/BlockHasher.cpp | 1 + libyul/optimiser/BlockHasher.h | 1 + libyul/optimiser/CallGraphGenerator.cpp | 1 + libyul/optimiser/CallGraphGenerator.h | 1 + libyul/optimiser/CircularReferencesPruner.cpp | 1 + libyul/optimiser/CircularReferencesPruner.h | 1 + libyul/optimiser/CommonSubexpressionEliminator.h | 1 + libyul/optimiser/ConditionalSimplifier.cpp | 1 + libyul/optimiser/ConditionalSimplifier.h | 1 + libyul/optimiser/ConditionalUnsimplifier.cpp | 1 + libyul/optimiser/ConditionalUnsimplifier.h | 1 + libyul/optimiser/ControlFlowSimplifier.cpp | 1 + libyul/optimiser/ControlFlowSimplifier.h | 1 + libyul/optimiser/DataFlowAnalyzer.h | 1 + libyul/optimiser/DeadCodeEliminator.cpp | 1 + libyul/optimiser/DeadCodeEliminator.h | 1 + libyul/optimiser/Disambiguator.cpp | 1 + libyul/optimiser/Disambiguator.h | 1 + libyul/optimiser/EquivalentFunctionCombiner.cpp | 1 + libyul/optimiser/EquivalentFunctionCombiner.h | 1 + libyul/optimiser/EquivalentFunctionDetector.cpp | 1 + libyul/optimiser/EquivalentFunctionDetector.h | 1 + libyul/optimiser/ExpressionInliner.cpp | 1 + libyul/optimiser/ExpressionInliner.h | 1 + libyul/optimiser/ExpressionJoiner.cpp | 1 + libyul/optimiser/ExpressionJoiner.h | 1 + libyul/optimiser/ExpressionSimplifier.cpp | 1 + libyul/optimiser/ExpressionSimplifier.h | 1 + libyul/optimiser/ExpressionSplitter.cpp | 1 + libyul/optimiser/ExpressionSplitter.h | 1 + libyul/optimiser/ForLoopConditionIntoBody.cpp | 1 + libyul/optimiser/ForLoopConditionIntoBody.h | 1 + libyul/optimiser/ForLoopConditionOutOfBody.cpp | 1 + libyul/optimiser/ForLoopConditionOutOfBody.h | 1 + libyul/optimiser/ForLoopInitRewriter.cpp | 1 + libyul/optimiser/ForLoopInitRewriter.h | 1 + libyul/optimiser/FullInliner.cpp | 1 + libyul/optimiser/FullInliner.h | 1 + libyul/optimiser/FunctionGrouper.cpp | 1 + libyul/optimiser/FunctionGrouper.h | 1 + libyul/optimiser/FunctionHoister.cpp | 1 + libyul/optimiser/FunctionHoister.h | 1 + libyul/optimiser/InlinableExpressionFunctionFinder.cpp | 1 + libyul/optimiser/InlinableExpressionFunctionFinder.h | 1 + libyul/optimiser/KnowledgeBase.cpp | 1 + libyul/optimiser/KnowledgeBase.h | 1 + libyul/optimiser/LoadResolver.cpp | 1 + libyul/optimiser/LoadResolver.h | 1 + libyul/optimiser/LoopInvariantCodeMotion.cpp | 1 + libyul/optimiser/LoopInvariantCodeMotion.h | 1 + libyul/optimiser/MainFunction.cpp | 1 + libyul/optimiser/MainFunction.h | 1 + libyul/optimiser/Metrics.h | 1 + libyul/optimiser/NameCollector.cpp | 1 + libyul/optimiser/NameCollector.h | 1 + libyul/optimiser/NameDispenser.cpp | 1 + libyul/optimiser/NameDispenser.h | 1 + libyul/optimiser/NameDisplacer.cpp | 1 + libyul/optimiser/NameDisplacer.h | 1 + libyul/optimiser/OptimiserStep.h | 1 + libyul/optimiser/OptimizerUtilities.cpp | 1 + libyul/optimiser/OptimizerUtilities.h | 1 + libyul/optimiser/RedundantAssignEliminator.cpp | 1 + libyul/optimiser/RedundantAssignEliminator.h | 1 + libyul/optimiser/Rematerialiser.h | 1 + libyul/optimiser/SSAReverser.cpp | 1 + libyul/optimiser/SSAReverser.h | 1 + libyul/optimiser/SSATransform.cpp | 1 + libyul/optimiser/SSATransform.h | 1 + libyul/optimiser/SSAValueTracker.cpp | 1 + libyul/optimiser/SSAValueTracker.h | 1 + libyul/optimiser/Semantics.cpp | 1 + libyul/optimiser/Semantics.h | 1 + libyul/optimiser/SimplificationRules.cpp | 1 + libyul/optimiser/SimplificationRules.h | 1 + libyul/optimiser/StackCompressor.h | 1 + libyul/optimiser/StructuralSimplifier.cpp | 1 + libyul/optimiser/StructuralSimplifier.h | 1 + libyul/optimiser/Substitution.cpp | 1 + libyul/optimiser/Substitution.h | 1 + libyul/optimiser/Suite.cpp | 1 + libyul/optimiser/Suite.h | 1 + libyul/optimiser/SyntacticalEquality.h | 1 + libyul/optimiser/TypeInfo.cpp | 1 + libyul/optimiser/TypeInfo.h | 1 + libyul/optimiser/UnusedPruner.h | 1 + libyul/optimiser/VarDeclInitializer.cpp | 1 + libyul/optimiser/VarDeclInitializer.h | 1 + libyul/optimiser/VarNameCleaner.cpp | 1 + libyul/optimiser/VarNameCleaner.h | 1 + solc/CommandLineInterface.cpp | 1 + solc/CommandLineInterface.h | 1 + solc/main.cpp | 1 + test/Common.cpp | 1 + test/Common.h | 1 + test/CommonSyntaxTest.cpp | 1 + test/CommonSyntaxTest.h | 1 + test/EVMHost.cpp | 1 + test/EVMHost.h | 1 + test/ExecutionFramework.cpp | 1 + test/ExecutionFramework.h | 1 + test/InteractiveTests.h | 1 + test/Metadata.cpp | 1 + test/Metadata.h | 1 + test/TestCase.cpp | 1 + test/TestCase.h | 1 + test/TestCaseReader.cpp | 1 + test/TestCaseReader.h | 1 + test/boostTest.cpp | 1 + test/contracts/AuctionRegistrar.cpp | 1 + test/contracts/ContractInterface.h | 1 + test/contracts/FixedFeeRegistrar.cpp | 1 + test/contracts/Wallet.cpp | 1 + test/libevmasm/Assembler.cpp | 1 + test/libevmasm/Optimiser.cpp | 1 + test/liblangutil/CharStream.cpp | 1 + test/liblangutil/SourceLocation.cpp | 1 + test/libsolidity/ABIDecoderTests.cpp | 1 + test/libsolidity/ABIEncoderTests.cpp | 1 + test/libsolidity/ABIJsonTest.h | 1 + test/libsolidity/ABITestsCommon.h | 1 + test/libsolidity/ASTJSONTest.cpp | 1 + test/libsolidity/ASTJSONTest.h | 1 + test/libsolidity/AnalysisFramework.cpp | 1 + test/libsolidity/AnalysisFramework.h | 1 + test/libsolidity/Assembly.cpp | 1 + test/libsolidity/ErrorCheck.cpp | 1 + test/libsolidity/ErrorCheck.h | 1 + test/libsolidity/GasCosts.cpp | 1 + test/libsolidity/GasMeter.cpp | 1 + test/libsolidity/GasTest.cpp | 1 + test/libsolidity/GasTest.h | 1 + test/libsolidity/Imports.cpp | 1 + test/libsolidity/LibSolc.cpp | 1 + test/libsolidity/SMTCheckerJSONTest.cpp | 1 + test/libsolidity/SMTCheckerJSONTest.h | 1 + test/libsolidity/SMTCheckerTest.cpp | 1 + test/libsolidity/SMTCheckerTest.h | 1 + test/libsolidity/SemVerMatcher.cpp | 1 + test/libsolidity/SolidityEndToEndTest.cpp | 1 + test/libsolidity/SolidityExecutionFramework.cpp | 1 + test/libsolidity/SolidityExecutionFramework.h | 1 + test/libsolidity/SolidityExpressionCompiler.cpp | 1 + test/libsolidity/SolidityOptimizer.cpp | 1 + test/libsolidity/SolidityTypes.cpp | 1 + test/libsolidity/StandardCompiler.cpp | 1 + test/libsolidity/SyntaxTest.cpp | 1 + test/libsolidity/SyntaxTest.h | 1 + test/libsolidity/util/BytesUtils.cpp | 1 + test/libsolidity/util/ContractABIUtils.cpp | 1 + test/libsolidity/util/TestFileParser.cpp | 1 + test/libsolidity/util/TestFileParserTests.cpp | 1 + test/libsolidity/util/TestFunctionCallTests.cpp | 1 + test/libsolutil/Checksum.cpp | 1 + test/libsolutil/CommonData.cpp | 1 + test/libsolutil/IndentedWriter.cpp | 1 + test/libsolutil/IpfsHash.cpp | 1 + test/libsolutil/IterateReplacing.cpp | 1 + test/libsolutil/JSON.cpp | 1 + test/libsolutil/Keccak256.cpp | 1 + test/libsolutil/LazyInit.cpp | 1 + test/libsolutil/StringUtils.cpp | 1 + test/libsolutil/SwarmHash.cpp | 1 + test/libsolutil/UTF8.cpp | 1 + test/libsolutil/Whiskers.cpp | 1 + test/libyul/EwasmTranslationTest.cpp | 1 + test/libyul/EwasmTranslationTest.h | 1 + test/libyul/FunctionSideEffects.cpp | 1 + test/libyul/FunctionSideEffects.h | 1 + test/libyul/Inliner.cpp | 1 + test/libyul/ObjectCompilerTest.cpp | 1 + test/libyul/ObjectCompilerTest.h | 1 + test/libyul/SyntaxTest.cpp | 1 + test/libyul/SyntaxTest.h | 1 + test/libyul/YulInterpreterTest.cpp | 1 + test/libyul/YulInterpreterTest.h | 1 + test/libyul/YulOptimizerTest.cpp | 1 + test/libyul/YulOptimizerTest.h | 1 + test/tools/IsolTestOptions.cpp | 1 + test/tools/IsolTestOptions.h | 1 + test/tools/afl_fuzzer.cpp | 1 + test/tools/fuzzer_common.cpp | 1 + test/tools/fuzzer_common.h | 1 + test/tools/isoltest.cpp | 1 + test/tools/ossfuzz/abiV2Proto.proto | 1 + test/tools/ossfuzz/abiV2ProtoFuzzer.cpp | 1 + test/tools/ossfuzz/const_opt_ossfuzz.cpp | 1 + test/tools/ossfuzz/protoToSol.cpp | 1 + test/tools/ossfuzz/protoToSol.h | 1 + test/tools/ossfuzz/protoToYul.cpp | 1 + test/tools/ossfuzz/protoToYul.h | 1 + test/tools/ossfuzz/solProto.proto | 1 + test/tools/ossfuzz/solProtoFuzzer.cpp | 1 + test/tools/ossfuzz/solc_noopt_ossfuzz.cpp | 1 + test/tools/ossfuzz/solc_opt_ossfuzz.cpp | 1 + test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp | 1 + test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp | 1 + test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp | 1 + test/tools/ossfuzz/yulFuzzerCommon.cpp | 1 + test/tools/ossfuzz/yulFuzzerCommon.h | 1 + test/tools/ossfuzz/yulProto.proto | 1 + test/tools/ossfuzz/yulProtoFuzzer.cpp | 1 + test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp | 1 + test/tools/yulInterpreter/EVMInstructionInterpreter.cpp | 1 + test/tools/yulInterpreter/EVMInstructionInterpreter.h | 1 + test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp | 1 + test/tools/yulInterpreter/EwasmBuiltinInterpreter.h | 1 + test/tools/yulInterpreter/Interpreter.cpp | 1 + test/tools/yulInterpreter/Interpreter.h | 1 + test/tools/yulopti.cpp | 1 + test/tools/yulrun.cpp | 1 + test/yulPhaser/AlgorithmRunner.cpp | 1 + test/yulPhaser/Chromosome.cpp | 1 + test/yulPhaser/Common.cpp | 1 + test/yulPhaser/FitnessMetrics.cpp | 1 + test/yulPhaser/GeneticAlgorithms.cpp | 1 + test/yulPhaser/Mutations.cpp | 1 + test/yulPhaser/PairSelections.cpp | 1 + test/yulPhaser/Phaser.cpp | 1 + test/yulPhaser/Population.cpp | 1 + test/yulPhaser/Program.cpp | 1 + test/yulPhaser/ProgramCache.cpp | 1 + test/yulPhaser/Selections.cpp | 1 + test/yulPhaser/SimulationRNG.cpp | 1 + test/yulPhaser/TestHelpers.cpp | 1 + test/yulPhaser/TestHelpers.h | 1 + test/yulPhaser/TestHelpersTest.cpp | 1 + tools/solidityUpgrade/SourceTransform.h | 1 + tools/solidityUpgrade/SourceUpgrade.cpp | 1 + tools/solidityUpgrade/SourceUpgrade.h | 1 + tools/solidityUpgrade/Upgrade050.cpp | 1 + tools/solidityUpgrade/Upgrade050.h | 1 + tools/solidityUpgrade/Upgrade060.cpp | 1 + tools/solidityUpgrade/Upgrade060.h | 1 + tools/solidityUpgrade/UpgradeChange.cpp | 1 + tools/solidityUpgrade/UpgradeSuite.h | 1 + tools/solidityUpgrade/main.cpp | 1 + tools/yulPhaser/AlgorithmRunner.cpp | 1 + tools/yulPhaser/AlgorithmRunner.h | 1 + tools/yulPhaser/Chromosome.cpp | 1 + tools/yulPhaser/Chromosome.h | 1 + tools/yulPhaser/Common.cpp | 1 + tools/yulPhaser/Common.h | 1 + tools/yulPhaser/Exceptions.h | 1 + tools/yulPhaser/FitnessMetrics.cpp | 1 + tools/yulPhaser/FitnessMetrics.h | 1 + tools/yulPhaser/GeneticAlgorithms.cpp | 1 + tools/yulPhaser/GeneticAlgorithms.h | 1 + tools/yulPhaser/Mutations.cpp | 1 + tools/yulPhaser/Mutations.h | 1 + tools/yulPhaser/PairSelections.cpp | 1 + tools/yulPhaser/PairSelections.h | 1 + tools/yulPhaser/Phaser.cpp | 1 + tools/yulPhaser/Phaser.h | 1 + tools/yulPhaser/Population.cpp | 1 + tools/yulPhaser/Population.h | 1 + tools/yulPhaser/Program.cpp | 1 + tools/yulPhaser/Program.h | 1 + tools/yulPhaser/ProgramCache.cpp | 1 + tools/yulPhaser/ProgramCache.h | 1 + tools/yulPhaser/Selections.cpp | 1 + tools/yulPhaser/Selections.h | 1 + tools/yulPhaser/SimulationRNG.cpp | 1 + tools/yulPhaser/SimulationRNG.h | 1 + tools/yulPhaser/main.cpp | 1 + 569 files changed, 569 insertions(+) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 8588832fe..70fc4565d 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Assembly.cpp * @author Gav Wood * @date 2014 diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index e82fee7dd..dbd5e130e 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index b78c0e60c..80d34f57c 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index 4b0b7ca72..dd65b109f 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file AssemblyItem.h * @author Gav Wood * @date 2014 diff --git a/libevmasm/BlockDeduplicator.cpp b/libevmasm/BlockDeduplicator.cpp index 95aba2a01..5f9fa768f 100644 --- a/libevmasm/BlockDeduplicator.cpp +++ b/libevmasm/BlockDeduplicator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file BlockDeduplicator.cpp * @author Christian diff --git a/libevmasm/BlockDeduplicator.h b/libevmasm/BlockDeduplicator.h index ce12b4bfb..ef131ae52 100644 --- a/libevmasm/BlockDeduplicator.h +++ b/libevmasm/BlockDeduplicator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file BlockDeduplicator.h * @author Christian diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index 7fa5c938b..9d07e47ca 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file CommonSubexpressionEliminator.cpp * @author Christian diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h index ce9c898ee..88e559719 100644 --- a/libevmasm/CommonSubexpressionEliminator.h +++ b/libevmasm/CommonSubexpressionEliminator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file CommonSubexpressionEliminator.h * @author Christian diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index 018be38ea..87ef57089 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file ConstantOptimiser.cpp * @author Christian * @date 2015 diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index a9db47ab1..aad0fd169 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file ConstantOptimiser.cpp * @author Christian * @date 2015 diff --git a/libevmasm/ControlFlowGraph.cpp b/libevmasm/ControlFlowGraph.cpp index 4c9d59c8b..8431fb51c 100644 --- a/libevmasm/ControlFlowGraph.cpp +++ b/libevmasm/ControlFlowGraph.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file ControlFlowGraph.cpp * @author Christian diff --git a/libevmasm/ControlFlowGraph.h b/libevmasm/ControlFlowGraph.h index 5fceb6388..d27702c2a 100644 --- a/libevmasm/ControlFlowGraph.h +++ b/libevmasm/ControlFlowGraph.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file ControlFlowGraph.h * @author Christian diff --git a/libevmasm/Exceptions.h b/libevmasm/Exceptions.h index e4fadb53c..027577576 100644 --- a/libevmasm/Exceptions.h +++ b/libevmasm/Exceptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Exceptions.h * @author Christian * @date 2014 diff --git a/libevmasm/ExpressionClasses.cpp b/libevmasm/ExpressionClasses.cpp index a208fabe7..55a3a04c7 100644 --- a/libevmasm/ExpressionClasses.cpp +++ b/libevmasm/ExpressionClasses.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file ExpressionClasses.cpp * @author Christian diff --git a/libevmasm/ExpressionClasses.h b/libevmasm/ExpressionClasses.h index f9eebabd0..bfab317dc 100644 --- a/libevmasm/ExpressionClasses.h +++ b/libevmasm/ExpressionClasses.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file ExpressionClasses.h * @author Christian diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 6a07e9905..eb259ba62 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libevmasm/GasMeter.h b/libevmasm/GasMeter.h index a6c0f29d9..ddba491aa 100644 --- a/libevmasm/GasMeter.h +++ b/libevmasm/GasMeter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file GasMeter.cpp * @author Christian * @date 2015 diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 0a61fbea0..55af2340a 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Instruction.cpp * @author Gav Wood * @date 2014 diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 67a77f0c9..5c8eeb3ee 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Instruction.h * @author Gav Wood * @date 2014 diff --git a/libevmasm/JumpdestRemover.cpp b/libevmasm/JumpdestRemover.cpp index cbb498c01..c4901700f 100644 --- a/libevmasm/JumpdestRemover.cpp +++ b/libevmasm/JumpdestRemover.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * Removes unused JUMPDESTs. diff --git a/libevmasm/JumpdestRemover.h b/libevmasm/JumpdestRemover.h index 80b546d79..e07550e2d 100644 --- a/libevmasm/JumpdestRemover.h +++ b/libevmasm/JumpdestRemover.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * Removes unused JUMPDESTs. diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index 10e4a4f10..ec6c50702 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file KnownState.cpp * @author Christian diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h index b19585036..458a48b3e 100644 --- a/libevmasm/KnownState.h +++ b/libevmasm/KnownState.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file KnownState.h * @author Christian diff --git a/libevmasm/LinkerObject.cpp b/libevmasm/LinkerObject.cpp index b7ffaac66..fdb9a460f 100644 --- a/libevmasm/LinkerObject.cpp +++ b/libevmasm/LinkerObject.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file LinkerObject.cpp * @author Christian R * @date 2015 diff --git a/libevmasm/LinkerObject.h b/libevmasm/LinkerObject.h index ab0e26507..03d01cc2c 100644 --- a/libevmasm/LinkerObject.h +++ b/libevmasm/LinkerObject.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Assembly.h * @author Gav Wood * @date 2014 diff --git a/libevmasm/PathGasMeter.cpp b/libevmasm/PathGasMeter.cpp index 749cc7bb1..b7c985f1b 100644 --- a/libevmasm/PathGasMeter.cpp +++ b/libevmasm/PathGasMeter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file PathGasMeter.cpp * @author Christian * @date 2015 diff --git a/libevmasm/PathGasMeter.h b/libevmasm/PathGasMeter.h index 38a197973..ecac17cac 100644 --- a/libevmasm/PathGasMeter.h +++ b/libevmasm/PathGasMeter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file PathGasMeter.cpp * @author Christian * @date 2015 diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp index 2b68198f8..6df80dac8 100644 --- a/libevmasm/PeepholeOptimiser.cpp +++ b/libevmasm/PeepholeOptimiser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file PeepholeOptimiser.cpp * Performs local optimising code changes to assembly. diff --git a/libevmasm/PeepholeOptimiser.h b/libevmasm/PeepholeOptimiser.h index a260d3148..64ad5227f 100644 --- a/libevmasm/PeepholeOptimiser.h +++ b/libevmasm/PeepholeOptimiser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file PeepholeOptimiser.h * Performs local optimising code changes to assembly. diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index 9442524b1..93ccdcaf9 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2018 * Templatized list of simplification rules. diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index 76eeb5956..3d4ead64f 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file SemanticInformation.cpp * @author Christian diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index 39a1b2439..f919b4207 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file SemanticInformation.h * @author Christian diff --git a/libevmasm/SimplificationRule.h b/libevmasm/SimplificationRule.h index 1fa1d8ea8..6ce9a9e7c 100644 --- a/libevmasm/SimplificationRule.h +++ b/libevmasm/SimplificationRule.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Expression simplification pattern. */ diff --git a/libevmasm/SimplificationRules.cpp b/libevmasm/SimplificationRules.cpp index c4cc59863..d2f30c22e 100644 --- a/libevmasm/SimplificationRules.cpp +++ b/libevmasm/SimplificationRules.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file ExpressionClasses.cpp * @author Christian diff --git a/libevmasm/SimplificationRules.h b/libevmasm/SimplificationRules.h index 72884d32a..f548f501d 100644 --- a/libevmasm/SimplificationRules.h +++ b/libevmasm/SimplificationRules.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file SimplificationRules * @author Christian diff --git a/liblangutil/EVMVersion.cpp b/liblangutil/EVMVersion.cpp index fa100c091..c953eda0f 100644 --- a/liblangutil/EVMVersion.cpp +++ b/liblangutil/EVMVersion.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * EVM versioning. */ diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index 2c9e87ef3..b34426c92 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * EVM versioning. */ diff --git a/liblangutil/ErrorReporter.cpp b/liblangutil/ErrorReporter.cpp index a8dccd557..29a20a8d8 100644 --- a/liblangutil/ErrorReporter.cpp +++ b/liblangutil/ErrorReporter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Rhett * @date 2017 diff --git a/liblangutil/ErrorReporter.h b/liblangutil/ErrorReporter.h index 3dc8c59c7..e533d7f6c 100644 --- a/liblangutil/ErrorReporter.h +++ b/liblangutil/ErrorReporter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Rhett * @date 2017 diff --git a/liblangutil/Exceptions.cpp b/liblangutil/Exceptions.cpp index fa65031cd..2e9d22b41 100644 --- a/liblangutil/Exceptions.cpp +++ b/liblangutil/Exceptions.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Liana * @date 2015 diff --git a/liblangutil/Exceptions.h b/liblangutil/Exceptions.h index 0dd756848..69745a2fc 100644 --- a/liblangutil/Exceptions.h +++ b/liblangutil/Exceptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/liblangutil/ParserBase.cpp b/liblangutil/ParserBase.cpp index c2162044a..19c4d187c 100644 --- a/liblangutil/ParserBase.cpp +++ b/liblangutil/ParserBase.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/liblangutil/ParserBase.h b/liblangutil/ParserBase.h index 0f6146005..475b08456 100644 --- a/liblangutil/ParserBase.h +++ b/liblangutil/ParserBase.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/liblangutil/SemVerHandler.cpp b/liblangutil/SemVerHandler.cpp index d997cb073..ee5490f55 100644 --- a/liblangutil/SemVerHandler.cpp +++ b/liblangutil/SemVerHandler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/liblangutil/SemVerHandler.h b/liblangutil/SemVerHandler.h index d3dfd5a5b..0a291224e 100644 --- a/liblangutil/SemVerHandler.h +++ b/liblangutil/SemVerHandler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/liblangutil/SourceLocation.cpp b/liblangutil/SourceLocation.cpp index 8c531c625..160a3616b 100644 --- a/liblangutil/SourceLocation.cpp +++ b/liblangutil/SourceLocation.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/liblangutil/SourceLocation.h b/liblangutil/SourceLocation.h index 283c8a524..4b7122de3 100644 --- a/liblangutil/SourceLocation.h +++ b/liblangutil/SourceLocation.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris Karapetsas * @date 2015 diff --git a/liblangutil/SourceReferenceExtractor.cpp b/liblangutil/SourceReferenceExtractor.cpp index 89f84011d..2faefc9b0 100644 --- a/liblangutil/SourceReferenceExtractor.cpp +++ b/liblangutil/SourceReferenceExtractor.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h index b9dababb9..7eb54845c 100644 --- a/liblangutil/SourceReferenceExtractor.h +++ b/liblangutil/SourceReferenceExtractor.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/liblangutil/SourceReferenceFormatter.cpp b/liblangutil/SourceReferenceFormatter.cpp index e10f251d5..d7a0a2169 100644 --- a/liblangutil/SourceReferenceFormatter.cpp +++ b/liblangutil/SourceReferenceFormatter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/liblangutil/SourceReferenceFormatter.h b/liblangutil/SourceReferenceFormatter.h index 439fe177c..636ddfcb0 100644 --- a/liblangutil/SourceReferenceFormatter.h +++ b/liblangutil/SourceReferenceFormatter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/liblangutil/SourceReferenceFormatterHuman.cpp b/liblangutil/SourceReferenceFormatterHuman.cpp index 998ca7bf5..96bef2ed7 100644 --- a/liblangutil/SourceReferenceFormatterHuman.cpp +++ b/liblangutil/SourceReferenceFormatterHuman.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Formatting functions for errors referencing positions and locations in the source. */ diff --git a/liblangutil/SourceReferenceFormatterHuman.h b/liblangutil/SourceReferenceFormatterHuman.h index b468f3756..21816ce67 100644 --- a/liblangutil/SourceReferenceFormatterHuman.h +++ b/liblangutil/SourceReferenceFormatterHuman.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Formatting functions for errors referencing positions and locations in the source. */ diff --git a/liblangutil/UndefMacros.h b/liblangutil/UndefMacros.h index d96e242ec..e3dde6d31 100644 --- a/liblangutil/UndefMacros.h +++ b/liblangutil/UndefMacros.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file UndefMacros.h * @author Lefteris * @date 2015 diff --git a/libsmtutil/CHCSmtLib2Interface.cpp b/libsmtutil/CHCSmtLib2Interface.cpp index 8116ea2a2..c6c5a4cac 100644 --- a/libsmtutil/CHCSmtLib2Interface.cpp +++ b/libsmtutil/CHCSmtLib2Interface.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/CHCSmtLib2Interface.h b/libsmtutil/CHCSmtLib2Interface.h index 8ec3f8dd2..5a74bacbe 100644 --- a/libsmtutil/CHCSmtLib2Interface.h +++ b/libsmtutil/CHCSmtLib2Interface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Interface for solving Horn systems via smtlib2. diff --git a/libsmtutil/CHCSolverInterface.h b/libsmtutil/CHCSolverInterface.h index f2d14cbcf..bf8b6a4cc 100644 --- a/libsmtutil/CHCSolverInterface.h +++ b/libsmtutil/CHCSolverInterface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Interface for constrained Horn solvers. diff --git a/libsmtutil/CVC4Interface.cpp b/libsmtutil/CVC4Interface.cpp index f58e46801..2a795d827 100644 --- a/libsmtutil/CVC4Interface.cpp +++ b/libsmtutil/CVC4Interface.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/CVC4Interface.h b/libsmtutil/CVC4Interface.h index 990590351..16f9f1f81 100644 --- a/libsmtutil/CVC4Interface.h +++ b/libsmtutil/CVC4Interface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsmtutil/Exceptions.h b/libsmtutil/Exceptions.h index 6321c4f6a..29011dab9 100644 --- a/libsmtutil/Exceptions.h +++ b/libsmtutil/Exceptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsmtutil/SMTLib2Interface.cpp b/libsmtutil/SMTLib2Interface.cpp index 1f87b9b72..f1d21c2cc 100644 --- a/libsmtutil/SMTLib2Interface.cpp +++ b/libsmtutil/SMTLib2Interface.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/SMTLib2Interface.h b/libsmtutil/SMTLib2Interface.h index dfb32a959..2a43c0441 100644 --- a/libsmtutil/SMTLib2Interface.h +++ b/libsmtutil/SMTLib2Interface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsmtutil/SMTPortfolio.cpp b/libsmtutil/SMTPortfolio.cpp index 80c1a4750..334d91dd7 100644 --- a/libsmtutil/SMTPortfolio.cpp +++ b/libsmtutil/SMTPortfolio.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/SMTPortfolio.h b/libsmtutil/SMTPortfolio.h index 0399ac033..3e933df5d 100644 --- a/libsmtutil/SMTPortfolio.h +++ b/libsmtutil/SMTPortfolio.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsmtutil/SolverInterface.h b/libsmtutil/SolverInterface.h index a62a39b37..d4c4d7fef 100644 --- a/libsmtutil/SolverInterface.h +++ b/libsmtutil/SolverInterface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsmtutil/Sorts.cpp b/libsmtutil/Sorts.cpp index 7624cbb5b..303e8bb84 100644 --- a/libsmtutil/Sorts.cpp +++ b/libsmtutil/Sorts.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/Sorts.h b/libsmtutil/Sorts.h index 20cbf2be5..de94e8fff 100644 --- a/libsmtutil/Sorts.h +++ b/libsmtutil/Sorts.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsmtutil/Z3CHCInterface.cpp b/libsmtutil/Z3CHCInterface.cpp index d2bce2f1c..262e72e1a 100644 --- a/libsmtutil/Z3CHCInterface.cpp +++ b/libsmtutil/Z3CHCInterface.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/Z3CHCInterface.h b/libsmtutil/Z3CHCInterface.h index f36ee2caa..7fe9e6653 100644 --- a/libsmtutil/Z3CHCInterface.h +++ b/libsmtutil/Z3CHCInterface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Z3 specific Horn solver interface. diff --git a/libsmtutil/Z3Interface.cpp b/libsmtutil/Z3Interface.cpp index c2309ad4f..501446553 100644 --- a/libsmtutil/Z3Interface.cpp +++ b/libsmtutil/Z3Interface.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsmtutil/Z3Interface.h b/libsmtutil/Z3Interface.h index d1fdce0f8..22f793337 100644 --- a/libsmtutil/Z3Interface.h +++ b/libsmtutil/Z3Interface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index d216ae8a2..f87f075d6 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolc/libsolc.h b/libsolc/libsolc.h index 655c9e7b5..c5b3b3db7 100644 --- a/libsolc/libsolc.h +++ b/libsolc/libsolc.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/ConstantEvaluator.cpp b/libsolidity/analysis/ConstantEvaluator.cpp index 4bd8b1389..d00affb91 100644 --- a/libsolidity/analysis/ConstantEvaluator.cpp +++ b/libsolidity/analysis/ConstantEvaluator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/ConstantEvaluator.h b/libsolidity/analysis/ConstantEvaluator.h index f07e6783d..521f46338 100644 --- a/libsolidity/analysis/ConstantEvaluator.h +++ b/libsolidity/analysis/ConstantEvaluator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index fc391f196..8d40ace0e 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that verifies overloads, abstract contracts, function clashes and others * checks at contract or function level. diff --git a/libsolidity/analysis/ContractLevelChecker.h b/libsolidity/analysis/ContractLevelChecker.h index 3a0d7d740..2af0963d7 100644 --- a/libsolidity/analysis/ContractLevelChecker.h +++ b/libsolidity/analysis/ContractLevelChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that verifies overloads, abstract contracts, function clashes and others * checks at contract or function level. diff --git a/libsolidity/analysis/ControlFlowAnalyzer.cpp b/libsolidity/analysis/ControlFlowAnalyzer.cpp index 4937ee1d4..1ed66f72b 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.cpp +++ b/libsolidity/analysis/ControlFlowAnalyzer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/analysis/ControlFlowAnalyzer.h b/libsolidity/analysis/ControlFlowAnalyzer.h index a839c5679..c731cc31f 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.h +++ b/libsolidity/analysis/ControlFlowAnalyzer.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/ControlFlowBuilder.cpp b/libsolidity/analysis/ControlFlowBuilder.cpp index a0c557a3e..4eb4658e1 100644 --- a/libsolidity/analysis/ControlFlowBuilder.cpp +++ b/libsolidity/analysis/ControlFlowBuilder.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libsolidity/analysis/ControlFlowBuilder.h b/libsolidity/analysis/ControlFlowBuilder.h index 2d0910d6a..0efd55d77 100644 --- a/libsolidity/analysis/ControlFlowBuilder.h +++ b/libsolidity/analysis/ControlFlowBuilder.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/ControlFlowGraph.cpp b/libsolidity/analysis/ControlFlowGraph.cpp index fb5fc1be0..f7344e7fc 100644 --- a/libsolidity/analysis/ControlFlowGraph.cpp +++ b/libsolidity/analysis/ControlFlowGraph.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/analysis/ControlFlowGraph.h b/libsolidity/analysis/ControlFlowGraph.h index 4d11ef8f6..7d51f2196 100644 --- a/libsolidity/analysis/ControlFlowGraph.h +++ b/libsolidity/analysis/ControlFlowGraph.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 2450778cd..b514c2c39 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/DeclarationContainer.h b/libsolidity/analysis/DeclarationContainer.h index 4b4df9339..8036a5a58 100644 --- a/libsolidity/analysis/DeclarationContainer.h +++ b/libsolidity/analysis/DeclarationContainer.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index 07e8f6066..0027b3045 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/analysis/DeclarationTypeChecker.h b/libsolidity/analysis/DeclarationTypeChecker.h index 0edd97bd9..6ba9d1aad 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.h +++ b/libsolidity/analysis/DeclarationTypeChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index 92989ddac..96fde8550 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/DocStringAnalyser.h b/libsolidity/analysis/DocStringAnalyser.h index 9bc8ec578..ee79cd9f7 100644 --- a/libsolidity/analysis/DocStringAnalyser.h +++ b/libsolidity/analysis/DocStringAnalyser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index 53020afce..885ae49a7 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @author Gav Wood diff --git a/libsolidity/analysis/GlobalContext.h b/libsolidity/analysis/GlobalContext.h index 81ffa2109..b84e3a026 100644 --- a/libsolidity/analysis/GlobalContext.h +++ b/libsolidity/analysis/GlobalContext.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/ImmutableValidator.cpp b/libsolidity/analysis/ImmutableValidator.cpp index e4fcfadcf..5af640e58 100644 --- a/libsolidity/analysis/ImmutableValidator.cpp +++ b/libsolidity/analysis/ImmutableValidator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/analysis/ImmutableValidator.h b/libsolidity/analysis/ImmutableValidator.h index 5845ba011..ffa45e74c 100644 --- a/libsolidity/analysis/ImmutableValidator.h +++ b/libsolidity/analysis/ImmutableValidator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 9fbd219f9..c7be364a3 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index efb404038..d72822653 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/OverrideChecker.cpp b/libsolidity/analysis/OverrideChecker.cpp index 6a2ccc83a..42a6230a2 100644 --- a/libsolidity/analysis/OverrideChecker.cpp +++ b/libsolidity/analysis/OverrideChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that verifies overloads, abstract contracts, function clashes and others * checks at contract or function level. diff --git a/libsolidity/analysis/OverrideChecker.h b/libsolidity/analysis/OverrideChecker.h index d47b89f3d..564100453 100644 --- a/libsolidity/analysis/OverrideChecker.h +++ b/libsolidity/analysis/OverrideChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that verifies override properties. */ diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 1b5b5b7c3..cb04eec6f 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index 0a3358553..d3f23918c 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 408a7ff83..10ad415c1 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index 7da745cc5..710f388cb 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 62a1861d1..68f52ac26 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Federico Bond * @date 2016 diff --git a/libsolidity/analysis/StaticAnalyzer.h b/libsolidity/analysis/StaticAnalyzer.h index 7886b4288..dc6263d7e 100644 --- a/libsolidity/analysis/StaticAnalyzer.h +++ b/libsolidity/analysis/StaticAnalyzer.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Federico Bond * @date 2016 diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 267d5764f..26d90f4f1 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index 78aa6b82f..1ace2f36a 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index a81520b05..92abc11e6 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 9e5f9470f..e34c9e9d0 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 09c8a34b3..d2e1b3e43 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h index 10e60f051..87135b4f7 100644 --- a/libsolidity/analysis/ViewPureChecker.h +++ b/libsolidity/analysis/ViewPureChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index cba5bccc3..7c1ed2aa8 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 34fefeb0a..eb2b4f87d 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/ast/ASTAnnotations.cpp b/libsolidity/ast/ASTAnnotations.cpp index eb3caf721..3556041d8 100644 --- a/libsolidity/ast/ASTAnnotations.cpp +++ b/libsolidity/ast/ASTAnnotations.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 507559ca6..d4df9d0cf 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/ast/ASTEnums.h b/libsolidity/ast/ASTEnums.h index 19279c6b7..e167e7d49 100644 --- a/libsolidity/ast/ASTEnums.h +++ b/libsolidity/ast/ASTEnums.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Enums for AST classes. diff --git a/libsolidity/ast/ASTForward.h b/libsolidity/ast/ASTForward.h index 38da35218..3f082d975 100644 --- a/libsolidity/ast/ASTForward.h +++ b/libsolidity/ast/ASTForward.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 219151f89..39b92bbb4 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Converts the AST into json format diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index a1d3cd4ad..bb5d9651c 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @date 2015 diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index ccf9af5a7..33975d8ca 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author julius * @date 2019 diff --git a/libsolidity/ast/ASTJsonImporter.h b/libsolidity/ast/ASTJsonImporter.h index ebcbd660c..0bfb111bf 100644 --- a/libsolidity/ast/ASTJsonImporter.h +++ b/libsolidity/ast/ASTJsonImporter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author julius * @date 2019 diff --git a/libsolidity/ast/ASTUtils.cpp b/libsolidity/ast/ASTUtils.cpp index 483b75301..54db7002e 100644 --- a/libsolidity/ast/ASTUtils.cpp +++ b/libsolidity/ast/ASTUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libsolidity/ast/ASTUtils.h b/libsolidity/ast/ASTUtils.h index af77b60f1..38465d8d5 100644 --- a/libsolidity/ast/ASTUtils.h +++ b/libsolidity/ast/ASTUtils.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/ast/ASTVisitor.h b/libsolidity/ast/ASTVisitor.h index 52e90b0d7..c5aeba402 100644 --- a/libsolidity/ast/ASTVisitor.h +++ b/libsolidity/ast/ASTVisitor.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h index e597ce46b..2105e369d 100644 --- a/libsolidity/ast/AST_accept.h +++ b/libsolidity/ast/AST_accept.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/ast/AsmJsonImporter.cpp b/libsolidity/ast/AsmJsonImporter.cpp index 302388841..3ff280f54 100644 --- a/libsolidity/ast/AsmJsonImporter.cpp +++ b/libsolidity/ast/AsmJsonImporter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author julius * @date 2019 diff --git a/libsolidity/ast/AsmJsonImporter.h b/libsolidity/ast/AsmJsonImporter.h index 498b4e489..b4e8cfe7b 100644 --- a/libsolidity/ast/AsmJsonImporter.h +++ b/libsolidity/ast/AsmJsonImporter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author julius * @date 2019 diff --git a/libsolidity/ast/ExperimentalFeatures.h b/libsolidity/ast/ExperimentalFeatures.h index 6fdc6897b..772bc4e08 100644 --- a/libsolidity/ast/ExperimentalFeatures.h +++ b/libsolidity/ast/ExperimentalFeatures.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * List of experimental features. */ diff --git a/libsolidity/ast/TypeProvider.cpp b/libsolidity/ast/TypeProvider.cpp index 6fd778403..c7ef3cfbd 100644 --- a/libsolidity/ast/TypeProvider.cpp +++ b/libsolidity/ast/TypeProvider.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libsolidity/ast/TypeProvider.h b/libsolidity/ast/TypeProvider.h index a86542d16..1f9ba4329 100644 --- a/libsolidity/ast/TypeProvider.h +++ b/libsolidity/ast/TypeProvider.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 825fc8d0c..b382e9803 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 155fa7f14..02f5c9f5f 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 9f244fdb1..ef5948069 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2017 diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h index a66b1284e..e3a7e6f18 100644 --- a/libsolidity/codegen/ABIFunctions.h +++ b/libsolidity/codegen/ABIFunctions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2017 diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 409c16cd7..ef94b6bf2 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/codegen/ArrayUtils.h b/libsolidity/codegen/ArrayUtils.h index 2ee087974..7cc01dd26 100644 --- a/libsolidity/codegen/ArrayUtils.h +++ b/libsolidity/codegen/ArrayUtils.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index f343f2377..a64a34009 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h index e12332015..11d5c2abd 100644 --- a/libsolidity/codegen/Compiler.h +++ b/libsolidity/codegen/Compiler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 2f3659010..9fde94e8a 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index c32b51406..f82c705d8 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 2d7b38b25..f2db90569 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index a65edb8f2..64ab84fe7 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index ad9c97474..225628a6c 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/ContractCompiler.h b/libsolidity/codegen/ContractCompiler.h index 0916da281..d4badc197 100644 --- a/libsolidity/codegen/ContractCompiler.h +++ b/libsolidity/codegen/ContractCompiler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 694ea8fa6..566db8517 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index 0216b260b..c0a703d78 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @author Gav Wood diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 798428098..777196767 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/codegen/LValue.h b/libsolidity/codegen/LValue.h index cd72f37e0..9bf0d1c05 100644 --- a/libsolidity/codegen/LValue.h +++ b/libsolidity/codegen/LValue.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp index f49f3083d..0049deb78 100644 --- a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp +++ b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Container of (unparsed) Yul functions identified by name which are meant to be generated * only once. diff --git a/libsolidity/codegen/MultiUseYulFunctionCollector.h b/libsolidity/codegen/MultiUseYulFunctionCollector.h index 031d08bde..428a0c9a3 100644 --- a/libsolidity/codegen/MultiUseYulFunctionCollector.h +++ b/libsolidity/codegen/MultiUseYulFunctionCollector.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Container of (unparsed) Yul functions identified by name which are meant to be generated * only once. diff --git a/libsolidity/codegen/ReturnInfo.cpp b/libsolidity/codegen/ReturnInfo.cpp index b522addd4..f0828befd 100644 --- a/libsolidity/codegen/ReturnInfo.cpp +++ b/libsolidity/codegen/ReturnInfo.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/codegen/ReturnInfo.h b/libsolidity/codegen/ReturnInfo.h index 01aa30862..e1e5719ef 100644 --- a/libsolidity/codegen/ReturnInfo.h +++ b/libsolidity/codegen/ReturnInfo.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that computes information relevant during decoding an external function * call's return values. diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 7678a0bef..cab908c18 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that can generate various useful Yul functions. */ diff --git a/libsolidity/codegen/YulUtilFunctions.h b/libsolidity/codegen/YulUtilFunctions.h index c1d98cfe4..5d9ec805f 100644 --- a/libsolidity/codegen/YulUtilFunctions.h +++ b/libsolidity/codegen/YulUtilFunctions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that can generate various useful Yul functions. */ diff --git a/libsolidity/codegen/ir/Common.cpp b/libsolidity/codegen/ir/Common.cpp index 2bf4a36cf..42a4650db 100644 --- a/libsolidity/codegen/ir/Common.cpp +++ b/libsolidity/codegen/ir/Common.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libsolidity/codegen/ir/Common.h b/libsolidity/codegen/ir/Common.h index 3f4ea64f4..da6c61a7f 100644 --- a/libsolidity/codegen/ir/Common.h +++ b/libsolidity/codegen/ir/Common.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Miscellaneous utilities for use in IR generator. */ diff --git a/libsolidity/codegen/ir/IRGenerationContext.cpp b/libsolidity/codegen/ir/IRGenerationContext.cpp index b85e2f7d3..7476dd90e 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.cpp +++ b/libsolidity/codegen/ir/IRGenerationContext.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Class that contains contextual information during IR generation. */ diff --git a/libsolidity/codegen/ir/IRGenerationContext.h b/libsolidity/codegen/ir/IRGenerationContext.h index d6d8022df..469beea2f 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.h +++ b/libsolidity/codegen/ir/IRGenerationContext.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Class that contains contextual information during IR generation. */ diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index 92df1ba83..f7f66b4f5 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * @date 2017 diff --git a/libsolidity/codegen/ir/IRGenerator.h b/libsolidity/codegen/ir/IRGenerator.h index 6bf94e575..e57b8535e 100644 --- a/libsolidity/codegen/ir/IRGenerator.h +++ b/libsolidity/codegen/ir/IRGenerator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * @date 2017 diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index a8d657b02..51679571e 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that translates Solidity code into Yul at statement level and below. */ diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.h b/libsolidity/codegen/ir/IRGeneratorForStatements.h index bdf21f783..09c9c7d27 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.h +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that translates Solidity code into Yul at statement level and below. */ diff --git a/libsolidity/codegen/ir/IRLValue.h b/libsolidity/codegen/ir/IRLValue.h index c5eadc9b2..fef390d4c 100644 --- a/libsolidity/codegen/ir/IRLValue.h +++ b/libsolidity/codegen/ir/IRLValue.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Classes that store locations of lvalues. */ diff --git a/libsolidity/codegen/ir/IRVariable.cpp b/libsolidity/codegen/ir/IRVariable.cpp index 8cb1896a6..3fce5288a 100644 --- a/libsolidity/codegen/ir/IRVariable.cpp +++ b/libsolidity/codegen/ir/IRVariable.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libsolidity/codegen/ir/IRVariable.h b/libsolidity/codegen/ir/IRVariable.h index dbf37704c..71413cc38 100644 --- a/libsolidity/codegen/ir/IRVariable.h +++ b/libsolidity/codegen/ir/IRVariable.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index 921c71ccf..363910edd 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/BMC.h b/libsolidity/formal/BMC.h index 2eed58101..324595bba 100644 --- a/libsolidity/formal/BMC.h +++ b/libsolidity/formal/BMC.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Class that implements an SMT-based Bounded Model Checker (BMC). * Traverses the AST such that: diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index 5dd8c958c..f68872d5c 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/CHC.h b/libsolidity/formal/CHC.h index 5e518a130..d025e31d3 100644 --- a/libsolidity/formal/CHC.h +++ b/libsolidity/formal/CHC.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Model checker based on Constrained Horn Clauses. diff --git a/libsolidity/formal/EncodingContext.cpp b/libsolidity/formal/EncodingContext.cpp index b58160230..422eb44ee 100644 --- a/libsolidity/formal/EncodingContext.cpp +++ b/libsolidity/formal/EncodingContext.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/EncodingContext.h b/libsolidity/formal/EncodingContext.h index 09316709a..e188792d8 100644 --- a/libsolidity/formal/EncodingContext.h +++ b/libsolidity/formal/EncodingContext.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/formal/ModelChecker.cpp b/libsolidity/formal/ModelChecker.cpp index 718a41ae1..9465dd342 100644 --- a/libsolidity/formal/ModelChecker.cpp +++ b/libsolidity/formal/ModelChecker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/ModelChecker.h b/libsolidity/formal/ModelChecker.h index b4378e629..42d116b28 100644 --- a/libsolidity/formal/ModelChecker.h +++ b/libsolidity/formal/ModelChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Entry point to the model checking engines. * The goal of this class is to make different diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index ac87bade1..e3f16b2ef 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/SMTEncoder.h b/libsolidity/formal/SMTEncoder.h index 86ed21ef9..92ef0601a 100644 --- a/libsolidity/formal/SMTEncoder.h +++ b/libsolidity/formal/SMTEncoder.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Encodes Solidity into SMT expressions without creating * any verification targets. diff --git a/libsolidity/formal/SSAVariable.cpp b/libsolidity/formal/SSAVariable.cpp index 5569d8f36..bb599c35a 100644 --- a/libsolidity/formal/SSAVariable.cpp +++ b/libsolidity/formal/SSAVariable.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/SSAVariable.h b/libsolidity/formal/SSAVariable.h index bad6fa80c..7db69d1fd 100644 --- a/libsolidity/formal/SSAVariable.h +++ b/libsolidity/formal/SSAVariable.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/formal/SymbolicState.cpp b/libsolidity/formal/SymbolicState.cpp index 1ab6e1860..06fe1bd2a 100644 --- a/libsolidity/formal/SymbolicState.cpp +++ b/libsolidity/formal/SymbolicState.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/SymbolicState.h b/libsolidity/formal/SymbolicState.h index 2b234466d..aaf6971fa 100644 --- a/libsolidity/formal/SymbolicState.h +++ b/libsolidity/formal/SymbolicState.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/formal/SymbolicTypes.cpp b/libsolidity/formal/SymbolicTypes.cpp index 096f496c4..b149cb69c 100644 --- a/libsolidity/formal/SymbolicTypes.cpp +++ b/libsolidity/formal/SymbolicTypes.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/SymbolicTypes.h b/libsolidity/formal/SymbolicTypes.h index 226bd5f94..401c9f0b6 100644 --- a/libsolidity/formal/SymbolicTypes.h +++ b/libsolidity/formal/SymbolicTypes.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/formal/SymbolicVariables.cpp b/libsolidity/formal/SymbolicVariables.cpp index 3f86b48d9..b09938e63 100644 --- a/libsolidity/formal/SymbolicVariables.cpp +++ b/libsolidity/formal/SymbolicVariables.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/SymbolicVariables.h b/libsolidity/formal/SymbolicVariables.h index 65dce43f0..bdf36afd0 100644 --- a/libsolidity/formal/SymbolicVariables.h +++ b/libsolidity/formal/SymbolicVariables.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/formal/VariableUsage.cpp b/libsolidity/formal/VariableUsage.cpp index 11ca44ff3..1634b3b58 100644 --- a/libsolidity/formal/VariableUsage.cpp +++ b/libsolidity/formal/VariableUsage.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/formal/VariableUsage.h b/libsolidity/formal/VariableUsage.h index 7b55998d2..508efbc60 100644 --- a/libsolidity/formal/VariableUsage.h +++ b/libsolidity/formal/VariableUsage.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index c00c2f83c..512bf9b13 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Utilities to handle the Contract ABI (https://solidity.readthedocs.io/en/develop/abi-spec.html) */ diff --git a/libsolidity/interface/ABI.h b/libsolidity/interface/ABI.h index 1dd578ceb..76b1a4a75 100644 --- a/libsolidity/interface/ABI.h +++ b/libsolidity/interface/ABI.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Utilities to handle the Contract ABI (https://solidity.readthedocs.io/en/develop/abi-spec.html) */ diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 164938c60..f8164bc9f 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @author Gav Wood diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 509623cc1..ce0f949b9 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @author Gav Wood diff --git a/libsolidity/interface/DebugSettings.h b/libsolidity/interface/DebugSettings.h index 34818889c..e0dab05bb 100644 --- a/libsolidity/interface/DebugSettings.h +++ b/libsolidity/interface/DebugSettings.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Settings to aid debugging. */ diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index 1a86f36ce..2b56977ff 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/interface/GasEstimator.h b/libsolidity/interface/GasEstimator.h index 1cfcec9a7..f814c8b8d 100644 --- a/libsolidity/interface/GasEstimator.h +++ b/libsolidity/interface/GasEstimator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index a292c7a3d..1f5c4807a 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @date 2014 diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index 8d414e71a..9dab62625 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @date 2014 diff --git a/libsolidity/interface/OptimiserSettings.h b/libsolidity/interface/OptimiserSettings.h index cd82290af..67007fc4c 100644 --- a/libsolidity/interface/OptimiserSettings.h +++ b/libsolidity/interface/OptimiserSettings.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * @date 2017 diff --git a/libsolidity/interface/ReadFile.h b/libsolidity/interface/ReadFile.h index 232d39be4..b21e8634a 100644 --- a/libsolidity/interface/ReadFile.h +++ b/libsolidity/interface/ReadFile.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 7293f94bc..b1e355fab 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * @date 2016 diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index d1a1489c3..cf5be94a0 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * @date 2016 diff --git a/libsolidity/interface/StorageLayout.cpp b/libsolidity/interface/StorageLayout.cpp index 806652cfe..d23344bc8 100644 --- a/libsolidity/interface/StorageLayout.cpp +++ b/libsolidity/interface/StorageLayout.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/interface/StorageLayout.h b/libsolidity/interface/StorageLayout.h index 331a85d46..4cfee73a9 100644 --- a/libsolidity/interface/StorageLayout.h +++ b/libsolidity/interface/StorageLayout.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Generates the storage layout of a contract. */ diff --git a/libsolidity/interface/Version.cpp b/libsolidity/interface/Version.cpp index 412750bc8..297333b6b 100644 --- a/libsolidity/interface/Version.cpp +++ b/libsolidity/interface/Version.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/interface/Version.h b/libsolidity/interface/Version.h index f2b1ad429..a5965d42e 100644 --- a/libsolidity/interface/Version.h +++ b/libsolidity/interface/Version.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/libsolidity/parsing/DocStringParser.cpp b/libsolidity/parsing/DocStringParser.cpp index 9f6f13f94..314f04201 100644 --- a/libsolidity/parsing/DocStringParser.cpp +++ b/libsolidity/parsing/DocStringParser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolidity/parsing/DocStringParser.h b/libsolidity/parsing/DocStringParser.h index d5ebd2383..4b6d6b512 100644 --- a/libsolidity/parsing/DocStringParser.h +++ b/libsolidity/parsing/DocStringParser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @date 2014, 2015 diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 4b63cbc58..ce08bef60 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index f66754045..f84cb7041 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index 0e8f1f85b..0382aba0e 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Solidity and Yul both share the same Token (and Scanner) API. * diff --git a/libsolutil/Algorithms.h b/libsolutil/Algorithms.h index 3897d65d2..88e034bf4 100644 --- a/libsolutil/Algorithms.h +++ b/libsolutil/Algorithms.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolutil/AnsiColorized.h b/libsolutil/AnsiColorized.h index 4f7ea577b..69d10d727 100644 --- a/libsolutil/AnsiColorized.h +++ b/libsolutil/AnsiColorized.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolutil/Assertions.h b/libsolutil/Assertions.h index 1c5a14008..b143e6ed7 100644 --- a/libsolutil/Assertions.h +++ b/libsolutil/Assertions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @file Assertions.h * @author Christian diff --git a/libsolutil/Common.h b/libsolutil/Common.h index f2d9c1d84..aae2fa859 100644 --- a/libsolutil/Common.h +++ b/libsolutil/Common.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Common.h * @author Gav Wood * @date 2014 diff --git a/libsolutil/CommonData.cpp b/libsolutil/CommonData.cpp index 2896804ca..1dc616836 100644 --- a/libsolutil/CommonData.cpp +++ b/libsolutil/CommonData.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file CommonData.cpp * @author Gav Wood * @date 2014 diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index a5c045646..b61ba82a2 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file CommonData.h * @author Gav Wood * @date 2014 diff --git a/libsolutil/CommonIO.cpp b/libsolutil/CommonIO.cpp index cbe68f0d1..43886264b 100644 --- a/libsolutil/CommonIO.cpp +++ b/libsolutil/CommonIO.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file CommonIO.cpp * @author Gav Wood * @date 2014 diff --git a/libsolutil/CommonIO.h b/libsolutil/CommonIO.h index 38c8f564a..2a811387b 100644 --- a/libsolutil/CommonIO.h +++ b/libsolutil/CommonIO.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file CommonIO.h * @author Gav Wood * @date 2014 diff --git a/libsolutil/Exceptions.cpp b/libsolutil/Exceptions.cpp index 94b40f634..fa4021d3b 100644 --- a/libsolutil/Exceptions.cpp +++ b/libsolutil/Exceptions.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolutil/Exceptions.h b/libsolutil/Exceptions.h index 971b9306f..9c84c8f71 100644 --- a/libsolutil/Exceptions.h +++ b/libsolutil/Exceptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolutil/FixedHash.h b/libsolutil/FixedHash.h index 7fbb8eec9..84d6afba3 100644 --- a/libsolutil/FixedHash.h +++ b/libsolutil/FixedHash.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file FixedHash.h * @author Gav Wood * @date 2014 diff --git a/libsolutil/IndentedWriter.cpp b/libsolutil/IndentedWriter.cpp index 884b50e9c..0e0aded3c 100644 --- a/libsolutil/IndentedWriter.cpp +++ b/libsolutil/IndentedWriter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Indented text writer. diff --git a/libsolutil/IndentedWriter.h b/libsolutil/IndentedWriter.h index 29ecc4f6d..47e2817fa 100644 --- a/libsolutil/IndentedWriter.h +++ b/libsolutil/IndentedWriter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Indented text writer. diff --git a/libsolutil/InvertibleMap.h b/libsolutil/InvertibleMap.h index 4448d03d7..3c6f3238a 100644 --- a/libsolutil/InvertibleMap.h +++ b/libsolutil/InvertibleMap.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolutil/IpfsHash.cpp b/libsolutil/IpfsHash.cpp index 6913d42f0..c034ce5ba 100644 --- a/libsolutil/IpfsHash.cpp +++ b/libsolutil/IpfsHash.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libsolutil/IpfsHash.h b/libsolutil/IpfsHash.h index 555b35961..977fb9836 100644 --- a/libsolutil/IpfsHash.h +++ b/libsolutil/IpfsHash.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index 609b9bb04..b3635c877 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file JSON.cpp * @author Alexander Arlt * @date 2018 diff --git a/libsolutil/JSON.h b/libsolutil/JSON.h index 17633ea07..5328a3faf 100644 --- a/libsolutil/JSON.h +++ b/libsolutil/JSON.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file JSON.h * @date 2016 * diff --git a/libsolutil/Keccak256.cpp b/libsolutil/Keccak256.cpp index 2a7a241c7..50e849352 100644 --- a/libsolutil/Keccak256.cpp +++ b/libsolutil/Keccak256.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file SHA3.cpp * @author Gav Wood * @date 2014 diff --git a/libsolutil/Keccak256.h b/libsolutil/Keccak256.h index 7135e55c0..7fb7c7501 100644 --- a/libsolutil/Keccak256.h +++ b/libsolutil/Keccak256.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file SHA3.h * @author Gav Wood * @date 2014 diff --git a/libsolutil/LazyInit.h b/libsolutil/LazyInit.h index fe2f6a916..b242484df 100644 --- a/libsolutil/LazyInit.h +++ b/libsolutil/LazyInit.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libsolutil/Result.h b/libsolutil/Result.h index a2c471097..ca9563947 100644 --- a/libsolutil/Result.h +++ b/libsolutil/Result.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libsolutil/StringUtils.cpp b/libsolutil/StringUtils.cpp index a5b0149c2..35804c60a 100644 --- a/libsolutil/StringUtils.cpp +++ b/libsolutil/StringUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file StringUtils.h * @author Balajiganapathi S * @date 2017 diff --git a/libsolutil/StringUtils.h b/libsolutil/StringUtils.h index caea637a2..e7a68cedc 100644 --- a/libsolutil/StringUtils.h +++ b/libsolutil/StringUtils.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file StringUtils.h * @author Balajiganapathi S * @date 2017 diff --git a/libsolutil/SwarmHash.cpp b/libsolutil/SwarmHash.cpp index 4cfc0fe66..f35a74bd1 100644 --- a/libsolutil/SwarmHash.cpp +++ b/libsolutil/SwarmHash.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file SwarmHash.cpp */ diff --git a/libsolutil/SwarmHash.h b/libsolutil/SwarmHash.h index 3905b2f5f..ed7a52292 100644 --- a/libsolutil/SwarmHash.h +++ b/libsolutil/SwarmHash.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file SwarmHash.h */ diff --git a/libsolutil/UTF8.cpp b/libsolutil/UTF8.cpp index a7d55af6c..4acf7a8ea 100644 --- a/libsolutil/UTF8.cpp +++ b/libsolutil/UTF8.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file UTF8.cpp * @author Alex Beregszaszi * @date 2016 diff --git a/libsolutil/UTF8.h b/libsolutil/UTF8.h index cd84c3982..59e2d4145 100644 --- a/libsolutil/UTF8.h +++ b/libsolutil/UTF8.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file UTF8.h * @author Alex Beregszaszi * @date 2016 diff --git a/libsolutil/Visitor.h b/libsolutil/Visitor.h index 6d771cd86..497ed2f29 100644 --- a/libsolutil/Visitor.h +++ b/libsolutil/Visitor.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Visitor templates. */ diff --git a/libsolutil/Whiskers.cpp b/libsolutil/Whiskers.cpp index aebe55c69..3049af5c4 100644 --- a/libsolutil/Whiskers.cpp +++ b/libsolutil/Whiskers.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Whiskers.cpp * @author Chris * @date 2017 diff --git a/libsolutil/Whiskers.h b/libsolutil/Whiskers.h index 5eb00dce5..5ddb7a884 100644 --- a/libsolutil/Whiskers.h +++ b/libsolutil/Whiskers.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file Whiskers.h * @author Chris * @date 2017 diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 315699153..e85ecd876 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Analyzer part of inline assembly. */ diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index e0a751b13..8d8db59ab 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Analysis part of inline assembly. */ diff --git a/libyul/AsmAnalysisInfo.h b/libyul/AsmAnalysisInfo.h index d094ee510..9ac179ad8 100644 --- a/libyul/AsmAnalysisInfo.h +++ b/libyul/AsmAnalysisInfo.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Information generated during analyzer part of inline assembly. */ diff --git a/libyul/AsmData.h b/libyul/AsmData.h index f870536af..c4040f320 100644 --- a/libyul/AsmData.h +++ b/libyul/AsmData.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/libyul/AsmDataForward.h b/libyul/AsmDataForward.h index b21f46f82..02216fd01 100644 --- a/libyul/AsmDataForward.h +++ b/libyul/AsmDataForward.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/libyul/AsmJsonConverter.cpp b/libyul/AsmJsonConverter.cpp index d2b905ece..58b11338d 100644 --- a/libyul/AsmJsonConverter.cpp +++ b/libyul/AsmJsonConverter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2019 * Converts inline assembly AST to JSON format diff --git a/libyul/AsmJsonConverter.h b/libyul/AsmJsonConverter.h index b350689fc..3436523b7 100644 --- a/libyul/AsmJsonConverter.h +++ b/libyul/AsmJsonConverter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2019 * @author julius diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 8dcb9a832..6c5d97e36 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h index 4c1d6980f..ecd62228a 100644 --- a/libyul/AsmParser.h +++ b/libyul/AsmParser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 97a7dc3ad..c5982afc9 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2017 diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h index f7ee9ff54..648181cbf 100644 --- a/libyul/AsmPrinter.h +++ b/libyul/AsmPrinter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2017 diff --git a/libyul/AsmScope.cpp b/libyul/AsmScope.cpp index 86dbce483..1237cba8d 100644 --- a/libyul/AsmScope.cpp +++ b/libyul/AsmScope.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Scopes for identifiers. */ diff --git a/libyul/AsmScope.h b/libyul/AsmScope.h index 6da1ff1e0..0857b604b 100644 --- a/libyul/AsmScope.h +++ b/libyul/AsmScope.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Scopes for identifiers. */ diff --git a/libyul/AsmScopeFiller.cpp b/libyul/AsmScopeFiller.cpp index 90143ba4d..0e0695410 100644 --- a/libyul/AsmScopeFiller.cpp +++ b/libyul/AsmScopeFiller.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module responsible for registering identifiers inside their scopes. */ diff --git a/libyul/AsmScopeFiller.h b/libyul/AsmScopeFiller.h index f3b7a1b8f..f2c35118b 100644 --- a/libyul/AsmScopeFiller.h +++ b/libyul/AsmScopeFiller.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module responsible for registering identifiers inside their scopes. */ diff --git a/libyul/AssemblyStack.cpp b/libyul/AssemblyStack.cpp index 4598d6d2b..b8824740d 100644 --- a/libyul/AssemblyStack.cpp +++ b/libyul/AssemblyStack.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and * Ewasm as output. diff --git a/libyul/AssemblyStack.h b/libyul/AssemblyStack.h index f9d235505..70325208d 100644 --- a/libyul/AssemblyStack.h +++ b/libyul/AssemblyStack.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and * Ewasm as output. diff --git a/libyul/CompilabilityChecker.h b/libyul/CompilabilityChecker.h index d92f1977e..1267640bf 100644 --- a/libyul/CompilabilityChecker.h +++ b/libyul/CompilabilityChecker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that checks whether all variables are reachable on the stack. */ diff --git a/libyul/ControlFlowSideEffects.h b/libyul/ControlFlowSideEffects.h index 5621a122b..5e22ad862 100644 --- a/libyul/ControlFlowSideEffects.h +++ b/libyul/ControlFlowSideEffects.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libyul/Dialect.cpp b/libyul/Dialect.cpp index 407fdea2f..1003c8e44 100644 --- a/libyul/Dialect.cpp +++ b/libyul/Dialect.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul dialect. */ diff --git a/libyul/Dialect.h b/libyul/Dialect.h index 870205833..553f9049a 100644 --- a/libyul/Dialect.h +++ b/libyul/Dialect.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul dialect. */ diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index 9bb6a5d04..2fe155030 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Exceptions in Yul. */ diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 13ad9f8ca..1086e38cf 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul code and data object container. */ diff --git a/libyul/Object.h b/libyul/Object.h index 6ae79ed42..3602e7177 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul code and data object container. */ diff --git a/libyul/ObjectParser.cpp b/libyul/ObjectParser.cpp index 7e50fa88e..f1d38ad73 100644 --- a/libyul/ObjectParser.cpp +++ b/libyul/ObjectParser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Parser for Yul code and data object container. */ diff --git a/libyul/ObjectParser.h b/libyul/ObjectParser.h index 1bd9d956f..6c6f527cd 100644 --- a/libyul/ObjectParser.h +++ b/libyul/ObjectParser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Parser for Yul code and data object container. */ diff --git a/libyul/SideEffects.h b/libyul/SideEffects.h index 2a0232973..e9c12d9c8 100644 --- a/libyul/SideEffects.h +++ b/libyul/SideEffects.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libyul/Utilities.cpp b/libyul/Utilities.cpp index 59e0adce3..af72888fa 100644 --- a/libyul/Utilities.cpp +++ b/libyul/Utilities.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Some useful snippets for the optimiser. */ diff --git a/libyul/Utilities.h b/libyul/Utilities.h index 8b4547be3..53913e6fd 100644 --- a/libyul/Utilities.h +++ b/libyul/Utilities.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Small useful snippets for the optimiser. */ diff --git a/libyul/YulString.h b/libyul/YulString.h index 0abe1f38d..6985794ec 100644 --- a/libyul/YulString.h +++ b/libyul/YulString.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * String abstraction that avoids copies. */ diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 42622272c..0c01a71d5 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Abstract assembly interface, subclasses of which are to be used with the generic diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 327ce8895..55e73feb1 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Adaptor between the abstract assembly and eth assembly. */ diff --git a/libyul/backends/evm/AsmCodeGen.h b/libyul/backends/evm/AsmCodeGen.h index 6ff02009c..d40b41fcd 100644 --- a/libyul/backends/evm/AsmCodeGen.h +++ b/libyul/backends/evm/AsmCodeGen.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Adaptor between the abstract assembly and eth assembly. */ diff --git a/libyul/backends/evm/ConstantOptimiser.cpp b/libyul/backends/evm/ConstantOptimiser.cpp index d8399d095..9148b0793 100644 --- a/libyul/backends/evm/ConstantOptimiser.cpp +++ b/libyul/backends/evm/ConstantOptimiser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that replaces constants by expressions that compute them. */ diff --git a/libyul/backends/evm/ConstantOptimiser.h b/libyul/backends/evm/ConstantOptimiser.h index 7423b5270..d6844bbe6 100644 --- a/libyul/backends/evm/ConstantOptimiser.h +++ b/libyul/backends/evm/ConstantOptimiser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that replaces constants by expressions that compute them. */ diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 7cf3d0662..06288e562 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Assembly interface for EVM and EVM1.5. */ diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index 9ee974bbb..6bf92e985 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Assembly interface for EVM and EVM1.5. */ diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 041e00380..51efbbe33 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Common code generator for translating Yul / inline assembly to EVM and EVM1.5. */ diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index 1cfa6afd7..c344b834d 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Common code generator for translating Yul / inline assembly to EVM and EVM1.5. */ diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index bf0c63bfa..4b9acb0c7 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul dialects for EVM. */ diff --git a/libyul/backends/evm/EVMDialect.h b/libyul/backends/evm/EVMDialect.h index 68f0b7046..fe1c67a4a 100644 --- a/libyul/backends/evm/EVMDialect.h +++ b/libyul/backends/evm/EVMDialect.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul dialects for EVM. */ diff --git a/libyul/backends/evm/EVMMetrics.cpp b/libyul/backends/evm/EVMMetrics.cpp index f3508afb3..5fb6d863a 100644 --- a/libyul/backends/evm/EVMMetrics.cpp +++ b/libyul/backends/evm/EVMMetrics.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module providing metrics for the EVM optimizer. */ diff --git a/libyul/backends/evm/EVMMetrics.h b/libyul/backends/evm/EVMMetrics.h index b6a23e3c8..63e0d3c8f 100644 --- a/libyul/backends/evm/EVMMetrics.h +++ b/libyul/backends/evm/EVMMetrics.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module providing metrics for the optimizer. */ diff --git a/libyul/backends/evm/EVMObjectCompiler.cpp b/libyul/backends/evm/EVMObjectCompiler.cpp index 6463b4a46..98c209bf2 100644 --- a/libyul/backends/evm/EVMObjectCompiler.cpp +++ b/libyul/backends/evm/EVMObjectCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Compiler that transforms Yul Objects to EVM bytecode objects. */ diff --git a/libyul/backends/evm/EVMObjectCompiler.h b/libyul/backends/evm/EVMObjectCompiler.h index fb40ac739..74ea71ac6 100644 --- a/libyul/backends/evm/EVMObjectCompiler.h +++ b/libyul/backends/evm/EVMObjectCompiler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Compiler that transforms Yul Objects to EVM bytecode objects. */ diff --git a/libyul/backends/evm/NoOutputAssembly.cpp b/libyul/backends/evm/NoOutputAssembly.cpp index ee280338d..0d840ef66 100644 --- a/libyul/backends/evm/NoOutputAssembly.cpp +++ b/libyul/backends/evm/NoOutputAssembly.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Assembly interface that ignores everything. Can be used as a backend for a compilation dry-run. */ diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index ec7e5f2ec..0ba4cf67b 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Assembly interface that ignores everything. Can be used as a backend for a compilation dry-run. */ diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index 38438e12e..5746dfaaf 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that transforms internal Wasm representation to binary. */ diff --git a/libyul/backends/wasm/BinaryTransform.h b/libyul/backends/wasm/BinaryTransform.h index c505fe2dc..348250546 100644 --- a/libyul/backends/wasm/BinaryTransform.h +++ b/libyul/backends/wasm/BinaryTransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that transforms internal Wasm representation to binary. */ diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index ebcdd961b..abb898828 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Translates Yul code from EVM dialect to Ewasm dialect. */ diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.h b/libyul/backends/wasm/EVMToEwasmTranslator.h index 0bd86a317..ecb34ec11 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.h +++ b/libyul/backends/wasm/EVMToEwasmTranslator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Translates Yul code from EVM dialect to Ewasm dialect. */ diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index ee2aa86e4..059f89600 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that transforms internal Wasm representation to text. */ diff --git a/libyul/backends/wasm/TextTransform.h b/libyul/backends/wasm/TextTransform.h index b8b21f7f2..eb14da65d 100644 --- a/libyul/backends/wasm/TextTransform.h +++ b/libyul/backends/wasm/TextTransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that transforms internal Wasm representation to text. */ diff --git a/libyul/backends/wasm/WasmAST.h b/libyul/backends/wasm/WasmAST.h index b22b0db84..ced3b7bc6 100644 --- a/libyul/backends/wasm/WasmAST.h +++ b/libyul/backends/wasm/WasmAST.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Simplified in-memory representation of a Wasm AST. */ diff --git a/libyul/backends/wasm/WasmCodeTransform.cpp b/libyul/backends/wasm/WasmCodeTransform.cpp index 5171db1b1..de87028a9 100644 --- a/libyul/backends/wasm/WasmCodeTransform.cpp +++ b/libyul/backends/wasm/WasmCodeTransform.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Common code generator for translating Yul / inline assembly to Wasm. */ diff --git a/libyul/backends/wasm/WasmCodeTransform.h b/libyul/backends/wasm/WasmCodeTransform.h index 326778b3d..79d3552c6 100644 --- a/libyul/backends/wasm/WasmCodeTransform.h +++ b/libyul/backends/wasm/WasmCodeTransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Common code generator for translating Yul / inline assembly to Wasm. */ diff --git a/libyul/backends/wasm/WasmDialect.cpp b/libyul/backends/wasm/WasmDialect.cpp index 9dddddd69..edf113a13 100644 --- a/libyul/backends/wasm/WasmDialect.cpp +++ b/libyul/backends/wasm/WasmDialect.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Dialects for Wasm. */ diff --git a/libyul/backends/wasm/WasmDialect.h b/libyul/backends/wasm/WasmDialect.h index e5f3c9fc4..a718f0b74 100644 --- a/libyul/backends/wasm/WasmDialect.h +++ b/libyul/backends/wasm/WasmDialect.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Dialects for Wasm. */ diff --git a/libyul/backends/wasm/WasmObjectCompiler.cpp b/libyul/backends/wasm/WasmObjectCompiler.cpp index 52d485a7f..2b4f0c355 100644 --- a/libyul/backends/wasm/WasmObjectCompiler.cpp +++ b/libyul/backends/wasm/WasmObjectCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Compiler that transforms Yul Objects to Wasm text and binary representation (Ewasm flavoured). */ diff --git a/libyul/backends/wasm/WasmObjectCompiler.h b/libyul/backends/wasm/WasmObjectCompiler.h index c5932a976..52e48a9d5 100644 --- a/libyul/backends/wasm/WasmObjectCompiler.h +++ b/libyul/backends/wasm/WasmObjectCompiler.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Compiler that transforms Yul Objects to Wasm text and binary representation (Ewasm flavoured). */ diff --git a/libyul/backends/wasm/WordSizeTransform.cpp b/libyul/backends/wasm/WordSizeTransform.cpp index 473f7324f..73dda9d0c 100644 --- a/libyul/backends/wasm/WordSizeTransform.cpp +++ b/libyul/backends/wasm/WordSizeTransform.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libyul/backends/wasm/WordSizeTransform.h b/libyul/backends/wasm/WordSizeTransform.h index 5771afea8..1bf7dcaca 100644 --- a/libyul/backends/wasm/WordSizeTransform.h +++ b/libyul/backends/wasm/WordSizeTransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Replace every u256 variable with four u64 variables. */ diff --git a/libyul/optimiser/ASTCopier.cpp b/libyul/optimiser/ASTCopier.cpp index 16f257818..8dc08f6fa 100644 --- a/libyul/optimiser/ASTCopier.cpp +++ b/libyul/optimiser/ASTCopier.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Creates an independent copy of an AST, renaming identifiers to be unique. */ diff --git a/libyul/optimiser/ASTCopier.h b/libyul/optimiser/ASTCopier.h index 3a05d2ca3..8afb50d97 100644 --- a/libyul/optimiser/ASTCopier.h +++ b/libyul/optimiser/ASTCopier.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Creates an independent copy of an AST, renaming identifiers to be unique. */ diff --git a/libyul/optimiser/ASTWalker.cpp b/libyul/optimiser/ASTWalker.cpp index 728949a4e..057f94b88 100644 --- a/libyul/optimiser/ASTWalker.cpp +++ b/libyul/optimiser/ASTWalker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Generic AST walker. */ diff --git a/libyul/optimiser/ASTWalker.h b/libyul/optimiser/ASTWalker.h index 20f7fb9b4..c62be4844 100644 --- a/libyul/optimiser/ASTWalker.h +++ b/libyul/optimiser/ASTWalker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Generic AST walker. */ diff --git a/libyul/optimiser/BlockFlattener.cpp b/libyul/optimiser/BlockFlattener.cpp index 02e4c42f5..24f57594c 100644 --- a/libyul/optimiser/BlockFlattener.cpp +++ b/libyul/optimiser/BlockFlattener.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/BlockFlattener.h b/libyul/optimiser/BlockFlattener.h index 31d3307d1..87a1af7cf 100644 --- a/libyul/optimiser/BlockFlattener.h +++ b/libyul/optimiser/BlockFlattener.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/BlockHasher.cpp b/libyul/optimiser/BlockHasher.cpp index 53d263f94..4fb199982 100644 --- a/libyul/optimiser/BlockHasher.cpp +++ b/libyul/optimiser/BlockHasher.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that calculates hash values for block prefixes. */ diff --git a/libyul/optimiser/BlockHasher.h b/libyul/optimiser/BlockHasher.h index 3b90f0c4d..36826e158 100644 --- a/libyul/optimiser/BlockHasher.h +++ b/libyul/optimiser/BlockHasher.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that calculates hash values for blocks. */ diff --git a/libyul/optimiser/CallGraphGenerator.cpp b/libyul/optimiser/CallGraphGenerator.cpp index 565518af0..85fb1c66c 100644 --- a/libyul/optimiser/CallGraphGenerator.cpp +++ b/libyul/optimiser/CallGraphGenerator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST walker that generates the call graph. */ diff --git a/libyul/optimiser/CallGraphGenerator.h b/libyul/optimiser/CallGraphGenerator.h index 2b57f8592..11224eeaa 100644 --- a/libyul/optimiser/CallGraphGenerator.h +++ b/libyul/optimiser/CallGraphGenerator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST walker that generates the call graph. */ diff --git a/libyul/optimiser/CircularReferencesPruner.cpp b/libyul/optimiser/CircularReferencesPruner.cpp index f9c849568..2fe6a1d80 100644 --- a/libyul/optimiser/CircularReferencesPruner.cpp +++ b/libyul/optimiser/CircularReferencesPruner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libyul/optimiser/CircularReferencesPruner.h b/libyul/optimiser/CircularReferencesPruner.h index 2a51045d1..0602445af 100644 --- a/libyul/optimiser/CircularReferencesPruner.h +++ b/libyul/optimiser/CircularReferencesPruner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimization stage that removes functions that call each other but are * otherwise unreferenced. diff --git a/libyul/optimiser/CommonSubexpressionEliminator.h b/libyul/optimiser/CommonSubexpressionEliminator.h index 04fc36a8c..f11de51a4 100644 --- a/libyul/optimiser/CommonSubexpressionEliminator.h +++ b/libyul/optimiser/CommonSubexpressionEliminator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that replaces expressions known to be the current value of a variable * in scope by a reference to that variable. diff --git a/libyul/optimiser/ConditionalSimplifier.cpp b/libyul/optimiser/ConditionalSimplifier.cpp index 453d2d9ce..f95ef830a 100644 --- a/libyul/optimiser/ConditionalSimplifier.cpp +++ b/libyul/optimiser/ConditionalSimplifier.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/ConditionalSimplifier.h b/libyul/optimiser/ConditionalSimplifier.h index 18f8a74b2..9a48b813f 100644 --- a/libyul/optimiser/ConditionalSimplifier.h +++ b/libyul/optimiser/ConditionalSimplifier.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/ConditionalUnsimplifier.cpp b/libyul/optimiser/ConditionalUnsimplifier.cpp index f11079032..28bc11a0c 100644 --- a/libyul/optimiser/ConditionalUnsimplifier.cpp +++ b/libyul/optimiser/ConditionalUnsimplifier.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/ConditionalUnsimplifier.h b/libyul/optimiser/ConditionalUnsimplifier.h index 116ab2536..975011b95 100644 --- a/libyul/optimiser/ConditionalUnsimplifier.h +++ b/libyul/optimiser/ConditionalUnsimplifier.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/ControlFlowSimplifier.cpp b/libyul/optimiser/ControlFlowSimplifier.cpp index 1d6b09615..044061d9d 100644 --- a/libyul/optimiser/ControlFlowSimplifier.cpp +++ b/libyul/optimiser/ControlFlowSimplifier.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/ControlFlowSimplifier.h b/libyul/optimiser/ControlFlowSimplifier.h index f8ea1af1e..3ebbe7c9a 100644 --- a/libyul/optimiser/ControlFlowSimplifier.h +++ b/libyul/optimiser/ControlFlowSimplifier.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index d3cb8d280..237b48597 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Base class to perform data flow analysis during AST walks. * Tracks assignments and is used as base class for both Rematerialiser and diff --git a/libyul/optimiser/DeadCodeEliminator.cpp b/libyul/optimiser/DeadCodeEliminator.cpp index 2416af514..1bb4f460d 100644 --- a/libyul/optimiser/DeadCodeEliminator.cpp +++ b/libyul/optimiser/DeadCodeEliminator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that removes unreachable code. */ diff --git a/libyul/optimiser/DeadCodeEliminator.h b/libyul/optimiser/DeadCodeEliminator.h index d1607b49e..d47bf86ea 100644 --- a/libyul/optimiser/DeadCodeEliminator.h +++ b/libyul/optimiser/DeadCodeEliminator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that removes unused variables and functions. */ diff --git a/libyul/optimiser/Disambiguator.cpp b/libyul/optimiser/Disambiguator.cpp index 50aa93599..2e20d4be2 100644 --- a/libyul/optimiser/Disambiguator.cpp +++ b/libyul/optimiser/Disambiguator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that makes all identifiers unique. */ diff --git a/libyul/optimiser/Disambiguator.h b/libyul/optimiser/Disambiguator.h index 997a9cf20..6d8a3775c 100644 --- a/libyul/optimiser/Disambiguator.h +++ b/libyul/optimiser/Disambiguator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that makes all identifiers unique. */ diff --git a/libyul/optimiser/EquivalentFunctionCombiner.cpp b/libyul/optimiser/EquivalentFunctionCombiner.cpp index d62768a25..8cea5d63e 100644 --- a/libyul/optimiser/EquivalentFunctionCombiner.cpp +++ b/libyul/optimiser/EquivalentFunctionCombiner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that combines syntactically equivalent functions. */ diff --git a/libyul/optimiser/EquivalentFunctionCombiner.h b/libyul/optimiser/EquivalentFunctionCombiner.h index 19ddbd71f..d43fa3986 100644 --- a/libyul/optimiser/EquivalentFunctionCombiner.h +++ b/libyul/optimiser/EquivalentFunctionCombiner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that combines syntactically equivalent functions. */ diff --git a/libyul/optimiser/EquivalentFunctionDetector.cpp b/libyul/optimiser/EquivalentFunctionDetector.cpp index 6c617a4e4..5c49ddb89 100644 --- a/libyul/optimiser/EquivalentFunctionDetector.cpp +++ b/libyul/optimiser/EquivalentFunctionDetector.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that combines syntactically equivalent functions. */ diff --git a/libyul/optimiser/EquivalentFunctionDetector.h b/libyul/optimiser/EquivalentFunctionDetector.h index 62825bcfa..107b355e6 100644 --- a/libyul/optimiser/EquivalentFunctionDetector.h +++ b/libyul/optimiser/EquivalentFunctionDetector.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that combines syntactically equivalent functions. */ diff --git a/libyul/optimiser/ExpressionInliner.cpp b/libyul/optimiser/ExpressionInliner.cpp index f17b594f3..ca29a5829 100644 --- a/libyul/optimiser/ExpressionInliner.cpp +++ b/libyul/optimiser/ExpressionInliner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that performs function inlining inside expressions. */ diff --git a/libyul/optimiser/ExpressionInliner.h b/libyul/optimiser/ExpressionInliner.h index 92bdebffc..f3a8833df 100644 --- a/libyul/optimiser/ExpressionInliner.h +++ b/libyul/optimiser/ExpressionInliner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that performs function inlining. */ diff --git a/libyul/optimiser/ExpressionJoiner.cpp b/libyul/optimiser/ExpressionJoiner.cpp index 45c23dcc3..fa9aac9ce 100644 --- a/libyul/optimiser/ExpressionJoiner.cpp +++ b/libyul/optimiser/ExpressionJoiner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that undoes what the ExpressionSplitter did, i.e. * it more or less inlines variable declarations. diff --git a/libyul/optimiser/ExpressionJoiner.h b/libyul/optimiser/ExpressionJoiner.h index 709a822e7..db3217de0 100644 --- a/libyul/optimiser/ExpressionJoiner.h +++ b/libyul/optimiser/ExpressionJoiner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that undoes what the ExpressionSplitter did, i.e. * it more or less inlines variable declarations. diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp index da3056057..ec3a6eb78 100644 --- a/libyul/optimiser/ExpressionSimplifier.cpp +++ b/libyul/optimiser/ExpressionSimplifier.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that uses the simplification rules to simplify expressions. */ diff --git a/libyul/optimiser/ExpressionSimplifier.h b/libyul/optimiser/ExpressionSimplifier.h index ce83b4e1e..b8703e2a2 100644 --- a/libyul/optimiser/ExpressionSimplifier.h +++ b/libyul/optimiser/ExpressionSimplifier.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that uses the simplification rules to simplify expressions. */ diff --git a/libyul/optimiser/ExpressionSplitter.cpp b/libyul/optimiser/ExpressionSplitter.cpp index 30a5fd5e9..2c15b6eb5 100644 --- a/libyul/optimiser/ExpressionSplitter.cpp +++ b/libyul/optimiser/ExpressionSplitter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that turns complex expressions into multiple variable * declarations. diff --git a/libyul/optimiser/ExpressionSplitter.h b/libyul/optimiser/ExpressionSplitter.h index 107be2590..ebcdd7f6d 100644 --- a/libyul/optimiser/ExpressionSplitter.h +++ b/libyul/optimiser/ExpressionSplitter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that turns complex expressions into multiple variable * declarations. diff --git a/libyul/optimiser/ForLoopConditionIntoBody.cpp b/libyul/optimiser/ForLoopConditionIntoBody.cpp index 22c3e76dc..a5b907ce7 100644 --- a/libyul/optimiser/ForLoopConditionIntoBody.cpp +++ b/libyul/optimiser/ForLoopConditionIntoBody.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libyul/optimiser/ForLoopConditionIntoBody.h b/libyul/optimiser/ForLoopConditionIntoBody.h index 633403c96..2a9c92c23 100644 --- a/libyul/optimiser/ForLoopConditionIntoBody.h +++ b/libyul/optimiser/ForLoopConditionIntoBody.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/ForLoopConditionOutOfBody.cpp b/libyul/optimiser/ForLoopConditionOutOfBody.cpp index fc7d48d62..f13b417e8 100644 --- a/libyul/optimiser/ForLoopConditionOutOfBody.cpp +++ b/libyul/optimiser/ForLoopConditionOutOfBody.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libyul/optimiser/ForLoopConditionOutOfBody.h b/libyul/optimiser/ForLoopConditionOutOfBody.h index b5f8c8d02..ba3b7eb18 100644 --- a/libyul/optimiser/ForLoopConditionOutOfBody.h +++ b/libyul/optimiser/ForLoopConditionOutOfBody.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index 163a999cd..62d520199 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/ForLoopInitRewriter.h b/libyul/optimiser/ForLoopInitRewriter.h index e2143ca61..96ae0cca7 100644 --- a/libyul/optimiser/ForLoopInitRewriter.h +++ b/libyul/optimiser/ForLoopInitRewriter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index a0c80533d..2e9dd1e05 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that performs function inlining for arbitrary functions. */ diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h index 1c1ad0d95..8092e478e 100644 --- a/libyul/optimiser/FullInliner.h +++ b/libyul/optimiser/FullInliner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that performs function inlining for arbitrary functions. */ diff --git a/libyul/optimiser/FunctionGrouper.cpp b/libyul/optimiser/FunctionGrouper.cpp index 60a1fa013..86d59dd53 100644 --- a/libyul/optimiser/FunctionGrouper.cpp +++ b/libyul/optimiser/FunctionGrouper.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that changes the code of a block so that all non-function definition * statements are moved to a block of their own followed by all function definitions. diff --git a/libyul/optimiser/FunctionGrouper.h b/libyul/optimiser/FunctionGrouper.h index ef3619893..0bfbb2f06 100644 --- a/libyul/optimiser/FunctionGrouper.h +++ b/libyul/optimiser/FunctionGrouper.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that changes the code of a black so that all non-function definition * instructions are moved to a block of their own followed by all function definitions. diff --git a/libyul/optimiser/FunctionHoister.cpp b/libyul/optimiser/FunctionHoister.cpp index 303cf1fb3..a02feeda8 100644 --- a/libyul/optimiser/FunctionHoister.cpp +++ b/libyul/optimiser/FunctionHoister.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that changes the code so that it consists of a block starting with * a single block followed only by function definitions and with no functions defined diff --git a/libyul/optimiser/FunctionHoister.h b/libyul/optimiser/FunctionHoister.h index 7106c03a4..39e692c8a 100644 --- a/libyul/optimiser/FunctionHoister.h +++ b/libyul/optimiser/FunctionHoister.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that changes the code so that all function definitions are at the top * level block. diff --git a/libyul/optimiser/InlinableExpressionFunctionFinder.cpp b/libyul/optimiser/InlinableExpressionFunctionFinder.cpp index c9a1f084b..c7830d480 100644 --- a/libyul/optimiser/InlinableExpressionFunctionFinder.cpp +++ b/libyul/optimiser/InlinableExpressionFunctionFinder.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that identifies functions to be inlined. */ diff --git a/libyul/optimiser/InlinableExpressionFunctionFinder.h b/libyul/optimiser/InlinableExpressionFunctionFinder.h index 0583107d1..3c0b768e6 100644 --- a/libyul/optimiser/InlinableExpressionFunctionFinder.h +++ b/libyul/optimiser/InlinableExpressionFunctionFinder.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that identifies functions to be inlined. */ diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index c68085420..0692d0c06 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Class that can answer questions about values of variables and their relations. */ diff --git a/libyul/optimiser/KnowledgeBase.h b/libyul/optimiser/KnowledgeBase.h index 8d7bcdd90..7d4cdfb6b 100644 --- a/libyul/optimiser/KnowledgeBase.h +++ b/libyul/optimiser/KnowledgeBase.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Class that can answer questions about values of variables and their relations. */ diff --git a/libyul/optimiser/LoadResolver.cpp b/libyul/optimiser/LoadResolver.cpp index 4d40281ec..7635f9d61 100644 --- a/libyul/optimiser/LoadResolver.cpp +++ b/libyul/optimiser/LoadResolver.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that replaces expressions of type ``sload(x)`` by the value * currently stored in storage, if known. diff --git a/libyul/optimiser/LoadResolver.h b/libyul/optimiser/LoadResolver.h index f2d11ed2a..00579e95f 100644 --- a/libyul/optimiser/LoadResolver.h +++ b/libyul/optimiser/LoadResolver.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that replaces expressions of type ``sload(x)`` by the value * currently stored in storage, if known. diff --git a/libyul/optimiser/LoopInvariantCodeMotion.cpp b/libyul/optimiser/LoopInvariantCodeMotion.cpp index b7d7874c2..9a81e5fc8 100644 --- a/libyul/optimiser/LoopInvariantCodeMotion.cpp +++ b/libyul/optimiser/LoopInvariantCodeMotion.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/libyul/optimiser/LoopInvariantCodeMotion.h b/libyul/optimiser/LoopInvariantCodeMotion.h index 7b7bd6c88..a3bf1784f 100644 --- a/libyul/optimiser/LoopInvariantCodeMotion.h +++ b/libyul/optimiser/LoopInvariantCodeMotion.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/MainFunction.cpp b/libyul/optimiser/MainFunction.cpp index e91cadb4d..83968651d 100644 --- a/libyul/optimiser/MainFunction.cpp +++ b/libyul/optimiser/MainFunction.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Changes the topmost block to be a function with a specific name ("main") which has no * inputs nor outputs. diff --git a/libyul/optimiser/MainFunction.h b/libyul/optimiser/MainFunction.h index 771624bef..92781f81c 100644 --- a/libyul/optimiser/MainFunction.h +++ b/libyul/optimiser/MainFunction.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Changes the topmost block to be a function with a specific name ("main") which has no * inputs nor outputs. diff --git a/libyul/optimiser/Metrics.h b/libyul/optimiser/Metrics.h index 19ca5616f..5aa8dbe4b 100644 --- a/libyul/optimiser/Metrics.h +++ b/libyul/optimiser/Metrics.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module providing metrics for the optimizer. */ diff --git a/libyul/optimiser/NameCollector.cpp b/libyul/optimiser/NameCollector.cpp index f9bb40bf4..5c6f2ab79 100644 --- a/libyul/optimiser/NameCollector.cpp +++ b/libyul/optimiser/NameCollector.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST walker that collects all defined names. */ diff --git a/libyul/optimiser/NameCollector.h b/libyul/optimiser/NameCollector.h index a48aa1a3b..0bedab3f8 100644 --- a/libyul/optimiser/NameCollector.h +++ b/libyul/optimiser/NameCollector.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST walkers that collect facts about identifiers and definitions. */ diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp index fb1c1dd1c..cfc7fdcb9 100644 --- a/libyul/optimiser/NameDispenser.cpp +++ b/libyul/optimiser/NameDispenser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that can create new unique names. */ diff --git a/libyul/optimiser/NameDispenser.h b/libyul/optimiser/NameDispenser.h index 372e4bd2c..1ef8c92e7 100644 --- a/libyul/optimiser/NameDispenser.h +++ b/libyul/optimiser/NameDispenser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that can create new unique names. */ diff --git a/libyul/optimiser/NameDisplacer.cpp b/libyul/optimiser/NameDisplacer.cpp index 052b011ef..81248819c 100644 --- a/libyul/optimiser/NameDisplacer.cpp +++ b/libyul/optimiser/NameDisplacer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that renames identifiers to free up certain names. */ diff --git a/libyul/optimiser/NameDisplacer.h b/libyul/optimiser/NameDisplacer.h index ba61cbf9d..d1b3e4363 100644 --- a/libyul/optimiser/NameDisplacer.h +++ b/libyul/optimiser/NameDisplacer.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that renames identifiers to free up certain names. */ diff --git a/libyul/optimiser/OptimiserStep.h b/libyul/optimiser/OptimiserStep.h index ebad29551..3da161957 100644 --- a/libyul/optimiser/OptimiserStep.h +++ b/libyul/optimiser/OptimiserStep.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libyul/optimiser/OptimizerUtilities.cpp b/libyul/optimiser/OptimizerUtilities.cpp index 132301696..3cb66d689 100644 --- a/libyul/optimiser/OptimizerUtilities.cpp +++ b/libyul/optimiser/OptimizerUtilities.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Some useful snippets for the optimiser. */ diff --git a/libyul/optimiser/OptimizerUtilities.h b/libyul/optimiser/OptimizerUtilities.h index 01bb7dae6..61d970877 100644 --- a/libyul/optimiser/OptimizerUtilities.h +++ b/libyul/optimiser/OptimizerUtilities.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Small useful snippets for the optimiser. */ diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp index 5d1d0557b..170cf1d79 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/RedundantAssignEliminator.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that removes assignments to variables that are not used * until they go out of scope or are re-assigned. diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/RedundantAssignEliminator.h index 3d61e84fb..81e977e8d 100644 --- a/libyul/optimiser/RedundantAssignEliminator.h +++ b/libyul/optimiser/RedundantAssignEliminator.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that removes assignments to variables that are not used * until they go out of scope or are re-assigned. diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h index 1316f0373..b7e98a6b8 100644 --- a/libyul/optimiser/Rematerialiser.h +++ b/libyul/optimiser/Rematerialiser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that replaces variables by their most recently assigned expressions. */ diff --git a/libyul/optimiser/SSAReverser.cpp b/libyul/optimiser/SSAReverser.cpp index a4373fb66..decdc4ea4 100644 --- a/libyul/optimiser/SSAReverser.cpp +++ b/libyul/optimiser/SSAReverser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/SSAReverser.h b/libyul/optimiser/SSAReverser.h index 0a6e0e1b0..bb6e98bc8 100644 --- a/libyul/optimiser/SSAReverser.h +++ b/libyul/optimiser/SSAReverser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp index 21165cd47..332b7af1d 100644 --- a/libyul/optimiser/SSATransform.cpp +++ b/libyul/optimiser/SSATransform.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that turns subsequent assignments to variable declarations * and assignments. diff --git a/libyul/optimiser/SSATransform.h b/libyul/optimiser/SSATransform.h index 201b1981a..74e52b62a 100644 --- a/libyul/optimiser/SSATransform.h +++ b/libyul/optimiser/SSATransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser component that turns subsequent assignments to variable declarations * and assignments. diff --git a/libyul/optimiser/SSAValueTracker.cpp b/libyul/optimiser/SSAValueTracker.cpp index ec898ad3c..452123447 100644 --- a/libyul/optimiser/SSAValueTracker.cpp +++ b/libyul/optimiser/SSAValueTracker.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that collects variables that are never assigned to and their * initial values. diff --git a/libyul/optimiser/SSAValueTracker.h b/libyul/optimiser/SSAValueTracker.h index 24f480947..f206cab5e 100644 --- a/libyul/optimiser/SSAValueTracker.h +++ b/libyul/optimiser/SSAValueTracker.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that collects variables that are never assigned to and their * initial values. diff --git a/libyul/optimiser/Semantics.cpp b/libyul/optimiser/Semantics.cpp index 6100b1cdc..4a7b8db12 100644 --- a/libyul/optimiser/Semantics.cpp +++ b/libyul/optimiser/Semantics.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST walkers that collect semantical facts. */ diff --git a/libyul/optimiser/Semantics.h b/libyul/optimiser/Semantics.h index 46d2984ca..a4f7b8102 100644 --- a/libyul/optimiser/Semantics.h +++ b/libyul/optimiser/Semantics.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST walkers that collect semantical facts. */ diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index 7a9b6576a..2fe5de3e5 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module for applying replacement rules against Expressions. */ diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h index b897ed492..05e4e0d59 100644 --- a/libyul/optimiser/SimplificationRules.h +++ b/libyul/optimiser/SimplificationRules.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Module for applying replacement rules against Expressions. */ diff --git a/libyul/optimiser/StackCompressor.h b/libyul/optimiser/StackCompressor.h index 6c9f1ff9a..f10a6ba17 100644 --- a/libyul/optimiser/StackCompressor.h +++ b/libyul/optimiser/StackCompressor.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that aggressively rematerializes certain variables ina a function to free * space on the stack until it is compilable. diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp index 0d5da95c1..09fe9ca1f 100644 --- a/libyul/optimiser/StructuralSimplifier.cpp +++ b/libyul/optimiser/StructuralSimplifier.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include #include diff --git a/libyul/optimiser/StructuralSimplifier.h b/libyul/optimiser/StructuralSimplifier.h index 8b9df5beb..3fd59efde 100644 --- a/libyul/optimiser/StructuralSimplifier.h +++ b/libyul/optimiser/StructuralSimplifier.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/libyul/optimiser/Substitution.cpp b/libyul/optimiser/Substitution.cpp index 6a0dc4800..ee2323577 100644 --- a/libyul/optimiser/Substitution.cpp +++ b/libyul/optimiser/Substitution.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST copier that replaces certain identifiers with expressions. */ diff --git a/libyul/optimiser/Substitution.h b/libyul/optimiser/Substitution.h index 369754fea..f76dcc72e 100644 --- a/libyul/optimiser/Substitution.h +++ b/libyul/optimiser/Substitution.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Specific AST copier that replaces certain identifiers with expressions. */ diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 9f2511e72..a12ecd194 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser suite that combines all steps and also provides the settings for the heuristics. */ diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h index 790b2f9ad..affbd37c0 100644 --- a/libyul/optimiser/Suite.h +++ b/libyul/optimiser/Suite.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimiser suite that combines all steps and also provides the settings for the heuristics. */ diff --git a/libyul/optimiser/SyntacticalEquality.h b/libyul/optimiser/SyntacticalEquality.h index 7cf5dc24a..774a223cc 100644 --- a/libyul/optimiser/SyntacticalEquality.h +++ b/libyul/optimiser/SyntacticalEquality.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Component that can compare ASTs for equality on a syntactic basis. */ diff --git a/libyul/optimiser/TypeInfo.cpp b/libyul/optimiser/TypeInfo.cpp index adb6e1cce..740856c72 100644 --- a/libyul/optimiser/TypeInfo.cpp +++ b/libyul/optimiser/TypeInfo.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Helper class that keeps track of the types while performing optimizations. */ diff --git a/libyul/optimiser/TypeInfo.h b/libyul/optimiser/TypeInfo.h index 48c6c1fba..f458cbe44 100644 --- a/libyul/optimiser/TypeInfo.h +++ b/libyul/optimiser/TypeInfo.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Helper class that keeps track of the types while performing optimizations. */ diff --git a/libyul/optimiser/UnusedPruner.h b/libyul/optimiser/UnusedPruner.h index 837088059..af77d911a 100644 --- a/libyul/optimiser/UnusedPruner.h +++ b/libyul/optimiser/UnusedPruner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Optimisation stage that removes unused variables and functions. */ diff --git a/libyul/optimiser/VarDeclInitializer.cpp b/libyul/optimiser/VarDeclInitializer.cpp index 66c5b4505..ca6c89feb 100644 --- a/libyul/optimiser/VarDeclInitializer.cpp +++ b/libyul/optimiser/VarDeclInitializer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libyul/optimiser/VarDeclInitializer.h b/libyul/optimiser/VarDeclInitializer.h index 75bb1493c..3d2d51c34 100644 --- a/libyul/optimiser/VarDeclInitializer.h +++ b/libyul/optimiser/VarDeclInitializer.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/libyul/optimiser/VarNameCleaner.cpp b/libyul/optimiser/VarNameCleaner.cpp index f9b9e7899..15d215f2c 100644 --- a/libyul/optimiser/VarNameCleaner.cpp +++ b/libyul/optimiser/VarNameCleaner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/libyul/optimiser/VarNameCleaner.h b/libyul/optimiser/VarNameCleaner.h index 911f67ca6..2c26cc7a6 100644 --- a/libyul/optimiser/VarNameCleaner.h +++ b/libyul/optimiser/VarNameCleaner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 3bd374676..412d7f094 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @author Gav Wood diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index 1aed72821..e79d81406 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @date 2014 diff --git a/solc/main.cpp b/solc/main.cpp index 5307e40ad..ae56066ed 100644 --- a/solc/main.cpp +++ b/solc/main.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/test/Common.cpp b/test/Common.cpp index 69bfd21ee..b56cb3257 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/Common.h b/test/Common.h index 119050f39..eaad7f0ba 100644 --- a/test/Common.h +++ b/test/Common.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/CommonSyntaxTest.cpp b/test/CommonSyntaxTest.cpp index ff99d6e24..34ddf719e 100644 --- a/test/CommonSyntaxTest.cpp +++ b/test/CommonSyntaxTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/CommonSyntaxTest.h b/test/CommonSyntaxTest.h index df165ea1a..db3a6e50c 100644 --- a/test/CommonSyntaxTest.h +++ b/test/CommonSyntaxTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 108dae4f1..51dc83352 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * EVM execution host, i.e. component that implements a simulated Ethereum blockchain * for testing purposes. diff --git a/test/EVMHost.h b/test/EVMHost.h index 1e3540012..af38426be 100644 --- a/test/EVMHost.h +++ b/test/EVMHost.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * EVM execution host, i.e. component that implements a simulated Ethereum blockchain * for testing purposes. diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index ebe63b265..b3841f6b4 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 6fea5310a..56321a119 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/test/InteractiveTests.h b/test/InteractiveTests.h index 4e8365796..46d8a2973 100644 --- a/test/InteractiveTests.h +++ b/test/InteractiveTests.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/Metadata.cpp b/test/Metadata.cpp index cb5892b8a..f70b8ea5f 100644 --- a/test/Metadata.cpp +++ b/test/Metadata.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Metadata processing helpers. diff --git a/test/Metadata.h b/test/Metadata.h index f032f1d1f..c91ceb559 100644 --- a/test/Metadata.h +++ b/test/Metadata.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Metadata processing helpers. diff --git a/test/TestCase.cpp b/test/TestCase.cpp index e6f4b212a..7cf5c790e 100644 --- a/test/TestCase.cpp +++ b/test/TestCase.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/TestCase.h b/test/TestCase.h index f846b7f87..1815409fe 100644 --- a/test/TestCase.h +++ b/test/TestCase.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/TestCaseReader.cpp b/test/TestCaseReader.cpp index 2f90678ed..7b3611d82 100644 --- a/test/TestCaseReader.cpp +++ b/test/TestCaseReader.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/TestCaseReader.h b/test/TestCaseReader.h index 9f94f898d..720c26338 100644 --- a/test/TestCaseReader.h +++ b/test/TestCaseReader.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 19cdfc423..8f065a7bb 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file boostTest.cpp * @author Marko Simovic * @date 2014 diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp index 71e47aa0c..b3621238b 100644 --- a/test/contracts/AuctionRegistrar.cpp +++ b/test/contracts/AuctionRegistrar.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/test/contracts/ContractInterface.h b/test/contracts/ContractInterface.h index 4d063947e..1bc1d9e39 100644 --- a/test/contracts/ContractInterface.h +++ b/test/contracts/ContractInterface.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp index a2998379f..f953cda9a 100644 --- a/test/contracts/FixedFeeRegistrar.cpp +++ b/test/contracts/FixedFeeRegistrar.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 46800fa78..503282094 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index cdb7046be..c2140ace6 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Alex Beregszaszi * @date 2018 diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 4690ceddc..741dc7523 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/test/liblangutil/CharStream.cpp b/test/liblangutil/CharStream.cpp index 3b9d980c1..d1189c3e9 100644 --- a/test/liblangutil/CharStream.cpp +++ b/test/liblangutil/CharStream.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Rocky Bernstein * @date 2019 diff --git a/test/liblangutil/SourceLocation.cpp b/test/liblangutil/SourceLocation.cpp index c5b47d0f6..ff1664dfe 100644 --- a/test/liblangutil/SourceLocation.cpp +++ b/test/liblangutil/SourceLocation.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Yoichi Hirai * @date 2016 diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index 39bf7602c..2c3711ea3 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for Solidity's ABI decoder. */ diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index 777f991a3..b804a458d 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for Solidity's ABI encoder. */ diff --git a/test/libsolidity/ABIJsonTest.h b/test/libsolidity/ABIJsonTest.h index 702d36dbf..0cc7e674e 100644 --- a/test/libsolidity/ABIJsonTest.h +++ b/test/libsolidity/ABIJsonTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the solidity compiler ABI JSON Interface output. */ diff --git a/test/libsolidity/ABITestsCommon.h b/test/libsolidity/ABITestsCommon.h index b2afcf125..c5eea01ca 100644 --- a/test/libsolidity/ABITestsCommon.h +++ b/test/libsolidity/ABITestsCommon.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index 974e0f486..979c79aa5 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h index 45d7a08b9..4e74d79f3 100644 --- a/test/libsolidity/ASTJSONTest.h +++ b/test/libsolidity/ASTJSONTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 80c20c760..bd28de240 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Framework for testing features from the analysis phase of compiler. */ diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index db75ad301..293e0e17c 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Framework for testing features from the analysis phase of compiler. */ diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index 23bf1a2f8..12e088fac 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris Karapetsas * @date 2015 diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp index 1f51006ed..42b527e5b 100644 --- a/test/libsolidity/ErrorCheck.cpp +++ b/test/libsolidity/ErrorCheck.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file ErrorCheck.cpp * @author Yoichi Hirai * @date 2016 diff --git a/test/libsolidity/ErrorCheck.h b/test/libsolidity/ErrorCheck.h index 5deae56dc..e01c2ca52 100644 --- a/test/libsolidity/ErrorCheck.h +++ b/test/libsolidity/ErrorCheck.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file ErrorCheck.h * @author Yoichi Hirai * @date 2016 diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp index 252b7759b..2ad1368a6 100644 --- a/test/libsolidity/GasCosts.cpp +++ b/test/libsolidity/GasCosts.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Tests that check that the cost of certain operations stay within range. */ diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 09e257664..c8296beb1 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index d76979c9c..f996f7352 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libsolidity/GasTest.h b/test/libsolidity/GasTest.h index d8bd0acad..da14e5292 100644 --- a/test/libsolidity/GasTest.h +++ b/test/libsolidity/GasTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index aa4cab9b8..bbbefb33e 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index 9802e37c2..3375f8f92 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Unit tests for libsolc/libsolc.cpp. diff --git a/test/libsolidity/SMTCheckerJSONTest.cpp b/test/libsolidity/SMTCheckerJSONTest.cpp index e1b977cf5..ca6608905 100644 --- a/test/libsolidity/SMTCheckerJSONTest.cpp +++ b/test/libsolidity/SMTCheckerJSONTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libsolidity/SMTCheckerJSONTest.h b/test/libsolidity/SMTCheckerJSONTest.h index b5d199e7d..6de7f36c9 100644 --- a/test/libsolidity/SMTCheckerJSONTest.h +++ b/test/libsolidity/SMTCheckerJSONTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libsolidity/SMTCheckerTest.cpp b/test/libsolidity/SMTCheckerTest.cpp index ac858747d..51d1e7b36 100644 --- a/test/libsolidity/SMTCheckerTest.cpp +++ b/test/libsolidity/SMTCheckerTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libsolidity/SMTCheckerTest.h b/test/libsolidity/SMTCheckerTest.h index b710cde45..522abb677 100644 --- a/test/libsolidity/SMTCheckerTest.h +++ b/test/libsolidity/SMTCheckerTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libsolidity/SemVerMatcher.cpp b/test/libsolidity/SemVerMatcher.cpp index 36b9c8214..a3e1661ef 100644 --- a/test/libsolidity/SemVerMatcher.cpp +++ b/test/libsolidity/SemVerMatcher.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index d449cd27e..59f01096d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @author Gav Wood diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index 2d0ae44da..d0f4227cc 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2016 diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h index 5be310c87..9efe22b20 100644 --- a/test/libsolidity/SolidityExecutionFramework.h +++ b/test/libsolidity/SolidityExecutionFramework.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 10083b827..a1db40747 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index c4f7a2e71..952eac940 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2014 diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index bc9f16904..b837b3878 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @author Christian * @date 2015 diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 0b2098097..570350466 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Unit tests for interface/StandardCompiler.h. diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index 48a293b65..c554366e9 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index dbc5d68b3..b71691bea 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libsolidity/util/BytesUtils.cpp b/test/libsolidity/util/BytesUtils.cpp index 7416ca9a2..d095a0a76 100644 --- a/test/libsolidity/util/BytesUtils.cpp +++ b/test/libsolidity/util/BytesUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libsolidity/util/ContractABIUtils.cpp b/test/libsolidity/util/ContractABIUtils.cpp index 2e600e4c1..a3a19e6e5 100644 --- a/test/libsolidity/util/ContractABIUtils.cpp +++ b/test/libsolidity/util/ContractABIUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 52e4156aa..046193d39 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libsolidity/util/TestFileParserTests.cpp b/test/libsolidity/util/TestFileParserTests.cpp index 4fb44d7cd..6b3ba2d7a 100644 --- a/test/libsolidity/util/TestFileParserTests.cpp +++ b/test/libsolidity/util/TestFileParserTests.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for Solidity's test expectation parser. */ diff --git a/test/libsolidity/util/TestFunctionCallTests.cpp b/test/libsolidity/util/TestFunctionCallTests.cpp index 7b34cbe8e..dc3030384 100644 --- a/test/libsolidity/util/TestFunctionCallTests.cpp +++ b/test/libsolidity/util/TestFunctionCallTests.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libsolutil/Checksum.cpp b/test/libsolutil/Checksum.cpp index 159c55efc..ab7ccf631 100644 --- a/test/libsolutil/Checksum.cpp +++ b/test/libsolutil/Checksum.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the address checksum. */ diff --git a/test/libsolutil/CommonData.cpp b/test/libsolutil/CommonData.cpp index d8434c79d..670a71d14 100644 --- a/test/libsolutil/CommonData.cpp +++ b/test/libsolutil/CommonData.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the StringUtils routines. */ diff --git a/test/libsolutil/IndentedWriter.cpp b/test/libsolutil/IndentedWriter.cpp index 3d0963e9f..0938f9617 100644 --- a/test/libsolutil/IndentedWriter.cpp +++ b/test/libsolutil/IndentedWriter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for IndentedWriter. */ diff --git a/test/libsolutil/IpfsHash.cpp b/test/libsolutil/IpfsHash.cpp index 40385d43f..c99650a4b 100644 --- a/test/libsolutil/IpfsHash.cpp +++ b/test/libsolutil/IpfsHash.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the ipfs hash computation routine. */ diff --git a/test/libsolutil/IterateReplacing.cpp b/test/libsolutil/IterateReplacing.cpp index e28091c76..a54841560 100644 --- a/test/libsolutil/IterateReplacing.cpp +++ b/test/libsolutil/IterateReplacing.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the iterateReplacing function */ diff --git a/test/libsolutil/JSON.cpp b/test/libsolutil/JSON.cpp index d0e86c3c7..666397877 100644 --- a/test/libsolutil/JSON.cpp +++ b/test/libsolutil/JSON.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2018 * Unit tests for JSON.h. diff --git a/test/libsolutil/Keccak256.cpp b/test/libsolutil/Keccak256.cpp index bad8510c5..17de6c885 100644 --- a/test/libsolutil/Keccak256.cpp +++ b/test/libsolutil/Keccak256.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for keccak256. */ diff --git a/test/libsolutil/LazyInit.cpp b/test/libsolutil/LazyInit.cpp index ec170946d..51ee3ee1e 100644 --- a/test/libsolutil/LazyInit.cpp +++ b/test/libsolutil/LazyInit.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libsolutil/StringUtils.cpp b/test/libsolutil/StringUtils.cpp index a9c03acd9..f678c0da7 100644 --- a/test/libsolutil/StringUtils.cpp +++ b/test/libsolutil/StringUtils.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the StringUtils routines. */ diff --git a/test/libsolutil/SwarmHash.cpp b/test/libsolutil/SwarmHash.cpp index cacb04adf..3b13cd382 100644 --- a/test/libsolutil/SwarmHash.cpp +++ b/test/libsolutil/SwarmHash.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the swarm hash computation routine. */ diff --git a/test/libsolutil/UTF8.cpp b/test/libsolutil/UTF8.cpp index 94ec6c6d7..d6a14bcff 100644 --- a/test/libsolutil/UTF8.cpp +++ b/test/libsolutil/UTF8.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for UTF-8 validation. */ diff --git a/test/libsolutil/Whiskers.cpp b/test/libsolutil/Whiskers.cpp index 3ed87acb9..1cc889127 100644 --- a/test/libsolutil/Whiskers.cpp +++ b/test/libsolutil/Whiskers.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Unit tests for the mini moustache class. */ diff --git a/test/libyul/EwasmTranslationTest.cpp b/test/libyul/EwasmTranslationTest.cpp index 9ef203dd0..dd732f9a8 100644 --- a/test/libyul/EwasmTranslationTest.cpp +++ b/test/libyul/EwasmTranslationTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libyul/EwasmTranslationTest.h b/test/libyul/EwasmTranslationTest.h index e0a90482b..f6307bdbc 100644 --- a/test/libyul/EwasmTranslationTest.h +++ b/test/libyul/EwasmTranslationTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libyul/FunctionSideEffects.cpp b/test/libyul/FunctionSideEffects.cpp index aa7d1e503..56051ffdd 100644 --- a/test/libyul/FunctionSideEffects.cpp +++ b/test/libyul/FunctionSideEffects.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libyul/FunctionSideEffects.h b/test/libyul/FunctionSideEffects.h index 23bebebcc..ac0653733 100644 --- a/test/libyul/FunctionSideEffects.h +++ b/test/libyul/FunctionSideEffects.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libyul/Inliner.cpp b/test/libyul/Inliner.cpp index de47f4885..f44d86618 100644 --- a/test/libyul/Inliner.cpp +++ b/test/libyul/Inliner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * @date 2017 * Unit tests for the Yul function inliner. diff --git a/test/libyul/ObjectCompilerTest.cpp b/test/libyul/ObjectCompilerTest.cpp index 4b34da7b1..950c0210f 100644 --- a/test/libyul/ObjectCompilerTest.cpp +++ b/test/libyul/ObjectCompilerTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libyul/ObjectCompilerTest.h b/test/libyul/ObjectCompilerTest.h index 4a1c75486..85a46a1cf 100644 --- a/test/libyul/ObjectCompilerTest.h +++ b/test/libyul/ObjectCompilerTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libyul/SyntaxTest.cpp b/test/libyul/SyntaxTest.cpp index 944ceaf33..bb0751b82 100644 --- a/test/libyul/SyntaxTest.cpp +++ b/test/libyul/SyntaxTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/libyul/SyntaxTest.h b/test/libyul/SyntaxTest.h index 342aa2845..7234e1f2c 100644 --- a/test/libyul/SyntaxTest.h +++ b/test/libyul/SyntaxTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libyul/YulInterpreterTest.cpp b/test/libyul/YulInterpreterTest.cpp index fa84c0869..78e815785 100644 --- a/test/libyul/YulInterpreterTest.cpp +++ b/test/libyul/YulInterpreterTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libyul/YulInterpreterTest.h b/test/libyul/YulInterpreterTest.h index ee60abe17..88e535fb0 100644 --- a/test/libyul/YulInterpreterTest.h +++ b/test/libyul/YulInterpreterTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 95d7bee64..436c46a65 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/libyul/YulOptimizerTest.h b/test/libyul/YulOptimizerTest.h index 3d351c3a2..5bba65682 100644 --- a/test/libyul/YulOptimizerTest.h +++ b/test/libyul/YulOptimizerTest.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/test/tools/IsolTestOptions.cpp b/test/tools/IsolTestOptions.cpp index 28552a86a..84e2babe9 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file IsolTestOptions.cpp * @date 2019 */ diff --git a/test/tools/IsolTestOptions.h b/test/tools/IsolTestOptions.h index 93d365191..118ac95d3 100644 --- a/test/tools/IsolTestOptions.h +++ b/test/tools/IsolTestOptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** @file IsolTestOptions.h */ diff --git a/test/tools/afl_fuzzer.cpp b/test/tools/afl_fuzzer.cpp index 81c3a2bfc..ea4a5a828 100644 --- a/test/tools/afl_fuzzer.cpp +++ b/test/tools/afl_fuzzer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Executable for use with AFL . */ diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index ac2e13775..437ab5d22 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/fuzzer_common.h b/test/tools/fuzzer_common.h index 801c8c1c1..c8749d9b1 100644 --- a/test/tools/fuzzer_common.h +++ b/test/tools/fuzzer_common.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 07802edf1..3bdb16b0f 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/abiV2Proto.proto b/test/tools/ossfuzz/abiV2Proto.proto index b581c9904..b6640bbe9 100644 --- a/test/tools/ossfuzz/abiV2Proto.proto +++ b/test/tools/ossfuzz/abiV2Proto.proto @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 syntax = "proto2"; diff --git a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp index 89d5a3566..8c529630f 100644 --- a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp +++ b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/const_opt_ossfuzz.cpp b/test/tools/ossfuzz/const_opt_ossfuzz.cpp index 13ceb8408..60b1febbc 100644 --- a/test/tools/ossfuzz/const_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/const_opt_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/ossfuzz/protoToSol.cpp b/test/tools/ossfuzz/protoToSol.cpp index aefbb41b9..73ed34b0d 100644 --- a/test/tools/ossfuzz/protoToSol.cpp +++ b/test/tools/ossfuzz/protoToSol.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/ossfuzz/protoToSol.h b/test/tools/ossfuzz/protoToSol.h index de2220752..39f830528 100644 --- a/test/tools/ossfuzz/protoToSol.h +++ b/test/tools/ossfuzz/protoToSol.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 5d19d470c..1d78dc802 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/protoToYul.h b/test/tools/ossfuzz/protoToYul.h index 950dd97a9..9b8de1480 100644 --- a/test/tools/ossfuzz/protoToYul.h +++ b/test/tools/ossfuzz/protoToYul.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/solProto.proto b/test/tools/ossfuzz/solProto.proto index 86e938c7c..59d989cf9 100644 --- a/test/tools/ossfuzz/solProto.proto +++ b/test/tools/ossfuzz/solProto.proto @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 syntax = "proto2"; diff --git a/test/tools/ossfuzz/solProtoFuzzer.cpp b/test/tools/ossfuzz/solProtoFuzzer.cpp index 663a94d36..e9e77dcc4 100644 --- a/test/tools/ossfuzz/solProtoFuzzer.cpp +++ b/test/tools/ossfuzz/solProtoFuzzer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp b/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp index efed3769f..e2f3a294f 100644 --- a/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp +++ b/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/ossfuzz/solc_opt_ossfuzz.cpp b/test/tools/ossfuzz/solc_opt_ossfuzz.cpp index fc431ffe5..bff19407f 100644 --- a/test/tools/ossfuzz/solc_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/solc_opt_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp index b9373a301..458bde745 100644 --- a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp index b4211dfc9..bd6d249b3 100644 --- a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp index a8378f72e..646e6ea6a 100644 --- a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/yulFuzzerCommon.cpp b/test/tools/ossfuzz/yulFuzzerCommon.cpp index 3682eef48..86cea8327 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.cpp +++ b/test/tools/ossfuzz/yulFuzzerCommon.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include using namespace std; diff --git a/test/tools/ossfuzz/yulFuzzerCommon.h b/test/tools/ossfuzz/yulFuzzerCommon.h index 08e17e381..cc20d6163 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.h +++ b/test/tools/ossfuzz/yulFuzzerCommon.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/tools/ossfuzz/yulProto.proto b/test/tools/ossfuzz/yulProto.proto index 3180b421a..d87d067f2 100644 --- a/test/tools/ossfuzz/yulProto.proto +++ b/test/tools/ossfuzz/yulProto.proto @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 syntax = "proto2"; diff --git a/test/tools/ossfuzz/yulProtoFuzzer.cpp b/test/tools/ossfuzz/yulProtoFuzzer.cpp index cc0205d16..1095994bf 100644 --- a/test/tools/ossfuzz/yulProtoFuzzer.cpp +++ b/test/tools/ossfuzz/yulProtoFuzzer.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index e5e6b203f..4c8ddb94f 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index 956db124f..cda99f1de 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter module that evaluates EVM instructions. */ diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.h b/test/tools/yulInterpreter/EVMInstructionInterpreter.h index 02104178b..05d27df96 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.h +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter module that evaluates EVM instructions. */ diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index 0f6524df6..61c7b4817 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter module that evaluates Ewasm builtins. */ diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h index 62b6bc024..78cf9216e 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter module that evaluates Ewasm builtins. */ diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index cd4fa5d69..ba946e732 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter. */ diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index 3c9619d21..a52c098ed 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter. */ diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index 9f5d56085..e4605d10f 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Interactive yul optimizer */ diff --git a/test/tools/yulrun.cpp b/test/tools/yulrun.cpp index 494115540..e682e98ba 100644 --- a/test/tools/yulrun.cpp +++ b/test/tools/yulrun.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Yul interpreter. */ diff --git a/test/yulPhaser/AlgorithmRunner.cpp b/test/yulPhaser/AlgorithmRunner.cpp index 0cd731aef..cb8f7633e 100644 --- a/test/yulPhaser/AlgorithmRunner.cpp +++ b/test/yulPhaser/AlgorithmRunner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/Chromosome.cpp b/test/yulPhaser/Chromosome.cpp index 94b95d82c..ecf754e8e 100644 --- a/test/yulPhaser/Chromosome.cpp +++ b/test/yulPhaser/Chromosome.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/Common.cpp b/test/yulPhaser/Common.cpp index b24143a94..417b9ce3c 100644 --- a/test/yulPhaser/Common.cpp +++ b/test/yulPhaser/Common.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/FitnessMetrics.cpp b/test/yulPhaser/FitnessMetrics.cpp index 73a92fb40..7c1ae2d96 100644 --- a/test/yulPhaser/FitnessMetrics.cpp +++ b/test/yulPhaser/FitnessMetrics.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/GeneticAlgorithms.cpp b/test/yulPhaser/GeneticAlgorithms.cpp index 473a6c009..cfac86db0 100644 --- a/test/yulPhaser/GeneticAlgorithms.cpp +++ b/test/yulPhaser/GeneticAlgorithms.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/Mutations.cpp b/test/yulPhaser/Mutations.cpp index 2d6b65c88..dfdd600a3 100644 --- a/test/yulPhaser/Mutations.cpp +++ b/test/yulPhaser/Mutations.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/PairSelections.cpp b/test/yulPhaser/PairSelections.cpp index a63704cf5..f3d13a5b3 100644 --- a/test/yulPhaser/PairSelections.cpp +++ b/test/yulPhaser/PairSelections.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/Phaser.cpp b/test/yulPhaser/Phaser.cpp index f1e0fd96a..673c43824 100644 --- a/test/yulPhaser/Phaser.cpp +++ b/test/yulPhaser/Phaser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/Population.cpp b/test/yulPhaser/Population.cpp index fb6d45940..955ccc49b 100644 --- a/test/yulPhaser/Population.cpp +++ b/test/yulPhaser/Population.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/Program.cpp b/test/yulPhaser/Program.cpp index d951c4e4e..b7dd1f8ed 100644 --- a/test/yulPhaser/Program.cpp +++ b/test/yulPhaser/Program.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/ProgramCache.cpp b/test/yulPhaser/ProgramCache.cpp index da4b7c18c..7fb74fca9 100644 --- a/test/yulPhaser/ProgramCache.cpp +++ b/test/yulPhaser/ProgramCache.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/test/yulPhaser/Selections.cpp b/test/yulPhaser/Selections.cpp index 7fdea6192..e5ef00327 100644 --- a/test/yulPhaser/Selections.cpp +++ b/test/yulPhaser/Selections.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/SimulationRNG.cpp b/test/yulPhaser/SimulationRNG.cpp index 306074b3c..36a04612e 100644 --- a/test/yulPhaser/SimulationRNG.cpp +++ b/test/yulPhaser/SimulationRNG.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/TestHelpers.cpp b/test/yulPhaser/TestHelpers.cpp index 2f4b40b02..348973a48 100644 --- a/test/yulPhaser/TestHelpers.cpp +++ b/test/yulPhaser/TestHelpers.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/test/yulPhaser/TestHelpers.h b/test/yulPhaser/TestHelpers.h index 514d2eda7..732e4ec7a 100644 --- a/test/yulPhaser/TestHelpers.h +++ b/test/yulPhaser/TestHelpers.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Miscellaneous utilities for use in yul-phaser's test cases. * diff --git a/test/yulPhaser/TestHelpersTest.cpp b/test/yulPhaser/TestHelpersTest.cpp index 09b722517..b90d65f5e 100644 --- a/test/yulPhaser/TestHelpersTest.cpp +++ b/test/yulPhaser/TestHelpersTest.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/solidityUpgrade/SourceTransform.h b/tools/solidityUpgrade/SourceTransform.h index a33a1d97e..571811983 100644 --- a/tools/solidityUpgrade/SourceTransform.h +++ b/tools/solidityUpgrade/SourceTransform.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/solidityUpgrade/SourceUpgrade.cpp b/tools/solidityUpgrade/SourceUpgrade.cpp index 7005fd336..5379f4b70 100644 --- a/tools/solidityUpgrade/SourceUpgrade.cpp +++ b/tools/solidityUpgrade/SourceUpgrade.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/tools/solidityUpgrade/SourceUpgrade.h b/tools/solidityUpgrade/SourceUpgrade.h index 9ace60e57..e5ad378b3 100644 --- a/tools/solidityUpgrade/SourceUpgrade.h +++ b/tools/solidityUpgrade/SourceUpgrade.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/tools/solidityUpgrade/Upgrade050.cpp b/tools/solidityUpgrade/Upgrade050.cpp index 18a495080..8e1a2f027 100644 --- a/tools/solidityUpgrade/Upgrade050.cpp +++ b/tools/solidityUpgrade/Upgrade050.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/tools/solidityUpgrade/Upgrade050.h b/tools/solidityUpgrade/Upgrade050.h index 58670e7b2..a678b04e5 100644 --- a/tools/solidityUpgrade/Upgrade050.h +++ b/tools/solidityUpgrade/Upgrade050.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/tools/solidityUpgrade/Upgrade060.cpp b/tools/solidityUpgrade/Upgrade060.cpp index 30214ddfc..58aa94d15 100644 --- a/tools/solidityUpgrade/Upgrade060.cpp +++ b/tools/solidityUpgrade/Upgrade060.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/tools/solidityUpgrade/Upgrade060.h b/tools/solidityUpgrade/Upgrade060.h index e2386d104..9a8880b96 100644 --- a/tools/solidityUpgrade/Upgrade060.h +++ b/tools/solidityUpgrade/Upgrade060.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/tools/solidityUpgrade/UpgradeChange.cpp b/tools/solidityUpgrade/UpgradeChange.cpp index a897a4e13..a4036f775 100644 --- a/tools/solidityUpgrade/UpgradeChange.cpp +++ b/tools/solidityUpgrade/UpgradeChange.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/tools/solidityUpgrade/UpgradeSuite.h b/tools/solidityUpgrade/UpgradeSuite.h index b9b094e70..33aeb40eb 100644 --- a/tools/solidityUpgrade/UpgradeSuite.h +++ b/tools/solidityUpgrade/UpgradeSuite.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once #include diff --git a/tools/solidityUpgrade/main.cpp b/tools/solidityUpgrade/main.cpp index 0f2b7a473..d13639b9a 100644 --- a/tools/solidityUpgrade/main.cpp +++ b/tools/solidityUpgrade/main.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/tools/yulPhaser/AlgorithmRunner.cpp b/tools/yulPhaser/AlgorithmRunner.cpp index 402735e0d..d5ad75575 100644 --- a/tools/yulPhaser/AlgorithmRunner.cpp +++ b/tools/yulPhaser/AlgorithmRunner.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/AlgorithmRunner.h b/tools/yulPhaser/AlgorithmRunner.h index 4326ce227..71f71bb3d 100644 --- a/tools/yulPhaser/AlgorithmRunner.h +++ b/tools/yulPhaser/AlgorithmRunner.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Contains the implementation of a class that manages the execution of a genetic algorithm. */ diff --git a/tools/yulPhaser/Chromosome.cpp b/tools/yulPhaser/Chromosome.cpp index 832c2cf80..453c62d39 100644 --- a/tools/yulPhaser/Chromosome.cpp +++ b/tools/yulPhaser/Chromosome.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Chromosome.h b/tools/yulPhaser/Chromosome.h index 7d8f1b912..95f3ae58e 100644 --- a/tools/yulPhaser/Chromosome.h +++ b/tools/yulPhaser/Chromosome.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/yulPhaser/Common.cpp b/tools/yulPhaser/Common.cpp index aa7ba85b5..a23210172 100644 --- a/tools/yulPhaser/Common.cpp +++ b/tools/yulPhaser/Common.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Common.h b/tools/yulPhaser/Common.h index c37afa2fb..b2164cc9e 100644 --- a/tools/yulPhaser/Common.h +++ b/tools/yulPhaser/Common.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Miscellaneous utilities for use in yul-phaser. */ diff --git a/tools/yulPhaser/Exceptions.h b/tools/yulPhaser/Exceptions.h index 6807d7180..e4aa19b52 100644 --- a/tools/yulPhaser/Exceptions.h +++ b/tools/yulPhaser/Exceptions.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/yulPhaser/FitnessMetrics.cpp b/tools/yulPhaser/FitnessMetrics.cpp index 134c13dfc..66c79fda2 100644 --- a/tools/yulPhaser/FitnessMetrics.cpp +++ b/tools/yulPhaser/FitnessMetrics.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/FitnessMetrics.h b/tools/yulPhaser/FitnessMetrics.h index 50f4c896f..f881df7a5 100644 --- a/tools/yulPhaser/FitnessMetrics.h +++ b/tools/yulPhaser/FitnessMetrics.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Contains an abstract base class representing a fitness metric and its concrete implementations. */ diff --git a/tools/yulPhaser/GeneticAlgorithms.cpp b/tools/yulPhaser/GeneticAlgorithms.cpp index 4a90503aa..907703738 100644 --- a/tools/yulPhaser/GeneticAlgorithms.cpp +++ b/tools/yulPhaser/GeneticAlgorithms.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include diff --git a/tools/yulPhaser/GeneticAlgorithms.h b/tools/yulPhaser/GeneticAlgorithms.h index f6c809a8b..58dc83b95 100644 --- a/tools/yulPhaser/GeneticAlgorithms.h +++ b/tools/yulPhaser/GeneticAlgorithms.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Contains an abstract base class representing a genetic algorithm and its concrete implementations. */ diff --git a/tools/yulPhaser/Mutations.cpp b/tools/yulPhaser/Mutations.cpp index f2876e395..f9d51744e 100644 --- a/tools/yulPhaser/Mutations.cpp +++ b/tools/yulPhaser/Mutations.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Mutations.h b/tools/yulPhaser/Mutations.h index 04e7050af..abdc4b10c 100644 --- a/tools/yulPhaser/Mutations.h +++ b/tools/yulPhaser/Mutations.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Mutation and crossover operators for use in genetic algorithms. */ diff --git a/tools/yulPhaser/PairSelections.cpp b/tools/yulPhaser/PairSelections.cpp index 8934c3e17..cce99cef5 100644 --- a/tools/yulPhaser/PairSelections.cpp +++ b/tools/yulPhaser/PairSelections.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/PairSelections.h b/tools/yulPhaser/PairSelections.h index a80fff897..2a4144bcb 100644 --- a/tools/yulPhaser/PairSelections.h +++ b/tools/yulPhaser/PairSelections.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Contains an abstract base class representing a selection of pairs of elements from a collection * and its concrete implementations. diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index 731560fe6..589ff93a8 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Phaser.h b/tools/yulPhaser/Phaser.h index 8ba5fc938..20a47a3a5 100644 --- a/tools/yulPhaser/Phaser.h +++ b/tools/yulPhaser/Phaser.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Contains the main class that controls yul-phaser based on command-line parameters and * associated factories for building instances of phaser's components. diff --git a/tools/yulPhaser/Population.cpp b/tools/yulPhaser/Population.cpp index 1b846122e..c4b506369 100644 --- a/tools/yulPhaser/Population.cpp +++ b/tools/yulPhaser/Population.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Population.h b/tools/yulPhaser/Population.h index c405f702c..b8cde75cc 100644 --- a/tools/yulPhaser/Population.h +++ b/tools/yulPhaser/Population.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index 2fd29f51a..a1d79f75a 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Program.h b/tools/yulPhaser/Program.h index b96843ee4..12026805b 100644 --- a/tools/yulPhaser/Program.h +++ b/tools/yulPhaser/Program.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/yulPhaser/ProgramCache.cpp b/tools/yulPhaser/ProgramCache.cpp index b174ad07f..351532aa7 100644 --- a/tools/yulPhaser/ProgramCache.cpp +++ b/tools/yulPhaser/ProgramCache.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/ProgramCache.h b/tools/yulPhaser/ProgramCache.h index 25c796a3d..d0e51a37e 100644 --- a/tools/yulPhaser/ProgramCache.h +++ b/tools/yulPhaser/ProgramCache.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/yulPhaser/Selections.cpp b/tools/yulPhaser/Selections.cpp index 920a7d7f1..e34c80eaf 100644 --- a/tools/yulPhaser/Selections.cpp +++ b/tools/yulPhaser/Selections.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/Selections.h b/tools/yulPhaser/Selections.h index a0ed2657f..a643b9a22 100644 --- a/tools/yulPhaser/Selections.h +++ b/tools/yulPhaser/Selections.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 /** * Contains an abstract base class representing a selection of elements from a collection * and its concrete implementations. diff --git a/tools/yulPhaser/SimulationRNG.cpp b/tools/yulPhaser/SimulationRNG.cpp index 26f438909..7a73f81ad 100644 --- a/tools/yulPhaser/SimulationRNG.cpp +++ b/tools/yulPhaser/SimulationRNG.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include diff --git a/tools/yulPhaser/SimulationRNG.h b/tools/yulPhaser/SimulationRNG.h index d16189f9e..7e5cc1442 100644 --- a/tools/yulPhaser/SimulationRNG.h +++ b/tools/yulPhaser/SimulationRNG.h @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #pragma once diff --git a/tools/yulPhaser/main.cpp b/tools/yulPhaser/main.cpp index d0c00fcda..1ec936dd4 100644 --- a/tools/yulPhaser/main.cpp +++ b/tools/yulPhaser/main.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with solidity. If not, see . */ +// SPDX-License-Identifier: GPL-3.0 #include #include From deffb7ffc8ea251184c091d3e4279a8820ecea07 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Mon, 13 Jul 2020 14:23:43 +0200 Subject: [PATCH 53/71] Yul interpreter: Return addresses of type u160 for create and create2 calls --- test/libyul/yulInterpreterTests/and_create.yul | 13 +++++++++++++ test/libyul/yulInterpreterTests/and_create2.yul | 15 +++++++++++++++ .../yulInterpreter/EVMInstructionInterpreter.cpp | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/libyul/yulInterpreterTests/and_create.yul create mode 100644 test/libyul/yulInterpreterTests/and_create2.yul diff --git a/test/libyul/yulInterpreterTests/and_create.yul b/test/libyul/yulInterpreterTests/and_create.yul new file mode 100644 index 000000000..890708150 --- /dev/null +++ b/test/libyul/yulInterpreterTests/and_create.yul @@ -0,0 +1,13 @@ +{ + let u160max := 0xffffffffffffffffffffffffffffffffffffffff + let a := create(0, u160max, 0) + let b := and(u160max, create(0, u160max, 0)) + mstore(0, eq(a, b)) +} +// ---- +// Trace: +// CREATE(0, 0xffffffffffffffffffffffffffffffffffffffff, 0) +// CREATE(0, 0xffffffffffffffffffffffffffffffffffffffff, 0) +// Memory dump: +// 0: 0000000000000000000000000000000000000000000000000000000000000001 +// Storage dump: diff --git a/test/libyul/yulInterpreterTests/and_create2.yul b/test/libyul/yulInterpreterTests/and_create2.yul new file mode 100644 index 000000000..46df2a9ca --- /dev/null +++ b/test/libyul/yulInterpreterTests/and_create2.yul @@ -0,0 +1,15 @@ +{ + let u160max := 0xffffffffffffffffffffffffffffffffffffffff + let a := create2(0, u160max, 0, 0) + let b := and(u160max, create2(0, u160max, 0, 0)) + mstore(0, eq(a, b)) +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Trace: +// CREATE2(0, 0xffffffffffffffffffffffffffffffffffffffff, 0, 0) +// CREATE2(0, 0xffffffffffffffffffffffffffffffffffffffff, 0, 0) +// Memory dump: +// 0: 0000000000000000000000000000000000000000000000000000000000000001 +// Storage dump: diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index 956db124f..b3cf78bab 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -303,11 +303,11 @@ u256 EVMInstructionInterpreter::eval( case Instruction::CREATE: accessMemory(arg[1], arg[2]); logTrace(_instruction, arg); - return 0xcccccc + arg[1]; + return u160(0xcccccc + arg[1]); case Instruction::CREATE2: accessMemory(arg[2], arg[3]); logTrace(_instruction, arg); - return 0xdddddd + arg[1]; + return u160(0xdddddd + arg[1]); case Instruction::CALL: case Instruction::CALLCODE: // TODO assign returndata From 53bc0ff18e8daa82a3bfb096b48cb019e3fb5aa5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 14:52:10 +0200 Subject: [PATCH 54/71] Fix "enforce via yul". --- test/libsolidity/SemanticTest.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index e3b40f1e4..180e49bd7 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -46,7 +46,7 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer m_lineOffset(m_reader.lineNumber()), m_enforceViaYul(enforceViaYul) { - string choice = m_reader.stringSetting("compileViaYul", "false"); + string choice = m_reader.stringSetting("compileViaYul", "default"); if (choice == "also") { m_runWithYul = true; @@ -64,6 +64,11 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer // Do not try to run via yul if explicitly denied. m_enforceViaYul = false; } + else if (choice == "default") + { + m_runWithYul = false; + m_runWithoutYul = true; + } else BOOST_THROW_EXCEPTION(runtime_error("Invalid compileViaYul value: " + choice + ".")); From 0a25370eebf603531f92ee15e5156fbdf7c941f3 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 15:06:45 +0200 Subject: [PATCH 55/71] Update tests. --- test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol | 2 ++ .../semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol | 2 ++ test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol | 2 ++ .../abiEncoderV2/calldata_struct_member_offset.sol | 2 ++ .../semanticTests/array/calldata_array_of_struct.sol | 2 ++ .../semanticTests/array/fixed_arrays_in_storage.sol | 2 ++ .../semanticTests/calldata/calldata_bytes_external.sol | 1 + .../semanticTests/calldata/calldata_struct_cleaning.sol | 2 ++ .../semanticTests/calldata/calldata_struct_internal.sol | 2 ++ test/libsolidity/semanticTests/dirty_calldata_bytes.sol | 4 +++- .../semanticTests/dirty_calldata_dynamic_array.sol | 4 +++- .../semanticTests/functionCall/call_options_overload.sol | 2 ++ .../libraries/internal_library_function_bound.sol | 2 ++ .../libraries/internal_library_function_return_var_size.sol | 2 ++ test/libsolidity/semanticTests/multiSource/import.sol | 2 ++ test/libsolidity/semanticTests/smoke/structs.sol | 2 ++ .../semanticTests/storage/packed_storage_structs_bytes.sol | 2 ++ .../semanticTests/storage/packed_storage_structs_enum.sol | 2 ++ .../semanticTests/storage/packed_storage_structs_uint.sol | 2 ++ test/libsolidity/semanticTests/strings/unicode_escapes.sol | 2 ++ test/libsolidity/semanticTests/strings/unicode_string.sol | 2 ++ .../semanticTests/structs/calldata/calldata_struct.sol | 2 ++ .../structs/calldata/calldata_struct_and_ints.sol | 2 ++ .../semanticTests/structs/calldata/calldata_structs.sol | 2 ++ .../semanticTests/structs/calldata/dynamic_nested.sol | 2 ++ .../semanticTests/structs/calldata/dynamically_encoded.sol | 2 ++ .../semanticTests/various/cross_contract_types.sol | 2 ++ test/libsolidity/semanticTests/various/memory_overwrite.sol | 2 ++ .../semanticTests/various/negative_stack_height.sol | 3 ++- 29 files changed, 59 insertions(+), 3 deletions(-) diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol index 1dbf320bd..6d7b27f58 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol @@ -18,5 +18,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol index a5e7a9af8..9ed9ada78 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol @@ -12,5 +12,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f(bytes): 0x20, 0xe0, 0x20, 0x21, 0x40, 0x3, 0xa, 0xb, 0xc -> 0x20, 0x21, 0x40, 0x3, 0xa, 0xb, 0xc diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol index f6510b53d..bfa750712 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol @@ -45,6 +45,8 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f0() -> 0x20, 0x0 // f1() -> 0x20, 0x40, 0x1, 0x2 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol index fb8e6c3c5..196967a44 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol @@ -19,5 +19,7 @@ contract C { return (b.b, this.g(b)); } } +// ==== +// compileViaYul: also // ---- // f() -> 11, 11 diff --git a/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol b/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol index 333112265..170dee6ee 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol @@ -20,5 +20,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f((uint256,uint256)[]): 0x20, 0x2, 0x1, 0x2, 0x3, 0x4 -> 2, 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol index b65a3d254..3f5c0d5dd 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol @@ -33,6 +33,8 @@ contract c { l2 = ids.length; } } +// ==== +// compileViaYul: also // ---- // setIDStatic(uint256): 0xb -> // getID(uint256): 0x2 -> 0xb diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol index 9917e736a..9be9e8eab 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol @@ -7,6 +7,7 @@ contract CalldataTest { } } // ==== +// compileViaYul: also // EVMVersion: >=byzantium // ---- // tester(bytes): 0x20, 0x08, "abcdefgh" -> "c" diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol b/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol index dbf6e4440..6b4eb2f07 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol @@ -16,6 +16,8 @@ contract C { } } } +// ==== +// compileViaYul: also // ---- // f((uint8,bytes1)): 0x12, hex"3400000000000000000000000000000000000000000000000000000000000000" -> 0x12, hex"3400000000000000000000000000000000000000000000000000000000000000" # double check that the valid case goes through # // f((uint8,bytes1)): 0x1234, hex"5678000000000000000000000000000000000000000000000000000000000000" -> FAILURE diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol b/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol index a463b5d33..810900dd6 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol @@ -13,5 +13,7 @@ contract C { return f(s); } } +// ==== +// compileViaYul: also // ---- // f(uint256,(uint256,uint256),uint256): 7, 1, 2, 4 -> 1, 2 diff --git a/test/libsolidity/semanticTests/dirty_calldata_bytes.sol b/test/libsolidity/semanticTests/dirty_calldata_bytes.sol index 05a3793f6..f3cd7b912 100644 --- a/test/libsolidity/semanticTests/dirty_calldata_bytes.sol +++ b/test/libsolidity/semanticTests/dirty_calldata_bytes.sol @@ -8,5 +8,7 @@ contract C { correct = r == (0x64 << 248); } } +// ==== +// compileViaYul: also // ---- -// f(bytes): 0x20, 0x04, "dead" -> true \ No newline at end of file +// f(bytes): 0x20, 0x04, "dead" -> true diff --git a/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol b/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol index 1c9d7db30..df5c672d1 100644 --- a/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol +++ b/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol @@ -8,5 +8,7 @@ contract C { correct = r == 0x7fff; } } +// ==== +// compileViaYul: also // ---- -// f(int16[]): 0x20, 0x02, 0x7fff, 0x7fff -> true \ No newline at end of file +// f(int16[]): 0x20, 0x02, 0x7fff, 0x7fff -> true diff --git a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol index 27e8e4127..8938d8f0c 100644 --- a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol +++ b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol @@ -9,6 +9,8 @@ contract C { } receive() external payable {} } +// ==== +// compileViaYul: also // ---- // (), 1 ether // call() -> 1, 2, 2, 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol index f59ec9440..a6ea94fed 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol @@ -22,5 +22,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol index 21417b599..1406e0117 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol @@ -22,5 +22,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/multiSource/import.sol b/test/libsolidity/semanticTests/multiSource/import.sol index 2a0f43d53..d3f5ed301 100644 --- a/test/libsolidity/semanticTests/multiSource/import.sol +++ b/test/libsolidity/semanticTests/multiSource/import.sol @@ -7,6 +7,8 @@ import "A"; contract B is A { function f(uint256 x) public view returns(uint256) { return x; } } +// ==== +// compileViaYul: also // ---- // f(uint256): 1337 -> 1337 // g(uint256): 1337 -> 1338 diff --git a/test/libsolidity/semanticTests/smoke/structs.sol b/test/libsolidity/semanticTests/smoke/structs.sol index 979dbdcc0..6a7286e57 100644 --- a/test/libsolidity/semanticTests/smoke/structs.sol +++ b/test/libsolidity/semanticTests/smoke/structs.sol @@ -17,6 +17,8 @@ contract C { return T(23, 42, "any"); } } +// ==== +// compileViaYul: also // ---- // s() -> 23, 42 // t() -> 0x20, 23, 42, 0x60, 3, "any" diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol index daeee6ba6..50a0d68f7 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol @@ -41,5 +41,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> true diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol index 9c9f778f0..3f2983f46 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol @@ -29,5 +29,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol index 8c91576f5..611fda3cc 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol @@ -26,5 +26,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/strings/unicode_escapes.sol b/test/libsolidity/semanticTests/strings/unicode_escapes.sol index 401d8b61e..fc57aa48e 100644 --- a/test/libsolidity/semanticTests/strings/unicode_escapes.sol +++ b/test/libsolidity/semanticTests/strings/unicode_escapes.sol @@ -15,6 +15,8 @@ contract C { return "\u0024\u00A2\u20AC"; } } +// ==== +// compileViaYul: also // ---- // oneByteUTF8() -> 0x20, 7, "aaa$aaa" // twoBytesUTF8() -> 0x20, 8, "aaa\xc2\xa2aaa" diff --git a/test/libsolidity/semanticTests/strings/unicode_string.sol b/test/libsolidity/semanticTests/strings/unicode_string.sol index c139d6b8b..73616e479 100644 --- a/test/libsolidity/semanticTests/strings/unicode_string.sol +++ b/test/libsolidity/semanticTests/strings/unicode_string.sol @@ -3,5 +3,7 @@ contract C { return "😃, 😭, and 😈"; } } +// ==== +// compileViaYul: also // ---- // f() -> 0x20, 0x14, "\xf0\x9f\x98\x83, \xf0\x9f\x98\xad, and \xf0\x9f\x98\x88" diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol index a7ecf2bd0..d3a79a181 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol @@ -13,5 +13,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f((uint256,uint256)): 42, 23 -> 42, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol index c3b8249e8..21fada9c2 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol @@ -16,5 +16,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f(uint256,(uint256,uint256),uint256): 1, 2, 3, 4 -> 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol index 4139c1073..0e62ee4ef 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol @@ -23,5 +23,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f((uint256,uint256),(uint256),(uint256,uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5 diff --git a/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol b/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol index 59cde3171..8d6b73103 100644 --- a/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol +++ b/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol @@ -7,5 +7,7 @@ contract C { return (s.children.length, s.a, s.children[0].b, s.children[1].b); } } +// ==== +// compileViaYul: also // ---- // f((uint256,(uint256)[])): 32, 17, 64, 2, 23, 42 -> 2, 17, 23, 42 diff --git a/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol b/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol index 3acea52e7..815de9a28 100644 --- a/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol +++ b/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol @@ -6,5 +6,7 @@ contract C { return (s.a.length, s.a[0], s.a[1]); } } +// ==== +// compileViaYul: also // ---- // f((uint256[])): 32, 32, 2, 42, 23 -> 2, 42, 23 diff --git a/test/libsolidity/semanticTests/various/cross_contract_types.sol b/test/libsolidity/semanticTests/various/cross_contract_types.sol index 47842cc03..88528ce07 100644 --- a/test/libsolidity/semanticTests/various/cross_contract_types.sol +++ b/test/libsolidity/semanticTests/various/cross_contract_types.sol @@ -13,5 +13,7 @@ contract Test { } } +// ==== +// compileViaYul: also // ---- // f() -> 3 diff --git a/test/libsolidity/semanticTests/various/memory_overwrite.sol b/test/libsolidity/semanticTests/various/memory_overwrite.sol index 7312509e2..3ab0a2aa2 100644 --- a/test/libsolidity/semanticTests/various/memory_overwrite.sol +++ b/test/libsolidity/semanticTests/various/memory_overwrite.sol @@ -6,5 +6,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 0x20, 5, "b23a5" diff --git a/test/libsolidity/semanticTests/various/negative_stack_height.sol b/test/libsolidity/semanticTests/various/negative_stack_height.sol index d5074dc91..8f36538e4 100644 --- a/test/libsolidity/semanticTests/various/negative_stack_height.sol +++ b/test/libsolidity/semanticTests/various/negative_stack_height.sol @@ -58,6 +58,7 @@ contract C { ) {} } - +// ==== +// compileViaYul: false // ---- // constructor() -> From f5d8636d281577c44da3c0a3f4fb2f15415ef500 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 15:43:52 +0200 Subject: [PATCH 56/71] Document variableHeightDiff. --- libyul/backends/evm/EVMCodeTransform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index 1cfa6afd7..b194676ee 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -201,6 +201,8 @@ private: /// Determines the stack height difference to the given variables. Throws /// if it is not yet in scope or the height difference is too large. Returns /// the (positive) stack height difference otherwise. + /// @param _forSwap if true, produces stack error if the difference is invalid for a swap + /// opcode, otherwise checks for validity for a dup opcode. size_t variableHeightDiff(Scope::Variable const& _var, YulString _name, bool _forSwap); void expectDeposit(int _deposit, int _oldHeight) const; From 50a54fa8aaf9c0e06ef7bbde0ae93717583ac339 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 14:37:19 +0200 Subject: [PATCH 57/71] Implement inline arrays. --- libsolidity/codegen/YulUtilFunctions.cpp | 29 +++++++++++++++---- libsolidity/codegen/YulUtilFunctions.h | 6 ++++ .../codegen/ir/IRGeneratorForStatements.cpp | 26 ++++++++++++++++- .../array/inline_array_singleton.sol | 3 +- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index cab908c18..0bd6b0d3a 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -1620,26 +1620,45 @@ string YulUtilFunctions::zeroComplexMemoryArrayFunction(ArrayType const& _type) }); } +string YulUtilFunctions::allocateMemoryArrayFunction(ArrayType const& _type) +{ + string functionName = "allocate_memory_array_" + _type.identifier(); + return m_functionCollector.createFunction(functionName, [&]() { + return Whiskers(R"( + function (length) -> memPtr { + let allocSize := (length) + memPtr := (allocSize) + + mstore(memPtr, length) + + } + )") + ("functionName", functionName) + ("alloc", allocationFunction()) + ("allocSize", arrayAllocationSizeFunction(_type)) + ("dynamic", _type.isDynamicallySized()) + .render(); + }); +} + string YulUtilFunctions::allocateAndInitializeMemoryArrayFunction(ArrayType const& _type) { string functionName = "allocate_and_zero_memory_array_" + _type.identifier(); return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( function (length) -> memPtr { - let allocSize := (length) - memPtr := (allocSize) + memPtr := (length) let dataStart := memPtr - let dataSize := allocSize + let dataSize := (length) dataStart := add(dataStart, 32) dataSize := sub(dataSize, 32) - mstore(memPtr, length) (dataStart, dataSize) } )") ("functionName", functionName) - ("alloc", allocationFunction()) + ("allocArray", allocateMemoryArrayFunction(_type)) ("allocSize", arrayAllocationSizeFunction(_type)) ("zeroArrayFunction", zeroMemoryArrayFunction(_type)) ("dynamic", _type.isDynamicallySized()) diff --git a/libsolidity/codegen/YulUtilFunctions.h b/libsolidity/codegen/YulUtilFunctions.h index 5d9ec805f..19ca72dd0 100644 --- a/libsolidity/codegen/YulUtilFunctions.h +++ b/libsolidity/codegen/YulUtilFunctions.h @@ -282,6 +282,12 @@ public: /// signature: (dataStart, dataSizeInBytes) -> std::string zeroComplexMemoryArrayFunction(ArrayType const& _type); + /// @returns the name of a function that allocates a memory array. + /// For dynamic arrays it adds space for length and stores it. + /// The contents of the data area are unspecified. + /// signature: (length) -> memPtr + std::string allocateMemoryArrayFunction(ArrayType const& _type); + /// @returns the name of a function that allocates and zeroes a memory array. /// For dynamic arrays it adds space for length and stores it. /// signature: (length) -> memPtr diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 51679571e..0489f3f68 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -311,7 +311,31 @@ bool IRGeneratorForStatements::visit(Assignment const& _assignment) bool IRGeneratorForStatements::visit(TupleExpression const& _tuple) { if (_tuple.isInlineArray()) - solUnimplementedAssert(false, ""); + { + auto const& arrayType = dynamic_cast(*_tuple.annotation().type); + solAssert(!arrayType.isDynamicallySized(), "Cannot create dynamically sized inline array."); + define(_tuple) << + m_utils.allocateMemoryArrayFunction(arrayType) << + "(" << + _tuple.components().size() << + ")\n"; + + string mpos = IRVariable(_tuple).part("mpos").name(); + Type const& baseType = *arrayType.baseType(); + for (size_t i = 0; i < _tuple.components().size(); i++) + { + Expression const& component = *_tuple.components()[i]; + component.accept(*this); + IRVariable converted = convert(component, baseType); + m_code << + m_utils.writeToMemoryFunction(baseType) << + "(" << + ("add(" + mpos + ", " + to_string(i * arrayType.memoryStride()) + ")") << + ", " << + converted.name() << + ")\n"; + } + } else { bool willBeWrittenTo = _tuple.annotation().willBeWrittenTo; diff --git a/test/libsolidity/semanticTests/array/inline_array_singleton.sol b/test/libsolidity/semanticTests/array/inline_array_singleton.sol index 5925aba0f..e8373854d 100644 --- a/test/libsolidity/semanticTests/array/inline_array_singleton.sol +++ b/test/libsolidity/semanticTests/array/inline_array_singleton.sol @@ -4,6 +4,7 @@ contract C { return [4][0]; } } - +// ==== +// compileViaYul: also // ---- // f() -> 4 From 8bdd93f4b8516911341eda0e0cefd0b675dadccb Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 17:17:19 +0200 Subject: [PATCH 58/71] Update tests. --- .../semanticTests/array/inline_array_index_access_ints.sol | 2 ++ .../array/inline_array_storage_to_memory_conversion_ints.sol | 2 ++ .../semanticTests/calldata/calldata_array_dynamic_bytes.sol | 2 ++ test/libsolidity/semanticTests/isoltestFormatting.sol | 2 ++ test/libsolidity/semanticTests/snark.sol | 1 + .../various/inline_tuple_with_rational_numbers.sol | 2 ++ 6 files changed, 11 insertions(+) diff --git a/test/libsolidity/semanticTests/array/inline_array_index_access_ints.sol b/test/libsolidity/semanticTests/array/inline_array_index_access_ints.sol index 8dc5a7451..fc7c85438 100644 --- a/test/libsolidity/semanticTests/array/inline_array_index_access_ints.sol +++ b/test/libsolidity/semanticTests/array/inline_array_index_access_ints.sol @@ -4,5 +4,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 3 diff --git a/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol b/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol index f3f37ea20..960b7fdb5 100644 --- a/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol +++ b/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol @@ -7,5 +7,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 3, 6 diff --git a/test/libsolidity/semanticTests/calldata/calldata_array_dynamic_bytes.sol b/test/libsolidity/semanticTests/calldata/calldata_array_dynamic_bytes.sol index c2c2fa70a..b59885de8 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_array_dynamic_bytes.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_array_dynamic_bytes.sol @@ -66,6 +66,8 @@ contract C { // found expectation comments: // same offset for both arrays @ ABI_CHECK( +// ==== +// compileViaYul: false // ---- // f1(bytes[1]): 0x20, 0x20, 0x3, hex"0102030000000000000000000000000000000000000000000000000000000000" -> 0x3, 0x1, 0x2, 0x3 // f2(bytes[1],bytes[1]): 0x40, 0xa0, 0x20, 0x3, hex"0102030000000000000000000000000000000000000000000000000000000000", 0x20, 0x2, hex"0102000000000000000000000000000000000000000000000000000000000000" -> 0x3, 0x1, 0x2, 0x3, 0x2, 0x1, 0x2 diff --git a/test/libsolidity/semanticTests/isoltestFormatting.sol b/test/libsolidity/semanticTests/isoltestFormatting.sol index 9380dc015..a6e25172e 100644 --- a/test/libsolidity/semanticTests/isoltestFormatting.sol +++ b/test/libsolidity/semanticTests/isoltestFormatting.sol @@ -8,6 +8,8 @@ contract C { return a; } } +// ==== +// compileViaYul: also // ---- // f() -> 4, 11, 0x0111, 0x333333, 2222222222222222222 // g() -> 0x10, 0x0100, 0x0101, 0x333333, 2222222222222222222 diff --git a/test/libsolidity/semanticTests/snark.sol b/test/libsolidity/semanticTests/snark.sol index 83f16f091..4ab6a61fc 100644 --- a/test/libsolidity/semanticTests/snark.sol +++ b/test/libsolidity/semanticTests/snark.sol @@ -288,6 +288,7 @@ contract Test { /// testMul() -> true // // ==== +// compileViaYul: also // EVMVersion: >=constantinople // ---- // library: Pairing diff --git a/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol b/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol index e350a11d3..477d14740 100644 --- a/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol +++ b/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol @@ -5,5 +5,7 @@ contract c { } } +// ==== +// compileViaYul: also // ---- // f() -> 1 From 2c93278719d31f248ba4833f6dc1cc7829327b27 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 17 Jul 2020 10:00:25 +0200 Subject: [PATCH 59/71] Fix push().push() --- Changelog.md | 1 + libsolidity/formal/SMTEncoder.cpp | 24 ++++++++++++++++++- .../array_members/push_push_no_args_1.sol | 9 +++++++ .../push_push_no_args_1_fail.sol | 12 ++++++++++ .../array_members/push_push_no_args_2.sol | 11 +++++++++ .../push_push_no_args_2_fail.sol | 15 ++++++++++++ .../array_members/storage_pointer_push_1.sol | 18 ++++++++++++++ .../storage_pointer_push_1_safe.sol | 15 ++++++++++++ 8 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1.sol create mode 100644 test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1_fail.sol create mode 100644 test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2.sol create mode 100644 test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2_fail.sol create mode 100644 test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1.sol create mode 100644 test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1_safe.sol diff --git a/Changelog.md b/Changelog.md index e0987a919..134bd5df8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,7 @@ Bugfixes: * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. * SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches. * SMTChecker: Fix error in events with indices of type static array. + * SMTChecker: Fix internal error in sequential storage array pushes (``push().push()`). * Type Checker: Fix overload resolution in combination with ``{value: ...}``. * Type Checker: Fix internal compiler error related to oversized types. * Code Generator: Avoid double cleanup when copying to memory. diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index e3f16b2ef..417a16921 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -1077,7 +1077,7 @@ void SMTEncoder::arrayPush(FunctionCall const& _funCall) m_context.addAssertion(symbArray->length() == oldLength + 1); if (arguments.empty()) - defineExpr(_funCall, element); + defineExpr(_funCall, smtutil::Expression::select(symbArray->elements(), oldLength)); arrayPushPopAssign(memberAccess->expression(), symbArray->currentValue()); } @@ -1119,6 +1119,28 @@ void SMTEncoder::arrayPushPopAssign(Expression const& _expr, smtutil::Expression } else if (auto const* indexAccess = dynamic_cast(&_expr)) arrayIndexAssignment(*indexAccess, _array); + else if (auto const* funCall = dynamic_cast(&_expr)) + { + FunctionType const& funType = dynamic_cast(*funCall->expression().annotation().type); + if (funType.kind() == FunctionType::Kind::ArrayPush) + { + auto memberAccess = dynamic_cast(&funCall->expression()); + solAssert(memberAccess, ""); + auto symbArray = dynamic_pointer_cast(m_context.expression(memberAccess->expression())); + solAssert(symbArray, ""); + + auto oldLength = symbArray->length(); + auto store = smtutil::Expression::store( + symbArray->elements(), + symbArray->length() - 1, + _array + ); + symbArray->increaseIndex(); + m_context.addAssertion(symbArray->elements() == store); + m_context.addAssertion(symbArray->length() == oldLength); + arrayPushPopAssign(memberAccess->expression(), symbArray->currentValue()); + } + } else if (dynamic_cast(&_expr)) m_errorReporter.warning( 9599_error, diff --git a/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1.sol b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1.sol new file mode 100644 index 000000000..8acd7998a --- /dev/null +++ b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1.sol @@ -0,0 +1,9 @@ +pragma experimental SMTChecker; +contract C { + int[][] array2d; + function l() public { + array2d.push().push(); + assert(array2d.length > 0); + assert(array2d[array2d.length - 1].length > 0); + } +} diff --git a/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1_fail.sol b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1_fail.sol new file mode 100644 index 000000000..a85638189 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_1_fail.sol @@ -0,0 +1,12 @@ +pragma experimental SMTChecker; +contract C { + int[][] array2d; + function l() public { + array2d.push().push(); + assert(array2d.length > 2); + assert(array2d[array2d.length - 1].length > 3); + } +} +// ---- +// Warning 4661: (113-139): Assertion violation happens here +// Warning 4661: (143-189): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2.sol b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2.sol new file mode 100644 index 000000000..b6fd8e8c9 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2.sol @@ -0,0 +1,11 @@ +pragma experimental SMTChecker; +contract C { + int[][][] array2d; + function l() public { + array2d.push().push().push(); + assert(array2d.length > 0); + uint last = array2d[array2d.length - 1].length; + assert(last > 0); + assert(array2d[array2d.length - 1][last - 1].length > 0); + } +} diff --git a/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2_fail.sol b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2_fail.sol new file mode 100644 index 000000000..3d22b862a --- /dev/null +++ b/test/libsolidity/smtCheckerTests/array_members/push_push_no_args_2_fail.sol @@ -0,0 +1,15 @@ +pragma experimental SMTChecker; +contract C { + int[][][] array2d; + function l() public { + array2d.push().push().push(); + assert(array2d.length > 2); + uint last = array2d[array2d.length - 1].length; + assert(last > 3); + assert(array2d[array2d.length - 1][last - 1].length > 4); + } +} +// ---- +// Warning 4661: (122-148): Assertion violation happens here +// Warning 4661: (202-218): Assertion violation happens here +// Warning 4661: (222-278): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1.sol b/test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1.sol new file mode 100644 index 000000000..527d06534 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1.sol @@ -0,0 +1,18 @@ +pragma experimental SMTChecker; +contract C { + int[][] array2d; + function l() public { + s().push(); + // False positive. + // Knowledge is erased because `s()` is a storage pointer. + assert(array2d[2].length > 0); + } + function s() internal returns (int[] storage) { + array2d.push(); + array2d.push(); + array2d.push(); + return array2d[2]; + } +} +// ---- +// Warning 4661: (184-213): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1_safe.sol b/test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1_safe.sol new file mode 100644 index 000000000..843b46b16 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/array_members/storage_pointer_push_1_safe.sol @@ -0,0 +1,15 @@ +pragma experimental SMTChecker; +contract C { + int[][] array2d; + function l() public { + s(); + array2d[2].push(); + assert(array2d[2].length > 0); + } + function s() internal returns (int[] storage) { + array2d.push(); + array2d.push(); + array2d.push(); + return array2d[2]; + } +} From ba0a4de50d11602dcde83a2648a96a7b1590e6eb Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Mon, 29 Jun 2020 14:30:09 +0200 Subject: [PATCH 60/71] NatSpec: Implement ``@inheritdoc`` --- Changelog.md | 1 + docs/natspec-format.rst | 50 +- libsolidity/CMakeLists.txt | 2 + libsolidity/analysis/DocStringAnalyser.cpp | 184 ++---- libsolidity/analysis/DocStringAnalyser.h | 32 +- libsolidity/analysis/DocStringTagParser.cpp | 227 +++++++ libsolidity/analysis/DocStringTagParser.h | 76 +++ libsolidity/analysis/ReferencesResolver.cpp | 68 ++- libsolidity/analysis/ReferencesResolver.h | 3 + libsolidity/ast/ASTAnnotations.h | 2 + libsolidity/interface/CompilerStack.cpp | 7 + libsolidity/interface/Natspec.cpp | 30 +- test/libsolidity/SolidityNatspecJSON.cpp | 566 +++++++++++++++++- .../natspec/invalid/docstring_inheritdoc.sol | 7 + .../natspec/invalid/docstring_inheritdoc2.sol | 10 + .../natspec/invalid/docstring_inheritdoc3.sol | 11 + .../docstring_inheritdoc_wrong_type.sol | 8 + .../natspec/invalid/inherit_doc_events.sol | 17 + 18 files changed, 1082 insertions(+), 219 deletions(-) create mode 100644 libsolidity/analysis/DocStringTagParser.cpp create mode 100644 libsolidity/analysis/DocStringTagParser.h create mode 100644 test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc.sol create mode 100644 test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc2.sol create mode 100644 test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc3.sol create mode 100644 test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_wrong_type.sol create mode 100644 test/libsolidity/syntaxTests/natspec/invalid/inherit_doc_events.sol diff --git a/Changelog.md b/Changelog.md index e0987a919..abfdb3a79 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ Compiler Features: * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. * Peephole Optimizer: Remove unnecessary masking of tags. * Yul EVM Code Transform: Free stack slots directly after visiting the right-hand-side of variable declarations instead of at the end of the statement only. + * NatSpec: Implement tag ``@inheritdoc`` to copy documentation from a specific contract. Bugfixes: * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index ec774014b..c566d5407 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -49,7 +49,7 @@ The following example shows a contract and a function using all available tags. .. code:: solidity // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.10 <0.7.0; /// @title A simulator for trees /// @author Larry A. Gardner @@ -60,9 +60,33 @@ The following example shows a contract and a function using all available tags. /// @dev The Alexandr N. Tetearing algorithm could increase precision /// @param rings The number of rings from dendrochronological sample /// @return age in years, rounded up for partial years - function age(uint256 rings) external pure returns (uint256) { + function age(uint256 rings) external virtual pure returns (uint256) { return rings + 1; } + + /// @notice Returns the amount of leaves the tree has. + /// @dev Returns only a fixed number. + function leaves() external virtual pure returns(uint256) { + return 2; + } + } + + contract Plant { + function leaves() external virtual pure returns(uint256) { + return 3; + } + } + + contract KumquatTree is Tree, Plant { + function age(uint256 rings) external override pure returns (uint256) { + return rings + 2; + } + + /// Return the amount of leaves that this specific kind of tree has + /// @inheritdoc Tree + function leaves() external override(Tree, Plant) pure returns(uint256) { + return 3; + } } .. _header-tags: @@ -75,16 +99,17 @@ NatSpec tag and where it may be used. As a special case, if no tags are used then the Solidity compiler will interpret a ``///`` or ``/**`` comment in the same way as if it were tagged with ``@notice``. -=========== =============================================================================== ============================= -Tag Context -=========== =============================================================================== ============================= -``@title`` A title that should describe the contract/interface contract, interface -``@author`` The name of the author contract, interface -``@notice`` Explain to an end user what this does contract, interface, function, public state variable, event -``@dev`` Explain to a developer any extra details contract, interface, function, state variable, event -``@param`` Documents a parameter just like in doxygen (must be followed by parameter name) function, event -``@return`` Documents the return variables of a contract's function function, public state variable -=========== =============================================================================== ============================= +=============== ====================================================================================== ============================= +Tag Context +=============== ====================================================================================== ============================= +``@title`` A title that should describe the contract/interface contract, interface +``@author`` The name of the author contract, interface +``@notice`` Explain to an end user what this does contract, interface, function, public state variable, event +``@dev`` Explain to a developer any extra details contract, interface, function, state variable, event +``@param`` Documents a parameter just like in doxygen (must be followed by parameter name) function, event +``@return`` Documents the return variables of a contract's function function, public state variable +``@inheritdoc`` Copies all missing tags from the base function (must be followed by the contract name) function, public state variable +=============== ====================================================================================== ============================= If your function returns multiple values, like ``(int quotient, int remainder)`` then use multiple ``@return`` statements in the same format as the @@ -127,6 +152,7 @@ base function. Exceptions to this are: * When the parameter names are different. * When there is more than one base function. + * When there is an explicit ``@inheritdoc`` tag which specifies which contract should be used to inherit. .. _header-output: diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 8e930b6ab..74f4a9a21 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -16,6 +16,8 @@ set(sources analysis/DeclarationTypeChecker.h analysis/DocStringAnalyser.cpp analysis/DocStringAnalyser.h + analysis/DocStringTagParser.cpp + analysis/DocStringTagParser.h analysis/ImmutableValidator.cpp analysis/ImmutableValidator.h analysis/GlobalContext.cpp diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index 96fde8550..94a841e00 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -53,6 +53,17 @@ void copyMissingTags(StructurallyDocumentedAnnotation& _target, set const& _baseFunctions, int64_t _contractId) +{ + for (CallableDeclaration const* baseFuncCandidate: _baseFunctions) + if (baseFuncCandidate->annotation().contract->id() == _contractId) + return baseFuncCandidate; + else if (auto callable = findBaseCallable(baseFuncCandidate->annotation().baseFunctions, _contractId)) + return callable; + + return nullptr; +} + bool parameterNamesEqual(CallableDeclaration const& _a, CallableDeclaration const& _b) { return boost::range::equal(_a.parameters(), _b.parameters(), [](auto const& pa, auto const& pb) { return pa->name() == pb->name(); }); @@ -67,50 +78,23 @@ bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit) return errorWatcher.ok(); } -bool DocStringAnalyser::visit(ContractDefinition const& _contract) -{ - static set const validTags = set{"author", "title", "dev", "notice"}; - parseDocStrings(_contract, _contract.annotation(), validTags, "contracts"); - - return true; -} - bool DocStringAnalyser::visit(FunctionDefinition const& _function) { - if (_function.isConstructor()) - handleConstructor(_function, _function, _function.annotation()); - else + if (!_function.isConstructor()) handleCallable(_function, _function, _function.annotation()); return true; } bool DocStringAnalyser::visit(VariableDeclaration const& _variable) { - if (_variable.isStateVariable()) - { - static set const validPublicTags = set{"dev", "notice", "return", "title", "author"}; - if (_variable.isPublic()) - parseDocStrings(_variable, _variable.annotation(), validPublicTags, "public state variables"); - else - { - parseDocStrings(_variable, _variable.annotation(), validPublicTags, "non-public state variables"); - if (_variable.annotation().docTags.count("notice") > 0) - m_errorReporter.warning( - 7816_error, _variable.documentation()->location(), - "Documentation tag on non-public state variables will be disallowed in 0.7.0. " - "You will need to use the @dev tag explicitly." - ); - } - if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0) - m_errorReporter.warning( - 8532_error, _variable.documentation()->location(), - "Documentation tag @title and @author is only allowed on contract definitions. " - "It will be disallowed in 0.7.0." - ); + if (!_variable.isStateVariable()) + return false; + + if (CallableDeclaration const* baseFunction = resolveInheritDoc(_variable.annotation().baseFunctions, _variable, _variable.annotation())) + copyMissingTags(_variable.annotation(), {baseFunction}); + else if (_variable.annotation().docTags.empty()) + copyMissingTags(_variable.annotation(), _variable.annotation().baseFunctions); - if (_variable.annotation().docTags.empty()) - copyMissingTags(_variable.annotation(), _variable.annotation().baseFunctions); - } return false; } @@ -128,133 +112,41 @@ bool DocStringAnalyser::visit(EventDefinition const& _event) return true; } -void DocStringAnalyser::checkParameters( - CallableDeclaration const& _callable, - StructurallyDocumented const& _node, - StructurallyDocumentedAnnotation& _annotation -) -{ - set validParams; - for (auto const& p: _callable.parameters()) - validParams.insert(p->name()); - if (_callable.returnParameterList()) - for (auto const& p: _callable.returnParameterList()->parameters()) - validParams.insert(p->name()); - auto paramRange = _annotation.docTags.equal_range("param"); - for (auto i = paramRange.first; i != paramRange.second; ++i) - if (!validParams.count(i->second.paramName)) - m_errorReporter.docstringParsingError( - 3881_error, - _node.documentation()->location(), - "Documented parameter \"" + - i->second.paramName + - "\" not found in the parameter list of the function." - ); - -} - -void DocStringAnalyser::handleConstructor( - CallableDeclaration const& _callable, - StructurallyDocumented const& _node, - StructurallyDocumentedAnnotation& _annotation -) -{ - static set const validTags = set{"author", "dev", "notice", "param"}; - parseDocStrings(_node, _annotation, validTags, "constructor"); - checkParameters(_callable, _node, _annotation); -} - void DocStringAnalyser::handleCallable( CallableDeclaration const& _callable, StructurallyDocumented const& _node, StructurallyDocumentedAnnotation& _annotation ) { - static set const validTags = set{"author", "dev", "notice", "return", "param"}; - parseDocStrings(_node, _annotation, validTags, "functions"); - checkParameters(_callable, _node, _annotation); - - if ( + if (CallableDeclaration const* baseFunction = resolveInheritDoc(_callable.annotation().baseFunctions, _node, _annotation)) + copyMissingTags(_annotation, {baseFunction}); + else if ( _annotation.docTags.empty() && _callable.annotation().baseFunctions.size() == 1 && parameterNamesEqual(_callable, **_callable.annotation().baseFunctions.begin()) ) copyMissingTags(_annotation, _callable.annotation().baseFunctions); - - if (_node.documentation() && _annotation.docTags.count("author") > 0) - m_errorReporter.warning( - 9843_error, _node.documentation()->location(), - "Documentation tag @author is only allowed on contract definitions. " - "It will be disallowed in 0.7.0." - ); } -void DocStringAnalyser::parseDocStrings( +CallableDeclaration const* DocStringAnalyser::resolveInheritDoc( + set const& _baseFuncs, StructurallyDocumented const& _node, - StructurallyDocumentedAnnotation& _annotation, - set const& _validTags, - string const& _nodeName + StructurallyDocumentedAnnotation& _annotation ) { - DocStringParser parser; - if (_node.documentation() && !_node.documentation()->text()->empty()) - { - parser.parse(*_node.documentation()->text(), m_errorReporter); - _annotation.docTags = parser.tags(); - } + if (_annotation.inheritdocReference == nullptr) + return nullptr; - size_t returnTagsVisited = 0; - for (auto const& docTag: _annotation.docTags) - { - if (!_validTags.count(docTag.first)) - m_errorReporter.docstringParsingError( - 6546_error, - _node.documentation()->location(), - "Documentation tag @" + docTag.first + " not valid for " + _nodeName + "." - ); - else - if (docTag.first == "return") - { - returnTagsVisited++; - if (auto* varDecl = dynamic_cast(&_node)) - { - if (!varDecl->isPublic()) - m_errorReporter.docstringParsingError( - 9440_error, - _node.documentation()->location(), - "Documentation tag \"@" + docTag.first + "\" is only allowed on public state-variables." - ); - if (returnTagsVisited > 1) - m_errorReporter.docstringParsingError( - 5256_error, - _node.documentation()->location(), - "Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables." - ); - } - else if (auto* function = dynamic_cast(&_node)) - { - string content = docTag.second.content; - string firstWord = content.substr(0, content.find_first_of(" \t")); + if (auto const callable = findBaseCallable(_baseFuncs, _annotation.inheritdocReference->id())) + return callable; - if (returnTagsVisited > function->returnParameters().size()) - m_errorReporter.docstringParsingError( - 2604_error, - _node.documentation()->location(), - "Documentation tag \"@" + docTag.first + " " + docTag.second.content + "\"" + - " exceeds the number of return parameters." - ); - else - { - auto parameter = function->returnParameters().at(returnTagsVisited - 1); - if (!parameter->name().empty() && parameter->name() != firstWord) - m_errorReporter.docstringParsingError( - 5856_error, - _node.documentation()->location(), - "Documentation tag \"@" + docTag.first + " " + docTag.second.content + "\"" + - " does not contain the name of its return parameter." - ); - } - } - } - } + m_errorReporter.docstringParsingError( + 4682_error, + _node.documentation()->location(), + "Documentation tag @inheritdoc references contract \"" + + _annotation.inheritdocReference->name() + + "\", but the contract does not contain a function that is overridden by this function." + ); + + return nullptr; } diff --git a/libsolidity/analysis/DocStringAnalyser.h b/libsolidity/analysis/DocStringAnalyser.h index ee79cd9f7..e13cab898 100644 --- a/libsolidity/analysis/DocStringAnalyser.h +++ b/libsolidity/analysis/DocStringAnalyser.h @@ -15,12 +15,6 @@ along with solidity. If not, see . */ // SPDX-License-Identifier: GPL-3.0 -/** - * @author Christian - * @date 2015 - * Parses and analyses the doc strings. - * Stores the parsing results in the AST annotations and reports errors. - */ #pragma once @@ -35,7 +29,7 @@ namespace solidity::frontend { /** - * Parses and analyses the doc strings. + * Analyses and validates the doc strings. * Stores the parsing results in the AST annotations and reports errors. */ class DocStringAnalyser: private ASTConstVisitor @@ -45,20 +39,13 @@ public: bool analyseDocStrings(SourceUnit const& _sourceUnit); private: - bool visit(ContractDefinition const& _contract) override; bool visit(FunctionDefinition const& _function) override; bool visit(VariableDeclaration const& _variable) override; bool visit(ModifierDefinition const& _modifier) override; bool visit(EventDefinition const& _event) override; - void checkParameters( - CallableDeclaration const& _callable, - StructurallyDocumented const& _node, - StructurallyDocumentedAnnotation& _annotation - ); - - void handleConstructor( - CallableDeclaration const& _callable, + CallableDeclaration const* resolveInheritDoc( + std::set const& _baseFunctions, StructurallyDocumented const& _node, StructurallyDocumentedAnnotation& _annotation ); @@ -69,19 +56,6 @@ private: StructurallyDocumentedAnnotation& _annotation ); - void handleDeclaration( - Declaration const& _declaration, - StructurallyDocumented const& _node, - StructurallyDocumentedAnnotation& _annotation - ); - - void parseDocStrings( - StructurallyDocumented const& _node, - StructurallyDocumentedAnnotation& _annotation, - std::set const& _validTags, - std::string const& _nodeName - ); - langutil::ErrorReporter& m_errorReporter; }; diff --git a/libsolidity/analysis/DocStringTagParser.cpp b/libsolidity/analysis/DocStringTagParser.cpp new file mode 100644 index 000000000..36fec2f2c --- /dev/null +++ b/libsolidity/analysis/DocStringTagParser.cpp @@ -0,0 +1,227 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** + * @author Christian + * @date 2015 + * Parses and analyses the doc strings. + * Stores the parsing results in the AST annotations and reports errors. + */ + +#include + +#include +#include +#include +#include + +using namespace std; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; + +bool DocStringTagParser::parseDocStrings(SourceUnit const& _sourceUnit) +{ + auto errorWatcher = m_errorReporter.errorWatcher(); + _sourceUnit.accept(*this); + return errorWatcher.ok(); +} + +bool DocStringTagParser::visit(ContractDefinition const& _contract) +{ + static set const validTags = set{"author", "title", "dev", "notice"}; + parseDocStrings(_contract, _contract.annotation(), validTags, "contracts"); + + return true; +} + +bool DocStringTagParser::visit(FunctionDefinition const& _function) +{ + if (_function.isConstructor()) + handleConstructor(_function, _function, _function.annotation()); + else + handleCallable(_function, _function, _function.annotation()); + return true; +} + +bool DocStringTagParser::visit(VariableDeclaration const& _variable) +{ + if (_variable.isStateVariable()) + { + static set const validPublicTags = set{"dev", "notice", "return", "title", "author", "inheritdoc"}; + if (_variable.isPublic()) + parseDocStrings(_variable, _variable.annotation(), validPublicTags, "public state variables"); + else + { + parseDocStrings(_variable, _variable.annotation(), validPublicTags, "non-public state variables"); + if (_variable.annotation().docTags.count("notice") > 0) + m_errorReporter.warning( + 7816_error, _variable.documentation()->location(), + "Documentation tag on non-public state variables will be disallowed in 0.7.0. " + "You will need to use the @dev tag explicitly." + ); + } + if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0) + m_errorReporter.warning( + 8532_error, _variable.documentation()->location(), + "Documentation tag @title and @author is only allowed on contract definitions. " + "It will be disallowed in 0.7.0." + ); + } + return false; +} + +bool DocStringTagParser::visit(ModifierDefinition const& _modifier) +{ + handleCallable(_modifier, _modifier, _modifier.annotation()); + + return true; +} + +bool DocStringTagParser::visit(EventDefinition const& _event) +{ + handleCallable(_event, _event, _event.annotation()); + + return true; +} + +void DocStringTagParser::checkParameters( + CallableDeclaration const& _callable, + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation +) +{ + set validParams; + for (auto const& p: _callable.parameters()) + validParams.insert(p->name()); + if (_callable.returnParameterList()) + for (auto const& p: _callable.returnParameterList()->parameters()) + validParams.insert(p->name()); + auto paramRange = _annotation.docTags.equal_range("param"); + for (auto i = paramRange.first; i != paramRange.second; ++i) + if (!validParams.count(i->second.paramName)) + m_errorReporter.docstringParsingError( + 3881_error, + _node.documentation()->location(), + "Documented parameter \"" + + i->second.paramName + + "\" not found in the parameter list of the function." + ); +} + +void DocStringTagParser::handleConstructor( + CallableDeclaration const& _callable, + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation +) +{ + static set const validTags = set{"author", "dev", "notice", "param"}; + parseDocStrings(_node, _annotation, validTags, "constructor"); + checkParameters(_callable, _node, _annotation); +} + +void DocStringTagParser::handleCallable( + CallableDeclaration const& _callable, + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation +) +{ + static set const validEventTags = set{"author", "dev", "notice", "return", "param"}; + static set const validTags = set{"author", "dev", "notice", "return", "param", "inheritdoc"}; + + if (dynamic_cast(&_callable)) + parseDocStrings(_node, _annotation, validEventTags, "events"); + else + parseDocStrings(_node, _annotation, validTags, "functions"); + + checkParameters(_callable, _node, _annotation); + + if (_node.documentation() && _annotation.docTags.count("author") > 0) + m_errorReporter.warning( + 9843_error, _node.documentation()->location(), + "Documentation tag @author is only allowed on contract definitions. " + "It will be disallowed in 0.7.0." + ); +} + +void DocStringTagParser::parseDocStrings( + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation, + set const& _validTags, + string const& _nodeName +) +{ + DocStringParser parser; + if (_node.documentation() && !_node.documentation()->text()->empty()) + { + parser.parse(*_node.documentation()->text(), m_errorReporter); + _annotation.docTags = parser.tags(); + } + + size_t returnTagsVisited = 0; + for (auto const& docTag: _annotation.docTags) + { + if (!_validTags.count(docTag.first)) + m_errorReporter.docstringParsingError( + 6546_error, + _node.documentation()->location(), + "Documentation tag @" + docTag.first + " not valid for " + _nodeName + "." + ); + else if (docTag.first == "return") + { + returnTagsVisited++; + if (auto const* varDecl = dynamic_cast(&_node)) + { + if (!varDecl->isPublic()) + m_errorReporter.docstringParsingError( + 9440_error, + _node.documentation()->location(), + "Documentation tag \"@" + docTag.first + "\" is only allowed on public state-variables." + ); + if (returnTagsVisited > 1) + m_errorReporter.docstringParsingError( + 5256_error, + _node.documentation()->location(), + "Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables." + ); + } + else if (auto const* function = dynamic_cast(&_node)) + { + string content = docTag.second.content; + string firstWord = content.substr(0, content.find_first_of(" \t")); + + if (returnTagsVisited > function->returnParameters().size()) + m_errorReporter.docstringParsingError( + 2604_error, + _node.documentation()->location(), + "Documentation tag \"@" + docTag.first + " " + docTag.second.content + "\"" + + " exceeds the number of return parameters." + ); + else + { + auto parameter = function->returnParameters().at(returnTagsVisited - 1); + if (!parameter->name().empty() && parameter->name() != firstWord) + m_errorReporter.docstringParsingError( + 5856_error, + _node.documentation()->location(), + "Documentation tag \"@" + docTag.first + " " + docTag.second.content + "\"" + + " does not contain the name of its return parameter." + ); + } + } + } + } +} diff --git a/libsolidity/analysis/DocStringTagParser.h b/libsolidity/analysis/DocStringTagParser.h new file mode 100644 index 000000000..41dcca5df --- /dev/null +++ b/libsolidity/analysis/DocStringTagParser.h @@ -0,0 +1,76 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#pragma once + +#include + +namespace solidity::langutil +{ +class ErrorReporter; +} + +namespace solidity::frontend +{ + +/** + * Parses the doc tags and does basic validity checks. + * Stores the parsing results in the AST annotations and reports errors. + */ +class DocStringTagParser: private ASTConstVisitor +{ +public: + explicit DocStringTagParser(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {} + bool parseDocStrings(SourceUnit const& _sourceUnit); + +private: + bool visit(ContractDefinition const& _contract) override; + bool visit(FunctionDefinition const& _function) override; + bool visit(VariableDeclaration const& _variable) override; + bool visit(ModifierDefinition const& _modifier) override; + bool visit(EventDefinition const& _event) override; + + void checkParameters( + CallableDeclaration const& _callable, + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation + ); + + void handleConstructor( + CallableDeclaration const& _callable, + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation + ); + + void handleCallable( + CallableDeclaration const& _callable, + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation + ); + + void parseDocStrings( + StructurallyDocumented const& _node, + StructurallyDocumentedAnnotation& _annotation, + std::set const& _validTags, + std::string const& _nodeName + ); + + langutil::ErrorReporter& m_errorReporter; +}; + +} diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 10ad415c1..4d26f1888 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -36,6 +36,7 @@ #include #include +#include using namespace std; using namespace solidity::langutil; @@ -106,6 +107,14 @@ void ReferencesResolver::endVisit(VariableDeclarationStatement const& _varDeclSt m_resolver.activateVariable(var->name()); } +bool ReferencesResolver::visit(VariableDeclaration const& _varDecl) +{ + if (_varDecl.documentation()) + resolveInheritDoc(*_varDecl.documentation(), _varDecl.annotation()); + + return true; +} + bool ReferencesResolver::visit(Identifier const& _identifier) { auto declarations = m_resolver.nameFromCurrentScope(_identifier.name()); @@ -132,6 +141,10 @@ bool ReferencesResolver::visit(Identifier const& _identifier) bool ReferencesResolver::visit(FunctionDefinition const& _functionDefinition) { m_returnParameters.push_back(_functionDefinition.returnParameterList().get()); + + if (_functionDefinition.documentation()) + resolveInheritDoc(*_functionDefinition.documentation(), _functionDefinition.annotation()); + return true; } @@ -141,9 +154,13 @@ void ReferencesResolver::endVisit(FunctionDefinition const&) m_returnParameters.pop_back(); } -bool ReferencesResolver::visit(ModifierDefinition const&) +bool ReferencesResolver::visit(ModifierDefinition const& _modifierDefinition) { m_returnParameters.push_back(nullptr); + + if (_modifierDefinition.documentation()) + resolveInheritDoc(*_modifierDefinition.documentation(), _modifierDefinition.annotation()); + return true; } @@ -284,4 +301,53 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) visit(*_varDecl.value); } +void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _documentation, StructurallyDocumentedAnnotation& _annotation) +{ + switch (_annotation.docTags.count("inheritdoc")) + { + case 0: + break; + case 1: + { + string const& name = _annotation.docTags.find("inheritdoc")->second.content; + vector path; + boost::split(path, name, boost::is_any_of(".")); + Declaration const* result = m_resolver.pathFromCurrentScope(path); + + if (result == nullptr) + { + m_errorReporter.docstringParsingError( + 9397_error, + _documentation.location(), + "Documentation tag @inheritdoc references inexistent contract \"" + + name + + "\"." + ); + return; + } + else + { + _annotation.inheritdocReference = dynamic_cast(result); + + if (!_annotation.inheritdocReference) + m_errorReporter.docstringParsingError( + 1430_error, + _documentation.location(), + "Documentation tag @inheritdoc reference \"" + + name + + "\" is not a contract." + ); + } + break; + } + default: + m_errorReporter.docstringParsingError( + 5142_error, + _documentation.location(), + "Documentation tag @inheritdoc can only be given once." + ); + break; + } +} + } diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index 710f388cb..fc71b4d4e 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -76,6 +76,7 @@ private: bool visit(ForStatement const& _for) override; void endVisit(ForStatement const& _for) override; void endVisit(VariableDeclarationStatement const& _varDeclStatement) override; + bool visit(VariableDeclaration const& _varDecl) override; bool visit(Identifier const& _identifier) override; bool visit(FunctionDefinition const& _functionDefinition) override; void endVisit(FunctionDefinition const& _functionDefinition) override; @@ -89,6 +90,8 @@ private: void operator()(yul::Identifier const& _identifier) override; void operator()(yul::VariableDeclaration const& _varDecl) override; + void resolveInheritDoc(StructuredDocumentation const& _documentation, StructurallyDocumentedAnnotation& _annotation); + langutil::ErrorReporter& m_errorReporter; NameAndTypeResolver& m_resolver; langutil::EVMVersion m_evmVersion; diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index d4df9d0cf..272bf6440 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -79,6 +79,8 @@ struct StructurallyDocumentedAnnotation /// Mapping docstring tag name -> content. std::multimap docTags; + /// contract that @inheritdoc references if it exists + ContractDefinition const* inheritdocReference = nullptr; }; struct SourceUnitAnnotation: ASTAnnotation diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index f8164bc9f..27a51552e 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -308,6 +309,11 @@ bool CompilerStack::analyze() if (source->ast && !syntaxChecker.checkSyntax(*source->ast)) noErrors = false; + DocStringTagParser DocStringTagParser(m_errorReporter); + for (Source const* source: m_sourceOrder) + if (source->ast && !DocStringTagParser.parseDocStrings(*source->ast)) + noErrors = false; + m_globalContext = make_shared(); // We need to keep the same resolver during the whole process. NameAndTypeResolver resolver(*m_globalContext, m_evmVersion, m_errorReporter); @@ -363,6 +369,7 @@ bool CompilerStack::analyze() if (!contractLevelChecker.check(*contract)) noErrors = false; + // Requires ContractLevelChecker DocStringAnalyser docStringAnalyser(m_errorReporter); for (Source const* source: m_sourceOrder) if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast)) diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 1f5c4807a..67ef6f17f 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -58,28 +58,22 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) for (auto const& it: _contractDef.interfaceFunctions()) if (it.second->hasDeclaration()) { + string value; + if (auto const* f = dynamic_cast(&it.second->declaration())) - { - string value = extractDoc(f->annotation().docTags, "notice"); - if (!value.empty()) - { - Json::Value user; - // since @notice is the only user tag if missing function should not appear - user["notice"] = Json::Value(value); - methods[it.second->externalSignature()] = user; - } - } + value = extractDoc(f->annotation().docTags, "notice"); else if (auto var = dynamic_cast(&it.second->declaration())) { solAssert(var->isStateVariable() && var->isPublic(), ""); - string value = extractDoc(var->annotation().docTags, "notice"); - if (!value.empty()) - { - Json::Value user; - // since @notice is the only user tag if missing function should not appear - user["notice"] = Json::Value(value); - methods[it.second->externalSignature()] = user; - } + value = extractDoc(var->annotation().docTags, "notice"); + } + + if (!value.empty()) + { + Json::Value user; + // since @notice is the only user tag if missing function should not appear + user["notice"] = Json::Value(value); + methods[it.second->externalSignature()] = user; } } diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 8edf470f4..26e293b68 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -77,7 +77,7 @@ public: BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError)); } -private: +protected: CompilerStack m_compilerStack; }; @@ -1277,13 +1277,7 @@ BOOST_AUTO_TEST_CASE(dev_default_inherit_variable) )"; char const *natspec = R"ABCDEF({ - "methods": - { - "x()": - { - "details": "test" - } - } + "methods": { "x()": { "details": "test" } } })ABCDEF"; char const *natspec1 = R"ABCDEF({ @@ -1318,13 +1312,80 @@ BOOST_AUTO_TEST_CASE(user_default_inherit_variable) )"; char const *natspec = R"ABCDEF({ - "methods": - { - "x()": - { - "notice": "Hello world" + "methods": { "x()": { "notice": "Hello world" } } + })ABCDEF"; + + checkNatspec(sourceCode, "C", natspec, true); + checkNatspec(sourceCode, "D", natspec, true); +} + +BOOST_AUTO_TEST_CASE(dev_explicit_inherit_variable) +{ + char const *sourceCode = R"( + contract B { + function x() virtual external returns (uint) { + return 1; } } + + contract C { + /// @notice Hello world + /// @dev test + function x() virtual external returns (uint) { + return 1; + } + } + + contract D is C, B { + /// @inheritdoc C + uint public override(C, B) x; + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": { "x()": { "details": "test" } } + })ABCDEF"; + + char const *natspec1 = R"ABCDEF({ + "methods" : {}, + "stateVariables" : + { + "x" : + { + "details" : "test" + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "C", natspec, false); + checkNatspec(sourceCode, "D", natspec1, false); +} + +BOOST_AUTO_TEST_CASE(user_explicit_inherit_variable) +{ + char const *sourceCode = R"( + contract B { + function x() virtual external returns (uint) { + return 1; + } + } + + contract C { + /// @notice Hello world + /// @dev test + function x() virtual external returns (uint) { + return 1; + } + } + + contract D is C, B { + /// @inheritdoc C + uint public override(C, B) x; + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": { "x()": { "notice": "Hello world" } } })ABCDEF"; checkNatspec(sourceCode, "C", natspec, true); @@ -1423,6 +1484,411 @@ BOOST_AUTO_TEST_CASE(user_default_inherit) checkNatspec(sourceCode, "Token", natspec, true); } +BOOST_AUTO_TEST_CASE(dev_explicit_inherit) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 { + function transfer(address to, uint amount) virtual external returns (bool) { + return false; + } + } + + contract Token is ERC21, ERC20 { + /// @inheritdoc ERC20 + function transfer(address to, uint amount) override(ERC21, ERC20) external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "test", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, false); + checkNatspec(sourceCode, "Token", natspec, false); +} + +BOOST_AUTO_TEST_CASE(user_explicit_inherit) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 { + function transfer(address to, uint amount) virtual external returns (bool) { + return false; + } + } + + contract Token is ERC21, ERC20 { + /// @inheritdoc ERC20 + function transfer(address to, uint amount) override(ERC21, ERC20) external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "notice": "Transfer ``amount`` from ``msg.sender`` to ``to``." + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, true); + checkNatspec(sourceCode, "Token", natspec, true); +} + +BOOST_AUTO_TEST_CASE(dev_explicit_inherit2) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 is ERC20 { + function transfer(address to, uint amount) virtual override external returns (bool) { + return false; + } + } + + contract Token is ERC20 { + /// @inheritdoc ERC20 + function transfer(address to, uint amount) override external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "test", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, false); + checkNatspec(sourceCode, "ERC21", natspec, false); + checkNatspec(sourceCode, "Token", natspec, false); +} + +BOOST_AUTO_TEST_CASE(user_explicit_inherit2) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 is ERC20 { + function transfer(address to, uint amount) virtual override external returns (bool) { + return false; + } + } + + contract Token is ERC20 { + /// @inheritdoc ERC20 + function transfer(address to, uint amount) override external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "notice": "Transfer ``amount`` from ``msg.sender`` to ``to``." + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, true); + checkNatspec(sourceCode, "ERC21", natspec, true); + checkNatspec(sourceCode, "Token", natspec, true); +} + +BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial2) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 is ERC20 { + /// @inheritdoc ERC20 + /// @dev override dev comment + /// @notice override notice + function transfer(address to, uint amount) virtual override external returns (bool) { + return false; + } + } + + contract Token is ERC21 { + function transfer(address to, uint amount) override external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "test", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + char const *natspec2 = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "override dev comment", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, false); + checkNatspec(sourceCode, "Token", natspec2, false); +} + +BOOST_AUTO_TEST_CASE(user_explicit_inherit_partial2) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 is ERC20 { + /// @inheritdoc ERC20 + /// @dev override dev comment + /// @notice override notice + function transfer(address to, uint amount) virtual override external returns (bool) { + return false; + } + } + + contract Token is ERC21 { + function transfer(address to, uint amount) override external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "notice": "Transfer ``amount`` from ``msg.sender`` to ``to``." + } + } + })ABCDEF"; + + char const *natspec2 = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "notice": "override notice" + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, true); + checkNatspec(sourceCode, "Token", natspec2, true); +} +BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 { + function transfer(address to, uint amount) virtual external returns (bool) { + return false; + } + } + + contract Token is ERC21, ERC20 { + /// @inheritdoc ERC20 + /// @dev override dev comment + /// @notice override notice + function transfer(address to, uint amount) override(ERC21, ERC20) external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "test", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + char const *natspec2 = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "override dev comment", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, false); + checkNatspec(sourceCode, "Token", natspec2, false); +} + +BOOST_AUTO_TEST_CASE(user_explicit_inherit_partial) +{ + char const *sourceCode = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + contract ERC21 { + function transfer(address to, uint amount) virtual external returns (bool) { + return false; + } + } + + contract Token is ERC21, ERC20 { + /// @inheritdoc ERC20 + /// @dev override dev comment + /// @notice override notice + function transfer(address to, uint amount) override(ERC21, ERC20) external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "notice": "Transfer ``amount`` from ``msg.sender`` to ``to``." + } + } + })ABCDEF"; + + char const *natspec2 = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "notice": "override notice" + } + } + })ABCDEF"; + + checkNatspec(sourceCode, "ERC20", natspec, true); + checkNatspec(sourceCode, "Token", natspec2, true); +} + BOOST_AUTO_TEST_CASE(dev_inherit_parameter_mismatch) { char const *sourceCode = R"( @@ -1517,6 +1983,80 @@ BOOST_AUTO_TEST_CASE(user_inherit_parameter_mismatch) checkNatspec(sourceCode, "Token", natspec2, true); } +BOOST_AUTO_TEST_CASE(dev_explicit_inehrit_complex) +{ + char const *sourceCode1 = R"( + interface ERC20 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer + /// @dev test + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + + interface ERC21 { + /// Transfer ``amount`` from ``msg.sender`` to ``to``. + /// @author Programmer2 + /// @dev test2 + /// @param to address to transfer to + /// @param amount amount to transfer + function transfer(address to, uint amount) external returns (bool); + } + )"; + + char const *sourceCode2 = R"( + import "Interfaces.sol" as myInterfaces; + + contract Token is myInterfaces.ERC20, myInterfaces.ERC21 { + /// @inheritdoc myInterfaces.ERC20 + function transfer(address too, uint amount) + override(myInterfaces.ERC20, myInterfaces.ERC21) external returns (bool) { + return false; + } + } + )"; + + char const *natspec = R"ABCDEF({ + "methods": + { + "transfer(address,uint256)": + { + "author": "Programmer", + "details": "test", + "params": + { + "amount": "amount to transfer", + "to": "address to transfer to" + } + } + } + })ABCDEF"; + + m_compilerStack.reset(); + m_compilerStack.setSources({ + {"Interfaces.sol", "pragma solidity >=0.0;\n" + std::string(sourceCode1)}, + {"Testfile.sol", "pragma solidity >=0.0;\n" + std::string(sourceCode2)} + }); + + m_compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + + BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed"); + + Json::Value generatedDocumentation = m_compilerStack.natspecDev("Token"); + Json::Value expectedDocumentation; + util::jsonParseStrict(natspec, expectedDocumentation); + + expectedDocumentation["version"] = Json::Value(Natspec::c_natspecVersion); + expectedDocumentation["kind"] = Json::Value("dev"); + + BOOST_CHECK_MESSAGE( + expectedDocumentation == generatedDocumentation, + "Expected:\n" << expectedDocumentation.toStyledString() << + "\n but got:\n" << generatedDocumentation.toStyledString() + ); +} + } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc.sol b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc.sol new file mode 100644 index 000000000..678872d7a --- /dev/null +++ b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc.sol @@ -0,0 +1,7 @@ +contract C { + /// @inheritdoc X + function f() internal { + } +} +// ---- +// DocstringParsingError 9397: (17-34): Documentation tag @inheritdoc references inexistent contract "X". diff --git a/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc2.sol b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc2.sol new file mode 100644 index 000000000..4d97ff93d --- /dev/null +++ b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc2.sol @@ -0,0 +1,10 @@ +contract D { +} + +contract C is D { + /// @inheritdoc D + function f() internal { + } +} +// ---- +// DocstringParsingError 4682: (38-55): Documentation tag @inheritdoc references contract "D", but the contract does not contain a function that is overridden by this function. diff --git a/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc3.sol b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc3.sol new file mode 100644 index 000000000..d00e1e7ea --- /dev/null +++ b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc3.sol @@ -0,0 +1,11 @@ +contract D { + struct S { uint a; } +} + +contract C is D { + /// @inheritdoc D.S + function f() internal { + } +} +// ---- +// DocstringParsingError 1430: (63-82): Documentation tag @inheritdoc reference "D.S" is not a contract. diff --git a/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_wrong_type.sol b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_wrong_type.sol new file mode 100644 index 000000000..510f6622f --- /dev/null +++ b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_wrong_type.sol @@ -0,0 +1,8 @@ +contract C { + struct S { uint a; } + /// @inheritdoc S + function f() internal { + } +} +// ---- +// DocstringParsingError 1430: (42-59): Documentation tag @inheritdoc reference "S" is not a contract. diff --git a/test/libsolidity/syntaxTests/natspec/invalid/inherit_doc_events.sol b/test/libsolidity/syntaxTests/natspec/invalid/inherit_doc_events.sol new file mode 100644 index 000000000..e7fb1a822 --- /dev/null +++ b/test/libsolidity/syntaxTests/natspec/invalid/inherit_doc_events.sol @@ -0,0 +1,17 @@ +contract ERC20 { + /// @notice This event is emitted when a transfer occurs. + /// @param from The source account. + /// @param to The destination account. + /// @param amount The amount. + /// @dev A test case! + event Transfer(address indexed from, address indexed to, uint amount); +} + +contract A is ERC20 { + /// @inheritdoc ERC20 + event Transfer(); +} + + +// ---- +// DocstringParsingError 6546: (305-326): Documentation tag @inheritdoc not valid for events. From ecdfef1b308330b1c672a8e73565676e2f8d2f75 Mon Sep 17 00:00:00 2001 From: a3d4 Date: Tue, 21 Jul 2020 00:18:47 +0200 Subject: [PATCH 61/71] Replace grave accent with acute accent --- libsolidity/analysis/TypeChecker.cpp | 2 +- .../syntaxTests/iceRegressionTests/oversized_var.sol | 2 +- .../syntaxTests/types/var_type_suggest.sol | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 92abc11e6..0a14d5cc9 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1306,7 +1306,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) 1719_error, _statement.location(), "Use of the \"var\" keyword is disallowed. " - "Use explicit declaration `" + createTupleDecl(variables) + " = ...® instead." + "Use explicit declaration `" + createTupleDecl(variables) + " = ...` instead." ); } diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol b/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol index 0e50ae138..45e2779c5 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol @@ -12,4 +12,4 @@ contract b { // Warning 2519: (105-110): This declaration shadows an existing declaration. // Warning 3408: (66-69): Variable "d" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. // Warning 2332: (105-110): Type "b.c" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// SyntaxError 1719: (105-114): Use of the "var" keyword is disallowed. Use explicit declaration `struct b.c storage pointer d = ...® instead. +// SyntaxError 1719: (105-114): Use of the "var" keyword is disallowed. Use explicit declaration `struct b.c storage pointer d = ...` instead. diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol index 65d91cd1e..61ee7d317 100644 --- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol +++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol @@ -20,11 +20,11 @@ contract C { } } // ---- -// SyntaxError 1719: (224-238): Use of the "var" keyword is disallowed. Use explicit declaration `int16 s = ...® instead. -// SyntaxError 1719: (248-261): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...® instead. -// SyntaxError 1719: (271-287): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...® instead. -// SyntaxError 1719: (297-307): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...® instead. +// SyntaxError 1719: (224-238): Use of the "var" keyword is disallowed. Use explicit declaration `int16 s = ...` instead. +// SyntaxError 1719: (248-261): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...` instead. +// SyntaxError 1719: (271-287): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...` instead. +// SyntaxError 1719: (297-307): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...` instead. // SyntaxError 3478: (317-350): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// SyntaxError 1719: (360-384): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...® instead. -// SyntaxError 1719: (394-411): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...® instead. +// SyntaxError 1719: (360-384): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...` instead. +// SyntaxError 1719: (394-411): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...` instead. // TypeError 7364: (421-438): Different number of components on the left hand side (2) than on the right hand side (1). From 1b95a5e1fcb8c8e506b0cc09fcb48cbbb1aec724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiny=E7=86=8A?= Date: Tue, 21 Jul 2020 16:28:13 +0800 Subject: [PATCH 62/71] Update simplified chinese translation link. The implified chinese translation version now host on https://learnblockchain.cn/docs/solidity/ . This url will be keep updating . --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 89976a8d4..d616d6e88 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -77,7 +77,7 @@ version stands as a reference. * `Japanese `_ * `Korean `_ (in progress) * `Russian `_ (rather outdated) -* `Simplified Chinese `_ (in progress) +* `Simplified Chinese `_ (in progress) * `Spanish `_ * `Turkish `_ (partial) From 952101996cb6a198e493e253a07e7184e8359bbf Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Tue, 16 Jun 2020 17:13:46 +0200 Subject: [PATCH 63/71] Removing expectDeposit() from AsmAnalysis as unused function --- libyul/AsmAnalysis.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 8d8db59ab..552191c4d 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -102,7 +102,6 @@ private: /// Vists the expression and expects it to return a single boolean value. /// Reports an error otherwise. void expectBoolExpression(Expression const& _expr); - bool expectDeposit(int _deposit, int _oldHeight, langutil::SourceLocation const& _location); /// Verifies that a variable to be assigned to exists, can be assigned to /// and has the same type as the value. From c11bb24a514fc303b61c15658005b78261aca093 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 21 Jul 2020 12:10:33 +0200 Subject: [PATCH 64/71] Add example about array literals. --- docs/types/reference-types.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index 5bd242f06..17a52f43b 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -237,6 +237,23 @@ memory arrays, i.e. the following is not possible: It is planned to remove this restriction in the future, but it creates some complications because of how arrays are passed in the ABI. +If you want to initialize dynamically-sized arrays, you have to assign the +individual elements: + +:: + + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.4.0 <0.7.0; + + contract C { + function f() public pure { + uint[] memory x = new uint[](3); + x[0] = 1; + x[1] = 3; + x[2] = 4; + } + } + .. index:: ! array;length, length, push, pop, !array;push, !array;pop .. _array-members: From 4067bab7ddac83818916aed840dd6d43396fb723 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Mon, 6 Jul 2020 19:32:48 +0200 Subject: [PATCH 65/71] Add corpus based multi source fuzzer Co-authored-by: Leonardo --- test/TestCaseReader.cpp | 7 +++++++ test/TestCaseReader.h | 1 + test/tools/fuzzer_common.cpp | 6 +++--- test/tools/fuzzer_common.h | 9 ++++++++- test/tools/ossfuzz/CMakeLists.txt | 4 ++-- test/tools/ossfuzz/solc_noopt_ossfuzz.cpp | 17 ++++++++++++++++- test/tools/ossfuzz/solc_opt_ossfuzz.cpp | 19 +++++++++++++++++-- 7 files changed, 54 insertions(+), 9 deletions(-) diff --git a/test/TestCaseReader.cpp b/test/TestCaseReader.cpp index 7b3611d82..d38e883ea 100644 --- a/test/TestCaseReader.cpp +++ b/test/TestCaseReader.cpp @@ -38,6 +38,13 @@ TestCaseReader::TestCaseReader(string const& _filename): m_unreadSettings = m_settings; } +TestCaseReader::TestCaseReader(istringstream const& _str) +{ + tie(m_sources, m_lineNumber) = parseSourcesAndSettingsWithLineNumber( + static_cast(const_cast(_str)) + ); +} + string const& TestCaseReader::source() const { if (m_sources.sources.size() != 1) diff --git a/test/TestCaseReader.h b/test/TestCaseReader.h index 720c26338..620565aee 100644 --- a/test/TestCaseReader.h +++ b/test/TestCaseReader.h @@ -42,6 +42,7 @@ class TestCaseReader public: TestCaseReader() = default; explicit TestCaseReader(std::string const& _filename); + explicit TestCaseReader(std::istringstream const& _testCode); SourceMap const& sources() const { return m_sources; } std::string const& source() const; diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index 437ab5d22..cb153e0e8 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -72,16 +72,16 @@ void FuzzerUtil::testCompilerJsonInterface(string const& _input, bool _optimize, runCompiler(jsonCompactPrint(config), _quiet); } -void FuzzerUtil::testCompiler(string const& _input, bool _optimize) +void FuzzerUtil::testCompiler(StringMap const& _input, bool _optimize, unsigned _rand) { frontend::CompilerStack compiler; - EVMVersion evmVersion = s_evmVersions[_input.size() % s_evmVersions.size()]; + EVMVersion evmVersion = s_evmVersions[_rand % s_evmVersions.size()]; frontend::OptimiserSettings optimiserSettings; if (_optimize) optimiserSettings = frontend::OptimiserSettings::standard(); else optimiserSettings = frontend::OptimiserSettings::minimal(); - compiler.setSources({{"", _input}}); + compiler.setSources(_input); compiler.setEVMVersion(evmVersion); compiler.setOptimiserSettings(optimiserSettings); try diff --git a/test/tools/fuzzer_common.h b/test/tools/fuzzer_common.h index c8749d9b1..cd30adc97 100644 --- a/test/tools/fuzzer_common.h +++ b/test/tools/fuzzer_common.h @@ -16,6 +16,9 @@ */ // SPDX-License-Identifier: GPL-3.0 +#include + +#include #include /** @@ -28,5 +31,9 @@ struct FuzzerUtil static void testCompilerJsonInterface(std::string const& _input, bool _optimize, bool _quiet); static void testConstantOptimizer(std::string const& _input, bool _quiet); static void testStandardCompiler(std::string const& _input, bool _quiet); - static void testCompiler(std::string const& _input, bool _optimize); + /// Compiles @param _input which is a map of input file name to source code + /// string with optimisation turned on if @param _optimize is true + /// (off otherwise) and a pseudo-random @param _rand that selects the EVM + /// version to be compiled for. + static void testCompiler(solidity::StringMap const& _input, bool _optimize, unsigned _rand); }; diff --git a/test/tools/ossfuzz/CMakeLists.txt b/test/tools/ossfuzz/CMakeLists.txt index 9ad7b9c80..a799bd736 100644 --- a/test/tools/ossfuzz/CMakeLists.txt +++ b/test/tools/ossfuzz/CMakeLists.txt @@ -23,11 +23,11 @@ if (OSSFUZZ) endif() if (OSSFUZZ) - add_executable(solc_opt_ossfuzz solc_opt_ossfuzz.cpp ../fuzzer_common.cpp) + add_executable(solc_opt_ossfuzz solc_opt_ossfuzz.cpp ../fuzzer_common.cpp ../../TestCaseReader.cpp) target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm) set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) - add_executable(solc_noopt_ossfuzz solc_noopt_ossfuzz.cpp ../fuzzer_common.cpp) + add_executable(solc_noopt_ossfuzz solc_noopt_ossfuzz.cpp ../fuzzer_common.cpp ../../TestCaseReader.cpp) target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm) set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) diff --git a/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp b/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp index e2f3a294f..8d615c0bd 100644 --- a/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp +++ b/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp @@ -18,6 +18,11 @@ #include +#include + +#include + +using namespace solidity::frontend::test; using namespace std; extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) @@ -25,7 +30,17 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) if (_size <= 600) { string input(reinterpret_cast(_data), _size); - FuzzerUtil::testCompiler(input, /*optimize=*/false); + map sourceCode; + try + { + TestCaseReader t = TestCaseReader(std::istringstream(input)); + sourceCode = t.sources().sources; + } + catch (runtime_error const&) + { + return 0; + } + FuzzerUtil::testCompiler(sourceCode, /*optimize=*/false, /*_rand=*/_size); } return 0; } diff --git a/test/tools/ossfuzz/solc_opt_ossfuzz.cpp b/test/tools/ossfuzz/solc_opt_ossfuzz.cpp index bff19407f..0d9c7f44e 100644 --- a/test/tools/ossfuzz/solc_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/solc_opt_ossfuzz.cpp @@ -18,14 +18,29 @@ #include +#include + +#include + +using namespace solidity::frontend::test; using namespace std; extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) { if (_size <= 600) { - string input(reinterpret_cast(_data), _size); - FuzzerUtil::testCompiler(input, /*optimize=*/true); + string input(reinterpret_cast(_data), _size); + map sourceCode; + try + { + TestCaseReader t = TestCaseReader(std::istringstream(input)); + sourceCode = t.sources().sources; + } + catch (runtime_error const&) + { + return 0; + } + FuzzerUtil::testCompiler(sourceCode, /*optimize=*/true, /*rand=*/_size); } return 0; } From 0a3c9ec358573d601ae6f101bc85bb92df2bcc7c Mon Sep 17 00:00:00 2001 From: a3d4 Date: Thu, 16 Jul 2020 22:06:55 +0200 Subject: [PATCH 66/71] Print source file names for uncovered error codes. Use more consistent naming. --- scripts/error_codes.py | 121 ++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 45 deletions(-) diff --git a/scripts/error_codes.py b/scripts/error_codes.py index da317d45c..8ab9b04dc 100755 --- a/scripts/error_codes.py +++ b/scripts/error_codes.py @@ -36,24 +36,26 @@ def in_comment(source, pos): return slash_star_pos > star_slash_pos -def find_ids_in_source_file(file_name, ids): +def find_ids_in_source_file(file_name, id_to_file_names): source = read_file(file_name) for m in re.finditer(SOURCE_FILE_PATTERN, source): if in_comment(source, m.start()): continue underscore_pos = m.group(0).index("_") id = m.group(0)[0:underscore_pos] - if id in ids: - ids[id] += 1 + if id in id_to_file_names: + id_to_file_names[id].append(file_name) else: - ids[id] = 1 + id_to_file_names[id] = [file_name] -def get_used_ids(file_names): - used_ids = {} +def find_ids_in_source_files(file_names): + """Returns a dictionary with list of source files for every appearance of every id""" + + id_to_file_names = {} for file_name in file_names: - find_ids_in_source_file(file_name, used_ids) - return used_ids + find_ids_in_source_file(file_name, id_to_file_names) + return id_to_file_names def get_next_id(available_ids): @@ -63,7 +65,7 @@ def get_next_id(available_ids): return next_id -def fix_ids_in_file(file_name, available_ids, used_ids): +def fix_ids_in_source_file(file_name, id_to_count, available_ids): source = read_file(file_name) k = 0 @@ -75,11 +77,11 @@ def fix_ids_in_file(file_name, available_ids, used_ids): id = m.group(0)[0:underscore_pos] # incorrect id or id has a duplicate somewhere - if not in_comment(source, m.start()) and (len(id) != 4 or id[0] == "0" or used_ids[id] > 1): - assert id in used_ids + if not in_comment(source, m.start()) and (len(id) != 4 or id[0] == "0" or id_to_count[id] > 1): + assert id in id_to_count new_id = get_next_id(available_ids) - assert new_id not in used_ids - used_ids[id] -= 1 + assert new_id not in id_to_count + id_to_count[id] -= 1 else: new_id = id @@ -94,10 +96,15 @@ def fix_ids_in_file(file_name, available_ids, used_ids): print(f"Fixed file: {file_name}") -def fix_ids(used_ids, file_names): - available_ids = {str(id) for id in range(1000, 10000)} - used_ids.keys() +def fix_ids_in_source_files(file_names, id_to_count): + """ + Fixes ids in given source files; + id_to_count contains number of appearances of every id in sources + """ + + available_ids = {str(id) for id in range(1000, 10000)} - id_to_count.keys() for file_name in file_names: - fix_ids_in_file(file_name, available_ids, used_ids) + fix_ids_in_source_file(file_name, id_to_count, available_ids) def find_files(top_dir, sub_dirs, extensions): @@ -121,10 +128,12 @@ def find_ids_in_test_file(file_name): def find_ids_in_test_files(file_names): - used_ids = set() + """Returns a set containing all ids in tests""" + + ids = set() for file_name in file_names: - used_ids |= find_ids_in_test_file(file_name) - return used_ids + ids |= find_ids_in_test_file(file_name) + return ids def find_ids_in_cmdline_test_err(file_name): @@ -142,7 +151,23 @@ def print_ids(ids): print(id, end="") -def examine_id_coverage(top_dir, used_ids): +def print_ids_per_file(ids, id_to_file_names, top_dir): + file_name_to_ids = {} + for id in ids: + for file_name in id_to_file_names[id]: + relpath = path.relpath(file_name, top_dir) + if relpath not in file_name_to_ids: + file_name_to_ids[relpath] = [] + file_name_to_ids[relpath].append(id) + + for file_name in sorted(file_name_to_ids): + print(file_name) + for id in sorted(file_name_to_ids[file_name]): + print(f" {id}", end="") + print() + + +def examine_id_coverage(top_dir, source_id_to_file_names): test_sub_dirs = [ path.join("test", "libsolidity", "errorRecoveryTests"), path.join("test", "libsolidity", "smtCheckerTests"), @@ -153,27 +178,28 @@ def examine_id_coverage(top_dir, used_ids): test_sub_dirs, [".sol"] ) - covered_ids = find_ids_in_test_files(test_file_names) + source_ids = source_id_to_file_names.keys() + test_ids = find_ids_in_test_files(test_file_names) # special case, we are interested in warnings which are ignored by regular tests: # Warning (1878): SPDX license identifier not provided in source file. .... # Warning (3420): Source file does not specify required compiler version! - covered_ids |= find_ids_in_cmdline_test_err(path.join(top_dir, "test", "cmdlineTests", "error_codes", "err")) + test_ids |= find_ids_in_cmdline_test_err(path.join(top_dir, "test", "cmdlineTests", "error_codes", "err")) - print(f"IDs in source files: {len(used_ids)}") - print(f"IDs in test files : {len(covered_ids)} ({len(covered_ids) - len(used_ids)})") + print(f"IDs in source files: {len(source_ids)}") + print(f"IDs in test files : {len(test_ids)} ({len(test_ids) - len(source_ids)})") print() - unused_covered_ids = covered_ids - used_ids - if len(unused_covered_ids) != 0: + test_only_ids = test_ids - source_ids + if len(test_only_ids) != 0: print("Error. The following error codes found in tests, but not in sources:") - print_ids(unused_covered_ids) + print_ids(test_only_ids) return 1 - used_uncovered_ids = used_ids - covered_ids - if len(used_uncovered_ids) != 0: + source_only_ids = source_ids - test_ids + if len(source_only_ids) != 0: print("The following error codes found in sources, but not in tests:") - print_ids(used_uncovered_ids) + print_ids_per_file(source_only_ids, source_id_to_file_names, top_dir) print("\n\nPlease make sure to add appropriate tests.") return 1 @@ -187,22 +213,22 @@ def main(argv): fix = False no_confirm = False examine_coverage = False - next = False + next_id = False opts, args = getopt.getopt(argv, "", ["check", "fix", "no-confirm", "examine-coverage", "next"]) for opt, arg in opts: - if opt == '--check': + if opt == "--check": check = True elif opt == "--fix": fix = True - elif opt == '--no-confirm': + elif opt == "--no-confirm": no_confirm = True - elif opt == '--examine-coverage': + elif opt == "--examine-coverage": examine_coverage = True - elif opt == '--next': - next = True + elif opt == "--next": + next_id = True - if [check, fix, examine_coverage, next].count(True) != 1: + if [check, fix, examine_coverage, next_id].count(True) != 1: print("usage: python error_codes.py --check | --fix [--no-confirm] | --examine-coverage | --next") exit(1) @@ -213,32 +239,34 @@ def main(argv): ["libevmasm", "liblangutil", "libsolc", "libsolidity", "libsolutil", "libyul", "solc"], [".h", ".cpp"] ) - used_ids = get_used_ids(source_file_names) + source_id_to_file_names = find_ids_in_source_files(source_file_names) ok = True - for id in sorted(used_ids): + for id in sorted(source_id_to_file_names): if len(id) != 4: print(f"ID {id} length != 4") ok = False if id[0] == "0": print(f"ID {id} starts with zero") ok = False - if used_ids[id] > 1: - print(f"ID {id} appears {used_ids[id]} times") + if len(source_id_to_file_names[id]) > 1: + print(f"ID {id} appears {len(source_id_to_file_names[id])} times") ok = False if examine_coverage: if not ok: print("Incorrect IDs have to be fixed before applying --examine-coverage") - res = examine_id_coverage(cwd, used_ids.keys()) + exit(1) + res = examine_id_coverage(cwd, source_id_to_file_names) exit(res) random.seed() - if next: + if next_id: if not ok: print("Incorrect IDs have to be fixed before applying --next") - available_ids = {str(id) for id in range(1000, 10000)} - used_ids.keys() + exit(1) + available_ids = {str(id) for id in range(1000, 10000)} - source_id_to_file_names.keys() next_id = get_next_id(available_ids) print(f"Next ID: {next_id}") exit(0) @@ -263,7 +291,10 @@ def main(argv): if answer not in "yY": exit(1) - fix_ids(used_ids, source_file_names) + # number of appearances for every id + source_id_to_count = { id: len(file_names) for id, file_names in source_id_to_file_names.items() } + + fix_ids_in_source_files(source_file_names, source_id_to_count) print("Fixing completed") exit(2) From 18fbbfa5ca4e62e6d371123de215e065c15e16e2 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Tue, 21 Jul 2020 14:37:22 +0200 Subject: [PATCH 67/71] Fuzzer: Count step by number of interpreted statements Co-authored-by: chriseth --- test/libyul/EwasmTranslationTest.cpp | 2 +- test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp | 10 +++++---- test/tools/yulInterpreter/Interpreter.cpp | 22 ++++++++++++++------ test/tools/yulInterpreter/Interpreter.h | 4 ++++ 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/test/libyul/EwasmTranslationTest.cpp b/test/libyul/EwasmTranslationTest.cpp index dd732f9a8..be9ed77d9 100644 --- a/test/libyul/EwasmTranslationTest.cpp +++ b/test/libyul/EwasmTranslationTest.cpp @@ -99,7 +99,7 @@ string EwasmTranslationTest::interpret() { InterpreterState state; state.maxTraceSize = 10000; - state.maxSteps = 100000; + state.maxSteps = 1000000; try { Interpreter::run(state, WasmDialect{}, *m_object->code); diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index 4c8ddb94f..c95b4db7f 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -97,15 +97,17 @@ DEFINE_PROTO_FUZZER(Program const& _input) EVMDialect::strictAssemblyForEVMObjects(version) ); - if (termReason == yulFuzzerUtil::TerminationReason::StepLimitReached) + if ( + termReason == yulFuzzerUtil::TerminationReason::StepLimitReached || + termReason == yulFuzzerUtil::TerminationReason::TraceLimitReached + ) return; stack.optimize(); - termReason = yulFuzzerUtil::interpret( + yulFuzzerUtil::interpret( os2, stack.parserResult()->code, - EVMDialect::strictAssemblyForEVMObjects(version), - (yul::test::yul_fuzzer::yulFuzzerUtil::maxSteps * 4) + EVMDialect::strictAssemblyForEVMObjects(version) ); bool isTraceEq = (os1.str() == os2.str()); diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index ba946e732..a8496793f 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -145,6 +145,11 @@ void Interpreter::operator()(ForLoop const& _forLoop) } while (evaluate(*_forLoop.condition) != 0) { + // Increment step for each loop iteration for loops with + // an empty body and post blocks to prevent a deadlock. + if (_forLoop.body.statements.size() == 0 && _forLoop.post.statements.size() == 0) + incrementStep(); + m_state.controlFlowState = ControlFlowState::Default; (*this)(_forLoop.body); if (m_state.controlFlowState == ControlFlowState::Break || m_state.controlFlowState == ControlFlowState::Leave) @@ -176,12 +181,6 @@ void Interpreter::operator()(Leave const&) void Interpreter::operator()(Block const& _block) { - m_state.numSteps++; - if (m_state.maxSteps > 0 && m_state.numSteps >= m_state.maxSteps) - { - m_state.trace.emplace_back("Interpreter execution step limit reached."); - throw StepLimitReached(); - } enterScope(_block); // Register functions. for (auto const& statement: _block.statements) @@ -193,6 +192,7 @@ void Interpreter::operator()(Block const& _block) for (auto const& statement: _block.statements) { + incrementStep(); visit(statement); if (m_state.controlFlowState != ControlFlowState::Default) break; @@ -235,6 +235,16 @@ void Interpreter::leaveScope() yulAssert(m_scope, ""); } +void Interpreter::incrementStep() +{ + m_state.numSteps++; + if (m_state.maxSteps > 0 && m_state.numSteps >= m_state.maxSteps) + { + m_state.trace.emplace_back("Interpreter execution step limit reached."); + throw StepLimitReached(); + } +} + void ExpressionEvaluator::operator()(Literal const& _literal) { static YulString const trueString("true"); diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index a52c098ed..00e02f6e2 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -154,6 +154,10 @@ private: void enterScope(Block const& _block); void leaveScope(); + /// Increment interpreter step count, throwing exception if step limit + /// is reached. + void incrementStep(); + Dialect const& m_dialect; InterpreterState& m_state; /// Values of variables. From e02878329dd3b73ad7a8dad039815793631f9ffe Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 21 Jul 2020 15:53:00 +0200 Subject: [PATCH 68/71] Prepare for 0.6.12 release. --- Changelog.md | 35 +++++++++++++++++++---------------- docs/bugs_by_version.json | 4 ++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Changelog.md b/Changelog.md index 990b78e2b..79cbf3e10 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,27 +1,30 @@ -### 0.6.12 (unreleased) +### 0.6.12 (2020-07-22) Language Features: + * NatSpec: Implement tag ``@inheritdoc`` to copy documentation from a specific base contract. * Wasm backend: Add ``i32.ctz``, ``i64.ctz``, ``i32.popcnt``, and ``i64.popcnt``. -Compiler Features: - * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. - * Peephole Optimizer: Remove unnecessary masking of tags. - * Yul EVM Code Transform: Free stack slots directly after visiting the right-hand-side of variable declarations instead of at the end of the statement only. - * NatSpec: Implement tag ``@inheritdoc`` to copy documentation from a specific contract. -Bugfixes: - * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. - * SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches. - * SMTChecker: Fix error in events with indices of type static array. - * SMTChecker: Fix internal error in sequential storage array pushes (``push().push()`). - * Type Checker: Fix overload resolution in combination with ``{value: ...}``. - * Type Checker: Fix internal compiler error related to oversized types. +Compiler Features: * Code Generator: Avoid double cleanup when copying to memory. - -Compiler Features: - * Build System: Update internal dependency of jsoncpp to 1.9.3. + * Code Generator: Evaluate ``keccak256`` of string literals at compile-time. * Optimizer: Add rule to remove shifts inside the byte opcode. * Peephole Optimizer: Add rule to remove swap after dup. + * Peephole Optimizer: Remove unnecessary masking of tags. + * Yul EVM Code Transform: Free stack slots directly after visiting the right-hand-side of variable declarations instead of at the end of the statement only. + + +Bugfixes: + * SMTChecker: Fix error in events with indices of type static array. + * SMTChecker: Fix internal error in sequential storage array pushes (``push().push()``). + * SMTChecker: Fix internal error when using bitwise operators on fixed bytes type. + * SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches. + * Type Checker: Fix internal compiler error related to oversized types. + * Type Checker: Fix overload resolution in combination with ``{value: ...}``. + + +Build System: + * Update internal dependency of jsoncpp to 1.9.3. ### 0.6.11 (2020-07-07) diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 000ab3ef8..fc9782c47 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1113,6 +1113,10 @@ "bugs": [], "released": "2020-07-07" }, + "0.6.12": { + "bugs": [], + "released": "2020-07-22" + }, "0.6.2": { "bugs": [ "MissingEscapingInFormatting", From 6f97e6153c57f879de93f39590293d794f10b391 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Wed, 17 Jun 2020 11:17:35 +0200 Subject: [PATCH 69/71] [yul] Adding support for accessing subobjects via `.` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil ƚliwak --- libevmasm/Assembly.cpp | 80 +++++++++++--- libevmasm/Assembly.h | 10 ++ libevmasm/AssemblyItem.cpp | 18 ++- libevmasm/AssemblyItem.h | 2 +- libyul/AsmAnalysis.cpp | 2 +- libyul/AssemblyStack.cpp | 2 +- libyul/CompilabilityChecker.cpp | 8 +- libyul/Object.cpp | 60 ++++++++-- libyul/Object.h | 21 +++- libyul/backends/evm/AbstractAssembly.h | 4 +- libyul/backends/evm/AsmCodeGen.cpp | 26 +++-- libyul/backends/evm/AsmCodeGen.h | 4 +- libyul/backends/evm/EVMAssembly.cpp | 4 +- libyul/backends/evm/EVMAssembly.h | 4 +- libyul/backends/evm/EVMDialect.cpp | 26 +++-- libyul/backends/evm/EVMObjectCompiler.cpp | 6 +- libyul/backends/evm/NoOutputAssembly.cpp | 4 +- libyul/backends/evm/NoOutputAssembly.h | 4 +- libyul/backends/wasm/EVMToEwasmTranslator.cpp | 2 +- .../input.json | 17 +++ .../output.json | 4 + test/libevmasm/Assembler.cpp | 19 ++++ test/libyul/Common.cpp | 2 +- .../libyul/objectCompiler/subObjectAccess.yul | 104 ++++++++++++++++++ 24 files changed, 357 insertions(+), 76 deletions(-) create mode 100644 test/cmdlineTests/standard_yul_object_invalid_sub/input.json create mode 100644 test/cmdlineTests/standard_yul_object_invalid_sub/output.json create mode 100644 test/libyul/objectCompiler/subObjectAccess.yul diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index b3a0dbde0..b1de71e3b 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -92,8 +92,8 @@ string locationFromSources(StringMap const& _sourceCodes, SourceLocation const& class Functionalizer { public: - Functionalizer (ostream& _out, string const& _prefix, StringMap const& _sourceCodes): - m_out(_out), m_prefix(_prefix), m_sourceCodes(_sourceCodes) + Functionalizer (ostream& _out, string const& _prefix, StringMap const& _sourceCodes, Assembly const& _assembly): + m_out(_out), m_prefix(_prefix), m_sourceCodes(_sourceCodes), m_assembly(_assembly) {} void feed(AssemblyItem const& _item) @@ -104,6 +104,9 @@ public: m_location = _item.location(); printLocation(); } + + string expression = _item.toAssemblyText(m_assembly); + if (!( _item.canBeFunctional() && _item.returnValues() <= 1 && @@ -111,10 +114,9 @@ public: )) { flush(); - m_out << m_prefix << (_item.type() == Tag ? "" : " ") << _item.toAssemblyText() << endl; + m_out << m_prefix << (_item.type() == Tag ? "" : " ") << expression << endl; return; } - string expression = _item.toAssemblyText(); if (_item.arguments() > 0) { expression += "("; @@ -160,13 +162,14 @@ private: ostream& m_out; string const& m_prefix; StringMap const& m_sourceCodes; + Assembly const& m_assembly; }; } void Assembly::assemblyStream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const { - Functionalizer f(_out, _prefix, _sourceCodes); + Functionalizer f(_out, _prefix, _sourceCodes, *this); for (auto const& i: m_items) f.feed(i); @@ -639,7 +642,7 @@ LinkerObject const& Assembly::assemble() const case PushSubSize: { assertThrow(i.data() <= numeric_limits::max(), AssemblyException, ""); - auto s = m_subs.at(static_cast(i.data()))->assemble().bytecode.size(); + auto s = subAssemblyById(static_cast(i.data()))->assemble().bytecode.size(); i.setPushedValue(u256(s)); uint8_t b = max(1, util::bytesRequired(s)); ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b); @@ -707,25 +710,20 @@ LinkerObject const& Assembly::assemble() const // Append an INVALID here to help tests find miscompilation. ret.bytecode.push_back(uint8_t(Instruction::INVALID)); - for (size_t i = 0; i < m_subs.size(); ++i) + for (auto const& [subIdPath, bytecodeOffset]: subRef) { - auto references = subRef.equal_range(i); - if (references.first == references.second) - continue; - for (auto ref = references.first; ref != references.second; ++ref) - { - bytesRef r(ret.bytecode.data() + ref->second, bytesPerDataRef); - toBigEndian(ret.bytecode.size(), r); - } - ret.append(m_subs[i]->assemble()); + bytesRef r(ret.bytecode.data() + bytecodeOffset, bytesPerDataRef); + toBigEndian(ret.bytecode.size(), r); + ret.append(subAssemblyById(subIdPath)->assemble()); } + for (auto const& i: tagRef) { size_t subId; size_t tagId; tie(subId, tagId) = i.second; assertThrow(subId == numeric_limits::max() || subId < m_subs.size(), AssemblyException, "Invalid sub id"); - std::vector const& tagPositions = + vector const& tagPositions = subId == numeric_limits::max() ? m_tagPositionsInBytecode : m_subs[subId]->m_tagPositionsInBytecode; @@ -758,3 +756,51 @@ LinkerObject const& Assembly::assemble() const } return ret; } + +vector Assembly::decodeSubPath(size_t _subObjectId) const +{ + if (_subObjectId < m_subs.size()) + return {_subObjectId}; + + auto subIdPathIt = find_if( + m_subPaths.begin(), + m_subPaths.end(), + [_subObjectId](auto const& subId) { return subId.second == _subObjectId; } + ); + + assertThrow(subIdPathIt != m_subPaths.end(), AssemblyException, ""); + return subIdPathIt->first; +} + +size_t Assembly::encodeSubPath(vector const& _subPath) +{ + assertThrow(!_subPath.empty(), AssemblyException, ""); + if (_subPath.size() == 1) + { + assertThrow(_subPath[0] < m_subs.size(), AssemblyException, ""); + return _subPath[0]; + } + + if (m_subPaths.find(_subPath) == m_subPaths.end()) + { + size_t objectId = numeric_limits::max() - m_subPaths.size(); + assertThrow(objectId >= m_subs.size(), AssemblyException, ""); + m_subPaths[_subPath] = objectId; + } + + return m_subPaths[_subPath]; +} + +Assembly const* Assembly::subAssemblyById(size_t _subId) const +{ + vector subIds = decodeSubPath(_subId); + Assembly const* currentAssembly = this; + for (size_t currentSubId: subIds) + { + currentAssembly = currentAssembly->m_subs.at(currentSubId).get(); + assertThrow(currentAssembly, AssemblyException, ""); + } + + assertThrow(currentAssembly != this, AssemblyException, ""); + return currentAssembly; +} diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index 312521b71..354304dcb 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -146,6 +146,9 @@ public: /// Mark this assembly as invalid. Calling ``assemble`` on it will throw. void markAsInvalid() { m_invalid = true; } + std::vector decodeSubPath(size_t _subObjectId) const; + size_t encodeSubPath(std::vector const& _subPath); + protected: /// Does the same operations as @a optimise, but should only be applied to a sub and /// returns the replaced tags. Also takes an argument containing the tags of this assembly @@ -166,6 +169,9 @@ private: static std::string toStringInHex(u256 _value); bool m_invalid = false; + + Assembly const* subAssemblyById(size_t _subId) const; + protected: /// 0 is reserved for exception unsigned m_usedTags = 1; @@ -179,6 +185,10 @@ protected: std::map m_libraries; ///< Identifiers of libraries to be linked. std::map m_immutables; ///< Identifiers of immutables. + /// Map from a vector representing a path to a particular sub assembly to sub assembly id. + /// This map is used only for sub-assemblies which are not direct sub-assemblies (where path is having more than one value). + std::map, size_t> m_subPaths; + mutable LinkerObject m_assembledObject; mutable std::vector m_tagPositionsInBytecode; diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 80d34f57c..e70e844d6 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -18,7 +18,10 @@ #include +#include + #include +#include #include #include @@ -170,7 +173,7 @@ string AssemblyItem::getJumpTypeAsString() const } } -string AssemblyItem::toAssemblyText() const +string AssemblyItem::toAssemblyText(Assembly const& _assembly) const { string text; switch (type()) @@ -208,11 +211,18 @@ string AssemblyItem::toAssemblyText() const text = string("data_") + util::toHex(data()); break; case PushSub: - text = string("dataOffset(sub_") + to_string(static_cast(data())) + ")"; - break; case PushSubSize: - text = string("dataSize(sub_") + to_string(static_cast(data())) + ")"; + { + vector subPathComponents; + for (size_t subPathComponentId: _assembly.decodeSubPath(static_cast(data()))) + subPathComponents.emplace_back("sub_" + to_string(subPathComponentId)); + text = + (type() == PushSub ? "dataOffset"s : "dataSize"s) + + "(" + + solidity::util::joinHumanReadable(subPathComponents, ".") + + ")"; break; + } case PushProgramSize: text = string("bytecodeSize"); break; diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index dd65b109f..ac3a2c9d8 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -152,7 +152,7 @@ public: void setPushedValue(u256 const& _value) const { m_pushedValue = std::make_shared(_value); } u256 const* pushedValue() const { return m_pushedValue.get(); } - std::string toAssemblyText() const; + std::string toAssemblyText(Assembly const& _assembly) const; size_t m_modifierDepth = 0; diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index e85ecd876..934cff0a4 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -72,7 +72,7 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(Dialect const& _dialect, errors, _dialect, {}, - _object.dataNames() + _object.qualifiedDataNames() ).analyze(*_object.code); yulAssert(success && !errors.hasErrors(), "Invalid assembly/yul code."); return analysisInfo; diff --git a/libyul/AssemblyStack.cpp b/libyul/AssemblyStack.cpp index b8824740d..542de51d9 100644 --- a/libyul/AssemblyStack.cpp +++ b/libyul/AssemblyStack.cpp @@ -138,7 +138,7 @@ bool AssemblyStack::analyzeParsed(Object& _object) m_errorReporter, languageToDialect(m_language, m_evmVersion), {}, - _object.dataNames() + _object.qualifiedDataNames() ); bool success = analyzer.analyze(*_object.code); for (auto& subNode: _object.subObjects) diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 0d80a510f..2a99e3c79 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -39,7 +39,7 @@ map CompilabilityChecker::run( bool _optimizeStackAllocation ) { - if (EVMDialect const* evmDialect = dynamic_cast(&_dialect)) + if (auto const* evmDialect = dynamic_cast(&_dialect)) { NoOutputEVMDialect noOutputDialect(*evmDialect); @@ -48,8 +48,10 @@ map CompilabilityChecker::run( BuiltinContext builtinContext; builtinContext.currentObject = &_object; - for (auto name: _object.dataNames()) - builtinContext.subIDs[name] = 1; + if (!_object.name.empty()) + builtinContext.subIDs[_object.name] = 1; + for (auto const& subNode: _object.subObjects) + builtinContext.subIDs[subNode->name] = 1; NoOutputAssembly assembly; CodeTransform transform( assembly, diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 1086e38cf..72206c4b6 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -24,9 +24,10 @@ #include #include -#include #include +#include +#include #include using namespace std; @@ -62,13 +63,54 @@ string Object::toString(Dialect const* _dialect) const return "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}"; } -set Object::dataNames() const +set Object::qualifiedDataNames() const { - set names; - names.insert(name); - for (auto const& subObject: subIndexByName) - names.insert(subObject.first); - // The empty name is not valid - names.erase(YulString{}); - return names; + set qualifiedNames = name.empty() ? set{} : set{name}; + for (shared_ptr const& subObjectNode: subObjects) + { + yulAssert(qualifiedNames.count(subObjectNode->name) == 0, ""); + qualifiedNames.insert(subObjectNode->name); + if (auto const* subObject = dynamic_cast(subObjectNode.get())) + for (YulString const& subSubObj: subObject->qualifiedDataNames()) + if (subObject->name != subSubObj) + { + yulAssert(qualifiedNames.count(YulString{subObject->name.str() + "." + subSubObj.str()}) == 0, ""); + qualifiedNames.insert(YulString{subObject->name.str() + "." + subSubObj.str()}); + } + } + + yulAssert(qualifiedNames.count(YulString{}) == 0, ""); + qualifiedNames.erase(YulString{}); + return qualifiedNames; +} + +vector Object::pathToSubObject(YulString _qualifiedName) const +{ + yulAssert(_qualifiedName != name, ""); + yulAssert(subIndexByName.count(name) == 0, ""); + + if (boost::algorithm::starts_with(_qualifiedName.str(), name.str() + ".")) + _qualifiedName = YulString{_qualifiedName.str().substr(name.str().length() + 1)}; + yulAssert(!_qualifiedName.empty(), ""); + + vector subObjectPathComponents; + boost::algorithm::split(subObjectPathComponents, _qualifiedName.str(), boost::is_any_of(".")); + + vector path; + Object const* object = this; + for (string const& currentSubObjectName: subObjectPathComponents) + { + yulAssert(!currentSubObjectName.empty(), ""); + auto subIndexIt = object->subIndexByName.find(YulString{currentSubObjectName}); + yulAssert( + subIndexIt != object->subIndexByName.end(), + "Assembly object <" + _qualifiedName.str() + "> not found or does not contain code." + ); + object = dynamic_cast(object->subObjects[subIndexIt->second].get()); + yulAssert(object, "Assembly object <" + _qualifiedName.str() + "> not found or does not contain code."); + yulAssert(object->subId != numeric_limits::max(), ""); + path.push_back({object->subId}); + } + + return path; } diff --git a/libyul/Object.h b/libyul/Object.h index 3602e7177..deb52eb25 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -44,6 +44,8 @@ struct ObjectNode virtual std::string toString(Dialect const* _dialect) const = 0; std::string toString() { return toString(nullptr); } + /// Name of the object. + /// Can be empty since .yul files can also just contain code, without explicitly placing it in an object. YulString name; }; @@ -68,8 +70,23 @@ public: std::string toString(Dialect const* _dialect) const override; /// @returns the set of names of data objects accessible from within the code of - /// this object. - std::set dataNames() const; + /// this object, including the name of object itself + std::set qualifiedDataNames() const; + + /// @returns vector of subIDs if possible to reach subobject with @a _qualifiedName, throws otherwise + /// For "B.C" should return vector of two values if success (subId of B and subId of C in B). + /// In object "A" if called for "A.B" will return only one value (subId for B) + /// will return empty vector for @a _qualifiedName that equals to object name. + /// Example: + /// A1{ B2{ C3, D3 }, E2{ F3{ G4, K4, H4{ I5 } } } } + /// pathToSubObject("A1.E2.F3.H4") == {1, 0, 2} + /// pathToSubObject("E2.F3.H4") == {1, 0, 2} + /// pathToSubObject("A1.E2") == {1} + /// The path must not lead to a @a Data object (will throw in that case). + std::vector pathToSubObject(YulString _qualifiedName) const; + + /// sub id for object if it is subobject of another object, max value if it is not subobject + size_t subId = std::numeric_limits::max(); std::shared_ptr code; std::vector> subObjects; diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 9ff0c3846..a8327c346 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -102,9 +102,9 @@ public: /// Creates a new sub-assembly, which can be referenced using dataSize and dataOffset. virtual std::pair, SubID> createSubAssembly() = 0; /// Appends the offset of the given sub-assembly or data. - virtual void appendDataOffset(SubID _sub) = 0; + virtual void appendDataOffset(std::vector const& _subPath) = 0; /// Appends the size of the given sub-assembly or data. - virtual void appendDataSize(SubID _sub) = 0; + virtual void appendDataSize(std::vector const& _subPath) = 0; /// Appends the given data to the assembly and returns its ID. virtual SubID appendData(bytes const& _data) = 0; diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index c2204ab95..15d646755 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -147,22 +147,28 @@ pair, AbstractAssembly::SubID> EthAssemblyAdapter:: return {make_shared(*assembly), static_cast(sub.data())}; } -void EthAssemblyAdapter::appendDataOffset(AbstractAssembly::SubID _sub) +void EthAssemblyAdapter::appendDataOffset(vector const& _subPath) { - auto it = m_dataHashBySubId.find(_sub); - if (it == m_dataHashBySubId.end()) - m_assembly.pushSubroutineOffset(_sub); - else + if (auto it = m_dataHashBySubId.find(_subPath[0]); it != m_dataHashBySubId.end()) + { + yulAssert(_subPath.size() == 1, ""); m_assembly << evmasm::AssemblyItem(evmasm::PushData, it->second); + return; + } + + m_assembly.pushSubroutineOffset(m_assembly.encodeSubPath(_subPath)); } -void EthAssemblyAdapter::appendDataSize(AbstractAssembly::SubID _sub) +void EthAssemblyAdapter::appendDataSize(vector const& _subPath) { - auto it = m_dataHashBySubId.find(_sub); - if (it == m_dataHashBySubId.end()) - m_assembly.pushSubroutineSize(static_cast(_sub)); - else + if (auto it = m_dataHashBySubId.find(_subPath[0]); it != m_dataHashBySubId.end()) + { + yulAssert(_subPath.size() == 1, ""); m_assembly << u256(m_assembly.data(h256(it->second)).size()); + return; + } + + m_assembly.pushSubroutineSize(m_assembly.encodeSubPath(_subPath)); } AbstractAssembly::SubID EthAssemblyAdapter::appendData(bytes const& _data) diff --git a/libyul/backends/evm/AsmCodeGen.h b/libyul/backends/evm/AsmCodeGen.h index 3192a9133..ee56f7fcb 100644 --- a/libyul/backends/evm/AsmCodeGen.h +++ b/libyul/backends/evm/AsmCodeGen.h @@ -58,8 +58,8 @@ public: void appendReturnsub(int, int) override; void appendAssemblySize() override; std::pair, SubID> createSubAssembly() override; - void appendDataOffset(SubID _sub) override; - void appendDataSize(SubID _sub) override; + void appendDataOffset(std::vector const& _subPath) override; + void appendDataSize(std::vector const& _subPath) override; SubID appendData(bytes const& _data) override; void appendImmutable(std::string const& _identifier) override; diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index a4a1d0a27..99945383e 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -202,12 +202,12 @@ pair, AbstractAssembly::SubID> EVMAssembly::createS return {}; } -void EVMAssembly::appendDataOffset(AbstractAssembly::SubID) +void EVMAssembly::appendDataOffset(vector const&) { yulAssert(false, "Data not implemented."); } -void EVMAssembly::appendDataSize(AbstractAssembly::SubID) +void EVMAssembly::appendDataSize(vector const&) { yulAssert(false, "Data not implemented."); } diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index f67aad8b8..6e6878476 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -80,8 +80,8 @@ public: /// Append the assembled size as a constant. void appendAssemblySize() override; std::pair, SubID> createSubAssembly() override; - void appendDataOffset(SubID _sub) override; - void appendDataSize(SubID _sub) override; + void appendDataOffset(std::vector const& _subPath) override; + void appendDataSize(std::vector const& _subPath) override; SubID appendData(bytes const& _data) override; void appendImmutable(std::string const& _identifier) override; diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 4b9acb0c7..c552b6e22 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -144,7 +144,7 @@ map createBuiltins(langutil::EVMVersion _evmVe FunctionCall const& _call, AbstractAssembly& _assembly, BuiltinContext& _context, - std::function + std::function const& ) { yulAssert(_context.currentObject, "No object available."); yulAssert(_call.arguments.size() == 1, ""); @@ -154,18 +154,19 @@ map createBuiltins(langutil::EVMVersion _evmVe _assembly.appendAssemblySize(); else { - yulAssert( - _context.subIDs.count(dataName) != 0, - "Could not find assembly object <" + dataName.str() + ">." - ); - _assembly.appendDataSize(_context.subIDs.at(dataName)); + vector subIdPath = + _context.subIDs.count(dataName) == 0 ? + _context.currentObject->pathToSubObject(dataName) : + vector{_context.subIDs.at(dataName)}; + yulAssert(!subIdPath.empty(), "Could not find assembly object <" + dataName.str() + ">."); + _assembly.appendDataSize(subIdPath); } })); builtins.emplace(createFunction("dataoffset", 1, 1, SideEffects{}, {true}, []( FunctionCall const& _call, AbstractAssembly& _assembly, BuiltinContext& _context, - std::function + std::function const& ) { yulAssert(_context.currentObject, "No object available."); yulAssert(_call.arguments.size() == 1, ""); @@ -175,11 +176,12 @@ map createBuiltins(langutil::EVMVersion _evmVe _assembly.appendConstant(0); else { - yulAssert( - _context.subIDs.count(dataName) != 0, - "Could not find assembly object <" + dataName.str() + ">." - ); - _assembly.appendDataOffset(_context.subIDs.at(dataName)); + vector subIdPath = + _context.subIDs.count(dataName) == 0 ? + _context.currentObject->pathToSubObject(dataName) : + vector{_context.subIDs.at(dataName)}; + yulAssert(!subIdPath.empty(), "Could not find assembly object <" + dataName.str() + ">."); + _assembly.appendDataOffset(subIdPath); } })); builtins.emplace(createFunction( diff --git a/libyul/backends/evm/EVMObjectCompiler.cpp b/libyul/backends/evm/EVMObjectCompiler.cpp index 91f23b596..5eb83a6a8 100644 --- a/libyul/backends/evm/EVMObjectCompiler.cpp +++ b/libyul/backends/evm/EVMObjectCompiler.cpp @@ -26,6 +26,7 @@ #include #include +#include using namespace solidity::yul; using namespace std; @@ -41,11 +42,12 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize) BuiltinContext context; context.currentObject = &_object; - for (auto& subNode: _object.subObjects) - if (Object* subObject = dynamic_cast(subNode.get())) + for (auto const& subNode: _object.subObjects) + if (auto* subObject = dynamic_cast(subNode.get())) { auto subAssemblyAndID = m_assembly.createSubAssembly(); context.subIDs[subObject->name] = subAssemblyAndID.second; + subObject->subId = subAssemblyAndID.second; compile(*subObject, *subAssemblyAndID.first, m_dialect, m_evm15, _optimize); } else diff --git a/libyul/backends/evm/NoOutputAssembly.cpp b/libyul/backends/evm/NoOutputAssembly.cpp index 0d840ef66..733795523 100644 --- a/libyul/backends/evm/NoOutputAssembly.cpp +++ b/libyul/backends/evm/NoOutputAssembly.cpp @@ -132,12 +132,12 @@ pair, AbstractAssembly::SubID> NoOutputAssembly::cr return {}; } -void NoOutputAssembly::appendDataOffset(AbstractAssembly::SubID) +void NoOutputAssembly::appendDataOffset(std::vector const&) { appendInstruction(evmasm::Instruction::PUSH1); } -void NoOutputAssembly::appendDataSize(AbstractAssembly::SubID) +void NoOutputAssembly::appendDataSize(std::vector const&) { appendInstruction(evmasm::Instruction::PUSH1); } diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index 9f853032b..b2153e42a 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -68,8 +68,8 @@ public: void appendAssemblySize() override; std::pair, SubID> createSubAssembly() override; - void appendDataOffset(SubID _sub) override; - void appendDataSize(SubID _sub) override; + void appendDataOffset(std::vector const& _subPath) override; + void appendDataSize(std::vector const& _subPath) override; SubID appendData(bytes const& _data) override; void appendImmutable(std::string const& _identifier) override; diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index abb898828..dc180b240 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -1249,7 +1249,7 @@ Object EVMToEwasmTranslator::run(Object const& _object) ErrorList errors; ErrorReporter errorReporter(errors); - AsmAnalyzer analyzer(*ret.analysisInfo, errorReporter, WasmDialect::instance(), {}, _object.dataNames()); + AsmAnalyzer analyzer(*ret.analysisInfo, errorReporter, WasmDialect::instance(), {}, _object.qualifiedDataNames()); if (!analyzer.analyze(*ret.code)) { string message = "Invalid code generated after EVM to wasm translation.\n"; diff --git a/test/cmdlineTests/standard_yul_object_invalid_sub/input.json b/test/cmdlineTests/standard_yul_object_invalid_sub/input.json new file mode 100644 index 000000000..ccc142d25 --- /dev/null +++ b/test/cmdlineTests/standard_yul_object_invalid_sub/input.json @@ -0,0 +1,17 @@ +{ + "language": "Yul", + "sources": + { + "A": + { + "content": "object \"NamedObject\" { code { let x := dataoffset(\"NamedObject.\") sstore(add(x, 0), 0) } object \"OtherObject\" { code { revert(0, 0) } } }" + } + }, + "settings": + { + "outputSelection": + { + "*": { "*": ["*"], "": [ "*" ] } + } + } +} \ No newline at end of file diff --git a/test/cmdlineTests/standard_yul_object_invalid_sub/output.json b/test/cmdlineTests/standard_yul_object_invalid_sub/output.json new file mode 100644 index 000000000..5008d4916 --- /dev/null +++ b/test/cmdlineTests/standard_yul_object_invalid_sub/output.json @@ -0,0 +1,4 @@ +{"errors":[{"component":"general","formattedMessage":"A:1:40: TypeError: Unknown data object \"NamedObject.\". +object \"NamedObject\" { code { let x := dataoffset(\"NamedObject.\") sstore(add(x, 0), 0) } object \"OtherObject\" { code { revert(0, 0) } } } + ^--------^ +","message":"Unknown data object \"NamedObject.\".","severity":"error","sourceLocation":{"end":49,"file":"A","start":39},"type":"TypeError"}]} diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index c2140ace6..c93d7b58d 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -29,6 +29,7 @@ #include #include #include +#include using namespace std; using namespace solidity::langutil; @@ -254,6 +255,24 @@ BOOST_AUTO_TEST_CASE(immutable) ); } +BOOST_AUTO_TEST_CASE(subobject_encode_decode) +{ + Assembly assembly; + + shared_ptr subAsmPtr = make_shared(); + shared_ptr subSubAsmPtr = make_shared(); + + assembly.appendSubroutine(subAsmPtr); + subAsmPtr->appendSubroutine(subSubAsmPtr); + + BOOST_CHECK(assembly.encodeSubPath({0}) == 0); + BOOST_REQUIRE_THROW(assembly.encodeSubPath({1}), solidity::evmasm::AssemblyException); + BOOST_REQUIRE_THROW(assembly.decodeSubPath(1), solidity::evmasm::AssemblyException); + + vector subPath{0, 0}; + BOOST_CHECK(assembly.decodeSubPath(assembly.encodeSubPath(subPath)) == subPath); +} + BOOST_AUTO_TEST_SUITE_END() } // end namespaces diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index 57ee7ffa6..b0b07a8fb 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -90,7 +90,7 @@ pair, shared_ptr> yul::test::parse( if (!parserResult->code || errorReporter.hasErrors()) return {}; shared_ptr analysisInfo = make_shared(); - AsmAnalyzer analyzer(*analysisInfo, errorReporter, _dialect, {}, parserResult->dataNames()); + AsmAnalyzer analyzer(*analysisInfo, errorReporter, _dialect, {}, parserResult->qualifiedDataNames()); // TODO this should be done recursively. if (!analyzer.analyze(*parserResult->code) || errorReporter.hasErrors()) return {}; diff --git a/test/libyul/objectCompiler/subObjectAccess.yul b/test/libyul/objectCompiler/subObjectAccess.yul new file mode 100644 index 000000000..4fddc2483 --- /dev/null +++ b/test/libyul/objectCompiler/subObjectAccess.yul @@ -0,0 +1,104 @@ +object "A" { + code { + pop(dataoffset("A")) + pop(datasize("A")) + pop(dataoffset("B")) + pop(datasize("B")) + pop(dataoffset("B.C")) + pop(datasize("B.C")) + pop(dataoffset("B.E")) + pop(datasize("B.E")) + pop(dataoffset("B.C.D")) + pop(datasize("B.C.D")) + } + + data "data1" "Hello, World!" + + object "B" { + code { + pop(dataoffset("C")) + pop(datasize("C")) + pop(dataoffset("E")) + pop(datasize("E")) + pop(dataoffset("C.D")) + pop(datasize("C.D")) + } + object "C" { + code { + pop(dataoffset("D")) + pop(datasize("D")) + } + object "D" { + code { + invalid() + } + } + } + object "E" { + code { + invalid() + } + } + } +} +// ---- +// Assembly: +// /* "source":26:46 */ +// pop(0x00) +// /* "source":51:69 */ +// pop(bytecodeSize) +// /* "source":74:94 */ +// pop(dataOffset(sub_0)) +// /* "source":99:117 */ +// pop(dataSize(sub_0)) +// /* "source":122:144 */ +// pop(dataOffset(sub_0.sub_0)) +// /* "source":149:169 */ +// pop(dataSize(sub_0.sub_0)) +// /* "source":174:196 */ +// pop(dataOffset(sub_0.sub_1)) +// /* "source":201:221 */ +// pop(dataSize(sub_0.sub_1)) +// /* "source":226:250 */ +// pop(dataOffset(sub_0.sub_0.sub_0)) +// /* "source":255:277 */ +// pop(dataSize(sub_0.sub_0.sub_0)) +// stop +// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421 +// +// sub_0: assembly { +// /* "source":347:367 */ +// pop(dataOffset(sub_0)) +// /* "source":374:392 */ +// pop(dataSize(sub_0)) +// /* "source":399:419 */ +// pop(dataOffset(sub_1)) +// /* "source":426:444 */ +// pop(dataSize(sub_1)) +// /* "source":451:473 */ +// pop(dataOffset(sub_0.sub_0)) +// /* "source":480:500 */ +// pop(dataSize(sub_0.sub_0)) +// stop +// +// sub_0: assembly { +// /* "source":545:565 */ +// pop(dataOffset(sub_0)) +// /* "source":574:592 */ +// pop(dataSize(sub_0)) +// stop +// +// sub_0: assembly { +// /* "source":645:654 */ +// invalid +// } +// } +// +// sub_1: assembly { +// /* "source":717:726 */ +// invalid +// } +// } +// Bytecode: 600050604650601f50601d50603e50600850603d50600150603c50600150fe601350600850601b50600150601c50600150fe600750600150fefefefefefe600750600150fefe +// Opcodes: PUSH1 0x0 POP PUSH1 0x46 POP PUSH1 0x1F POP PUSH1 0x1D POP PUSH1 0x3E POP PUSH1 0x8 POP PUSH1 0x3D POP PUSH1 0x1 POP PUSH1 0x3C POP PUSH1 0x1 POP INVALID PUSH1 0x13 POP PUSH1 0x8 POP PUSH1 0x1B POP PUSH1 0x1 POP PUSH1 0x1C POP PUSH1 0x1 POP INVALID PUSH1 0x7 POP PUSH1 0x1 POP INVALID INVALID INVALID INVALID INVALID INVALID PUSH1 0x7 POP PUSH1 0x1 POP INVALID INVALID +// SourceMappings: 26:20:0:-:0;;51:18;;74:20;;99:18;;122:22;;149:20;;174:22;;201:20;;226:24;;255:22; From 546e9af24dd6b6bda046a3903124960deb532e17 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Wed, 15 Jul 2020 17:26:51 +0200 Subject: [PATCH 70/71] [Sol->Yul] Supporting .runtimeCode --- libsolidity/codegen/ir/IRGeneratorForStatements.cpp | 3 +-- .../semanticTests/various/code_access_content.sol | 3 ++- .../semanticTests/various/code_access_runtime.sol | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 0489f3f68..d28ee2e9c 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1491,7 +1491,6 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess) solAssert(false, "Blockhash has been removed."); else if (member == "creationCode" || member == "runtimeCode") { - solUnimplementedAssert(member != "runtimeCode", ""); TypePointer arg = dynamic_cast(*_memberAccess.expression().annotation().type).typeArgument(); ContractDefinition const& contract = dynamic_cast(*arg).contractDefinition(); m_context.subObjectsCreated().insert(&contract); @@ -1503,7 +1502,7 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess) )") ("allocationFunction", m_utils.allocationFunction()) ("size", m_context.newYulVariable()) - ("objectName", IRNames::creationObject(contract)) + ("objectName", IRNames::creationObject(contract) + (member == "runtimeCode" ? "." + IRNames::runtimeObject(contract) : "")) ("result", IRVariable(_memberAccess).commaSeparatedList()).render(); } else if (member == "name") diff --git a/test/libsolidity/semanticTests/various/code_access_content.sol b/test/libsolidity/semanticTests/various/code_access_content.sol index 2c115d6c8..c0a74fe1a 100644 --- a/test/libsolidity/semanticTests/various/code_access_content.sol +++ b/test/libsolidity/semanticTests/various/code_access_content.sol @@ -36,7 +36,8 @@ contract C { return true; } } - +// ==== +// compileViaYul: also // ---- // testRuntime() -> true // testCreation() -> true diff --git a/test/libsolidity/semanticTests/various/code_access_runtime.sol b/test/libsolidity/semanticTests/various/code_access_runtime.sol index cc1401c6f..36264f84d 100644 --- a/test/libsolidity/semanticTests/various/code_access_runtime.sol +++ b/test/libsolidity/semanticTests/various/code_access_runtime.sol @@ -10,18 +10,18 @@ contract D { } } - contract C { function test() public returns (uint256) { - D d = new D(); - bytes32 hash; - assembly { hash := extcodehash(d) } - assert(hash == keccak256(type(D).runtimeCode)); - return 42; + D d = new D(); + bytes32 hash; + assembly { hash := extcodehash(d) } + assert(hash == keccak256(type(D).runtimeCode)); + return 42; } } // ==== // EVMVersion: >=constantinople +// compileViaYul: also // ---- // test() -> 42 From 7e0a291fac680fc9af269b4f7d8f3f4c51a4caee Mon Sep 17 00:00:00 2001 From: a3d4 Date: Fri, 17 Jul 2020 00:37:16 +0200 Subject: [PATCH 71/71] Add "Only one receive function is allowed"-error to syntax tests --- .../fallback_function_twice.sol} | 0 .../duplicateFunctions/receive_function_thrice.sol | 8 ++++++++ 2 files changed, 8 insertions(+) rename test/libsolidity/syntaxTests/{nameAndTypeResolution/078_fallback_function_twice.sol => duplicateFunctions/fallback_function_twice.sol} (100%) create mode 100644 test/libsolidity/syntaxTests/duplicateFunctions/receive_function_thrice.sol diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol b/test/libsolidity/syntaxTests/duplicateFunctions/fallback_function_twice.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol rename to test/libsolidity/syntaxTests/duplicateFunctions/fallback_function_twice.sol diff --git a/test/libsolidity/syntaxTests/duplicateFunctions/receive_function_thrice.sol b/test/libsolidity/syntaxTests/duplicateFunctions/receive_function_thrice.sol new file mode 100644 index 000000000..2160dc055 --- /dev/null +++ b/test/libsolidity/syntaxTests/duplicateFunctions/receive_function_thrice.sol @@ -0,0 +1,8 @@ +contract C { + receive() external payable { } + receive() external payable { } + receive() external payable { } +} +// ---- +// DeclarationError 4046: (52-82): Only one receive function is allowed. +// DeclarationError 4046: (87-117): Only one receive function is allowed.