diff --git a/.circleci/build_win.ps1 b/.circleci/build_win.ps1 index 9be967c97..730bb6319 100644 --- a/.circleci/build_win.ps1 +++ b/.circleci/build_win.ps1 @@ -20,7 +20,7 @@ cd build $boost_dir=(Resolve-Path $PSScriptRoot\..\deps\boost\lib\cmake\Boost-*) ..\deps\cmake\bin\cmake -G "Visual Studio 16 2019" -DBoost_DIR="$boost_dir\" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_INSTALL_PREFIX="$PSScriptRoot\..\upload" -DUSE_Z3=OFF .. if ( -not $? ) { throw "CMake configure failed." } -msbuild solidity.sln /p:Configuration=Release /m:5 /v:minimal +msbuild solidity.sln /p:Configuration=Release /m:10 /v:minimal if ( -not $? ) { throw "Build failed." } -..\deps\cmake\bin\cmake --build . -j 5 --target install --config Release +..\deps\cmake\bin\cmake --build . -j 10 --target install --config Release if ( -not $? ) { throw "Install target failed." } diff --git a/.circleci/config.yml b/.circleci/config.yml index 72434ea15..cda6e5890 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,20 +9,20 @@ version: 2.1 parameters: ubuntu-2004-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-8 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:9c3cdfc1d573d1ca3edacd892590a9a83487a1f746a6ca2093d7e009818c5179" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-9 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:3d8a912e8e78e98cd217955d06d98608ad60adc67728d4c3a569991235fa1abb" ubuntu-2004-clang-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004.clang-8 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:61232feea23c8c57e82cf5fae890f8b86bbec353cdc04f2fcba383ca589e1d8b" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004.clang-9 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:a1ba002cae17279d1396a898b04e4e9c45602ad881295db3e2f484a7e24f6f43" ubuntu-1604-clang-ossfuzz-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-13 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:c26a7ffc9fc243a4ec3105b9dc1edcdd964ad0e9665c83172b7ebda74bbf3021" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-14 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:f353823cce2f6cd2f9f1459d86cd76fdfc551a0261d87626615ea6c1d8f90587" emscripten-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:emscripten-7 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:9ffcd0944433fe100e9433f2aa9ba5c21e096e758ad8a05a4a76feaed3d1f463" + # solbuildpackpusher/solidity-buildpack-deps:emscripten-8 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:842d6074e0e7e5355c89122c1cafc1fdb59696596750e7d56e5f35c0d883ad59" evm-version: type: string default: london @@ -44,10 +44,17 @@ commands: name: "Gitter notification" when: << parameters.condition >> command: | - [[ $CI_PULL_REQUEST == "" ]] || { echo "Running on a PR - notification skipped."; exit 0; } + # FIXME: Checking $CIRCLE_PULL_REQUEST would be better than hard-coding branch names + # but it's broken. CircleCI associates runs on develop/breaking with random old PRs. + [[ $CIRCLE_BRANCH == develop || $CIRCLE_BRANCH == breaking ]] || { echo "Running on a PR or a feature branch - notification skipped."; exit 0; } - [[ "<< parameters.event >>" == "failure" ]] && message=" ❌ Nightly job **${CIRCLE_JOB}** failed on **${CIRCLE_BRANCH}**. Please see [build #${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}) for details." - [[ "<< parameters.event >>" == "success" ]] && message=" ✅ Nightly job **${CIRCLE_JOB}** succeeded on **${CIRCLE_BRANCH}**. Please see [build #${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}) for details." + # Workflow name is not exposed as an env variable. Has to be queried from the API. + # The name is not critical so if anything fails, use the raw workflow ID as a fallback. + workflow_info=$(curl --silent "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}") || true + workflow_name=$(echo "$workflow_info" | grep -E '"\s*name"\s*:\s*".*"' | cut -d \" -f 4 || echo "$CIRCLE_WORKFLOW_ID") + + [[ "<< parameters.event >>" == "failure" ]] && message=" ❌ [${workflow_name}] Job **${CIRCLE_JOB}** failed on **${CIRCLE_BRANCH}**. Please see [build ${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}) for details." + [[ "<< parameters.event >>" == "success" ]] && message=" ✅ [${workflow_name}] Job **${CIRCLE_JOB}** succeeded on **${CIRCLE_BRANCH}**. Please see [build ${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}) for details." curl "https://api.gitter.im/v1/rooms/${GITTER_NOTIFY_ROOM_ID}/chatMessages" \ --request POST \ @@ -219,6 +226,14 @@ defaults: - image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >> environment: TERM: xterm + MAKEFLAGS: -j 3 + + - base_ubuntu1604_clang_small: &base_ubuntu1604_clang_small + <<: *base_ubuntu1604_clang + resource_class: small + environment: + TERM: xterm + MAKEFLAGS: -j 2 - base_ubuntu2004_clang: &base_ubuntu2004_clang docker: @@ -229,20 +244,44 @@ defaults: CXX: clang++ MAKEFLAGS: -j 3 - - base_ubuntu2004_clang_xlarge: &base_ubuntu2004_clang_xlarge + - base_ubuntu2004_clang_small: &base_ubuntu2004_clang_small <<: *base_ubuntu2004_clang - resource_class: xlarge + resource_class: small environment: TERM: xterm CC: clang CXX: clang++ - MAKEFLAGS: -j 10 + MAKEFLAGS: -j 2 + + - base_ubuntu2004_clang_large: &base_ubuntu2004_clang_large + <<: *base_ubuntu2004_clang + resource_class: large + environment: + TERM: xterm + CC: clang + CXX: clang++ + MAKEFLAGS: -j 5 - base_ubuntu2004: &base_ubuntu2004 docker: - image: << pipeline.parameters.ubuntu-2004-docker-image >> environment: TERM: xterm + MAKEFLAGS: -j 3 + + - base_ubuntu2004_small: &base_ubuntu2004_small + <<: *base_ubuntu2004 + resource_class: small + environment: + TERM: xterm + MAKEFLAGS: -j 2 + + - base_ubuntu2004_large: &base_ubuntu2004_large + <<: *base_ubuntu2004 + resource_class: large + environment: + TERM: xterm + MAKEFLAGS: -j 5 - base_ubuntu2004_xlarge: &base_ubuntu2004_xlarge <<: *base_ubuntu2004 @@ -251,29 +290,48 @@ defaults: TERM: xterm MAKEFLAGS: -j 10 - - base_buildpack_focal: &base_buildpack_focal + - base_buildpack_focal_small: &base_buildpack_focal_small docker: - image: buildpack-deps:focal + resource_class: small environment: TERM: xterm + MAKEFLAGS: -j 2 - - base_buildpack_latest: &base_buildpack_latest + - base_buildpack_latest_small: &base_buildpack_latest_small docker: - image: buildpack-deps:latest + resource_class: small environment: TERM: xterm + MAKEFLAGS: -j 2 - base_archlinux: &base_archlinux docker: - image: archlinux:base environment: TERM: xterm + MAKEFLAGS: -j 3 + + - base_archlinux_large: &base_archlinux_large + docker: + - image: archlinux:base + resource_class: large + environment: + TERM: xterm + MAKEFLAGS: -j 5 - base_win_powershell: &base_win_powershell executor: name: win/default shell: powershell.exe + - base_win_powershell_large: &base_win_powershell_large + executor: + name: win/default + shell: powershell.exe + size: large + - base_win_cmd: &base_win_cmd executor: name: win/default @@ -284,26 +342,31 @@ defaults: xcode: "11.0.0" environment: TERM: xterm + MAKEFLAGS: -j 5 - - base_ems_xlarge: &base_ems_xlarge + - base_ems_large: &base_ems_large docker: - image: << pipeline.parameters.emscripten-docker-image >> - resource_class: xlarge + resource_class: large environment: TERM: xterm - MAKEFLAGS: -j 10 + MAKEFLAGS: -j 5 - - base_python: &base_python + - base_python_small: &base_python_small docker: - image: circleci/python:3.6 + resource_class: small environment: TERM: xterm + MAKEFLAGS: -j 2 - - base_node_latest: &base_node_latest + - base_node_latest_small: &base_node_latest_small docker: - image: circleci/node + resource_class: small environment: TERM: xterm + MAKEFLAGS: -j 2 # -------------------------------------------------------------------------- # Workflow Templates @@ -333,6 +396,11 @@ defaults: requires: - b_ubu_release + - workflow_ubuntu2004_static: &workflow_ubuntu2004_static + <<: *workflow_trigger_on_tags + requires: + - b_ubu_static + - workflow_archlinux: &workflow_archlinux <<: *workflow_trigger_on_tags requires: @@ -387,7 +455,7 @@ defaults: jobs: chk_spelling: - <<: *base_python + <<: *base_python_small steps: - checkout - attach_workspace: @@ -402,7 +470,7 @@ jobs: - gitter_notify_failure_unless_pr chk_docs_examples: - <<: *base_node_latest + <<: *base_node_latest_small steps: - checkout - attach_workspace: @@ -416,7 +484,7 @@ jobs: - gitter_notify_failure_unless_pr chk_coding_style: - <<: *base_buildpack_focal + <<: *base_buildpack_focal_small steps: - checkout - run: @@ -434,7 +502,7 @@ jobs: - gitter_notify_failure_unless_pr chk_errorcodes: - <<: *base_python + <<: *base_python_small steps: - checkout - run: @@ -443,7 +511,7 @@ jobs: - gitter_notify_failure_unless_pr chk_pylint: - <<: *base_buildpack_focal + <<: *base_buildpack_focal_small steps: - checkout - run: @@ -459,7 +527,7 @@ jobs: - gitter_notify_failure_unless_pr chk_antlr_grammar: - <<: *base_buildpack_focal + <<: *base_buildpack_focal_small steps: - checkout - run: @@ -471,7 +539,7 @@ jobs: - gitter_notify_failure_unless_pr chk_buglist: - <<: *base_node_latest + <<: *base_node_latest_small steps: - checkout - run: @@ -486,7 +554,7 @@ jobs: - gitter_notify_failure_unless_pr chk_proofs: - <<: *base_buildpack_latest + <<: *base_buildpack_latest_small steps: - checkout - run: @@ -499,14 +567,14 @@ jobs: - gitter_notify_failure_unless_pr chk_docs_pragma_min_version: - <<: *base_ubuntu2004 + <<: *base_ubuntu2004_small steps: - checkout - run: *run_docs_pragma_min_version - gitter_notify_failure_unless_pr t_ubu_pyscripts: - <<: *base_ubuntu2004 + <<: *base_ubuntu2004_small steps: - checkout - run: @@ -525,6 +593,8 @@ jobs: - gitter_notify_failure_unless_pr b_ubu: &b_ubu + # this runs 2x faster on xlarge but takes 4x more resources (compared to medium). + # Enough other jobs depend on it that it's worth it though. <<: *base_ubuntu2004_xlarge steps: - checkout @@ -537,10 +607,11 @@ jobs: # x64 ASAN build, for testing for memory related bugs b_ubu_asan: &b_ubu_asan - <<: *base_ubuntu2004_xlarge + # Runs slightly faster on large and xlarge but we only run it nightly so efficiency matters more. + <<: *base_ubuntu2004 environment: CMAKE_OPTIONS: -DSANITIZE=address - MAKEFLAGS: -j 10 + MAKEFLAGS: -j 3 CMAKE_BUILD_TYPE: Release steps: - checkout @@ -550,7 +621,12 @@ jobs: - gitter_notify_failure_unless_pr b_ubu_clang: &b_ubu_clang - <<: *base_ubuntu2004_clang_xlarge + <<: *base_ubuntu2004_clang_large + environment: + TERM: xterm + CC: clang + CXX: clang++ + MAKEFLAGS: -j 10 steps: - checkout - run: *run_build @@ -559,6 +635,7 @@ jobs: - gitter_notify_failure_unless_pr b_ubu_asan_clang: &b_ubu_asan_clang + # This runs a bit faster on large and xlarge but on nightly efficiency matters more. <<: *base_ubuntu2004_clang environment: CC: clang @@ -573,6 +650,7 @@ jobs: - gitter_notify_failure_unless_pr b_ubu_ubsan_clang: &b_ubu_ubsan_clang + # This runs a bit faster on large and xlarge but on nightly efficiency matters more. <<: *base_ubuntu2004_clang environment: CC: clang @@ -593,8 +671,10 @@ jobs: MAKEFLAGS: -j 10 b_ubu_static: + # On large runs 2x faster than on medium. 3x on xlarge. <<: *base_ubuntu2004_xlarge environment: + TERM: xterm MAKEFLAGS: -j 10 CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -DUSE_Z3_DLOPEN=ON -DUSE_CVC4=OFF -DSOLC_STATIC_STDLIBS=ON steps: @@ -604,14 +684,16 @@ jobs: name: strip binary command: strip build/solc/solc - store_artifacts: *artifacts_solc + - persist_to_workspace: *artifacts_executables - gitter_notify_failure_unless_pr b_ubu_codecov: - <<: *base_ubuntu2004_xlarge + # Runs ~30% faster on large but we only run it nightly so efficiency matters more. + <<: *base_ubuntu2004 environment: COVERAGE: ON CMAKE_BUILD_TYPE: Debug - MAKEFLAGS: -j 10 + MAKEFLAGS: -j 3 steps: - checkout - run: *run_build @@ -620,7 +702,6 @@ jobs: t_ubu_codecov: <<: *base_ubuntu2004 - parallelism: 6 environment: EVM: << pipeline.parameters.evm-version >> OPTIMIZE: 1 @@ -644,7 +725,7 @@ jobs: # Builds in C++20 mode and uses debug build in order to speed up. # Do *NOT* store any artifacts or workspace as we don't run tests on this build. b_ubu_cxx20: - <<: *base_ubuntu2004_xlarge + <<: *base_ubuntu2004_large environment: CMAKE_BUILD_TYPE: Debug CMAKE_OPTIONS: -DCMAKE_CXX_STANDARD=20 -DUSE_CVC4=OFF @@ -664,7 +745,7 @@ jobs: - gitter_notify_failure_unless_pr t_ubu_ossfuzz: &t_ubu_ossfuzz - <<: *base_ubuntu1604_clang + <<: *base_ubuntu1604_clang_small steps: - checkout - attach_workspace: @@ -681,10 +762,10 @@ jobs: - gitter_notify_success_unless_pr b_archlinux: - <<: *base_archlinux + <<: *base_archlinux_large environment: TERM: xterm - MAKEFLAGS: -j 3 + MAKEFLAGS: -j 5 steps: - run: name: Install build dependencies @@ -765,7 +846,10 @@ jobs: - gitter_notify_failure_unless_pr b_ems: - <<: *base_ems_xlarge + <<: *base_ems_large + environment: + TERM: xterm + MAKEFLAGS: -j 10 steps: - checkout - run: @@ -786,7 +870,7 @@ jobs: - gitter_notify_failure_unless_pr b_docs: - <<: *base_ubuntu2004 + <<: *base_ubuntu2004_small steps: - checkout - run: *setup_prerelease_commit_hash @@ -800,7 +884,7 @@ jobs: t_ubu_soltest_all: &t_ubu_soltest_all <<: *base_ubuntu2004 - parallelism: 6 + parallelism: 15 # 7 EVM versions, each with/without optimization + 1 ABIv1/@nooptions run <<: *steps_soltest_all t_archlinux_soltest: &t_archlinux_soltest @@ -843,14 +927,15 @@ jobs: <<: *t_ubu_soltest_all t_ubu_cli: &t_ubu_cli - <<: *base_ubuntu2004 + <<: *base_ubuntu2004_small <<: *steps_cmdline_tests t_ubu_release_cli: &t_ubu_release_cli <<: *t_ubu_cli t_ubu_asan_cli: - <<: *base_ubuntu2004 + # Runs slightly faster on medium but we only run it nightly so efficiency matters more. + <<: *base_ubuntu2004_small environment: TERM: xterm ASAN_OPTIONS: check_initialization_order=true:detect_stack_use_after_return=true:strict_init_order=true:strict_string_checks=true:detect_invalid_pointer_pairs=2 @@ -858,7 +943,6 @@ jobs: t_ubu_asan_soltest: <<: *base_ubuntu2004 - parallelism: 6 environment: EVM: << pipeline.parameters.evm-version >> OPTIMIZE: 0 @@ -882,10 +966,11 @@ jobs: <<: *steps_soltest t_ubu_ubsan_clang_cli: - <<: *base_ubuntu2004_clang + <<: *base_ubuntu2004_clang_small <<: *steps_cmdline_tests t_ems_solcjs: + # Unlike other t_ems jobs this one actually runs 2x faster on medium (compared to small). <<: *base_ubuntu2004 steps: - checkout @@ -906,7 +991,7 @@ jobs: - gitter_notify_failure_unless_pr t_ems_ext_hardhat: - <<: *base_node_latest + <<: *base_node_latest_small environment: TERM: xterm HARDHAT_TESTS_SOLC_PATH: /tmp/workspace/soljson.js @@ -935,14 +1020,25 @@ jobs: parameters: project: type: string + binary_type: + type: enum + enum: + - solcjs + - native compile_only: type: integer default: 0 nodejs_version: - type: integer - default: 14 + type: string + default: latest + resource_class: + type: string + default: small docker: - image: circleci/node:<> + resource_class: <> + # NOTE: Each external test does 3 separate compile&test runs + parallelism: 3 environment: TERM: xterm COMPILE_ONLY: <> @@ -951,18 +1047,30 @@ jobs: - attach_workspace: at: /tmp/workspace - run: - name: Install dependencies + name: Install lsof command: | # lsof is used by Colony in its stop-blockchain-client.sh script - sudo apt-get -qy install lsof - - run: - name: External <> tests - command: | - test/externalTests/<>.sh /tmp/workspace/soljson.js + sudo apt-get --quiet --assume-yes --no-install-recommends install lsof + - when: + condition: + equal: [<< parameters.binary_type >>, "solcjs"] + steps: + - run: + name: External <> tests (solcjs) + command: | + test/externalTests/<>.sh solcjs /tmp/workspace/soljson.js + - when: + condition: + equal: [<< parameters.binary_type >>, "native"] + steps: + - run: + name: External <> tests (native) + command: | + test/externalTests/<>.sh native /tmp/workspace/solc/solc - gitter_notify_failure_unless_pr b_win: &b_win - <<: *base_win_powershell + <<: *base_win_powershell_large steps: # NOTE: Not disabling git's core.autocrlf here because we want to build using the typical Windows config. - checkout @@ -1019,7 +1127,7 @@ jobs: <<: *t_win_soltest b_bytecode_ubu: - <<: *base_ubuntu2004 + <<: *base_ubuntu2004_small steps: - checkout - attach_workspace: @@ -1085,7 +1193,7 @@ jobs: - gitter_notify_failure_unless_pr b_bytecode_ems: - <<: *base_node_latest + <<: *base_node_latest_small environment: SOLC_EMSCRIPTEN: "On" steps: @@ -1102,7 +1210,7 @@ jobs: - gitter_notify_failure_unless_pr t_bytecode_compare: - <<: *base_ubuntu2004 + <<: *base_ubuntu2004_small environment: REPORT_FILES: | bytecode-report-emscripten.txt @@ -1191,58 +1299,53 @@ workflows: - t_ems_solcjs: *workflow_emscripten - t_ems_ext_hardhat: *workflow_emscripten + # Separate compile-only runs of those external tests where a full run takes much longer. - t_ems_ext: <<: *workflow_emscripten name: t_ems_compile_ext_colony project: colony + binary_type: solcjs compile_only: 1 + nodejs_version: '14' - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_compile_ext_gnosis + <<: *workflow_ubuntu2004_static + name: t_native_compile_ext_gnosis project: gnosis + binary_type: native compile_only: 1 - - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_compile_ext_gnosis_v2 - project: gnosis-v2 - compile_only: 1 - - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_compile_ext_zeppelin - project: zeppelin - compile_only: 1 - - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_compile_ext_ens - project: ens - compile_only: 1 - # NOTE: One of the dependencies (fsevents) fails to build its native extension on node.js 12+. - nodejs_version: 10 + nodejs_version: '14' # FIXME: Gnosis tests are pretty flaky right now. They often fail on CircleCI due to random ProviderError # and there are also other less frequent problems. See https://github.com/gnosis/safe-contracts/issues/216. #- t_ems_ext: # <<: *workflow_emscripten - # name: t_ems_test_ext_gnosis + # name: t_native_test_ext_gnosis # project: gnosis + # binary_type: native # # NOTE: Tests do not start on node.js 14 ("ganache-cli exited early with code 1"). - # nodejs_version: 12 + # nodejs_version: '12' - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_test_ext_gnosis_v2 + <<: *workflow_ubuntu2004_static + name: t_native_test_ext_gnosis_v2 project: gnosis-v2 + binary_type: native # NOTE: Tests do not start on node.js 14 ("ganache-cli exited early with code 1"). - nodejs_version: 12 + nodejs_version: '12' - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_test_ext_zeppelin + <<: *workflow_ubuntu2004_static + name: t_native_test_ext_zeppelin project: zeppelin + binary_type: native + # NOTE: Tests crash on nodejs 17: "Error: error:0308010C:digital envelope routines::unsupported" + nodejs_version: '16' + resource_class: large - t_ems_ext: - <<: *workflow_emscripten - name: t_ems_test_ext_ens + <<: *workflow_ubuntu2004_static + name: t_native_test_ext_ens project: ens + binary_type: native # NOTE: One of the dependencies (fsevents) fails to build its native extension on node.js 12+. - nodejs_version: 10 + nodejs_version: '10' # Windows build and tests - b_win: *workflow_trigger_on_tags @@ -1307,3 +1410,6 @@ workflows: <<: *workflow_emscripten name: t_ems_test_ext_colony project: colony + binary_type: solcjs + nodejs_version: '14' + resource_class: medium diff --git a/.circleci/osx_install_dependencies.sh b/.circleci/osx_install_dependencies.sh index ed11f2491..36d336774 100755 --- a/.circleci/osx_install_dependencies.sh +++ b/.circleci/osx_install_dependencies.sh @@ -57,14 +57,15 @@ then brew install cmake brew install wget brew install coreutils + brew install diffutils ./scripts/install_obsolete_jsoncpp_1_7_4.sh # z3 - z3_version="4.8.12" - z3_dir="z3-${z3_version}-x64-osx-10.15.7" + z3_version="4.8.13" + z3_dir="z3-${z3_version}-x64-osx-10.16" z3_package="${z3_dir}.zip" wget "https://github.com/Z3Prover/z3/releases/download/z3-${z3_version}/${z3_package}" - validate_checksum "$z3_package" a1f6ef3c99456147c4d3f2652dc6bc90951c4ab3fe7741a255eb794f0ab8938c + validate_checksum "$z3_package" 191b26be2b617b2dffffce139d77abcd7e584859efbc10a58d01a1d7830697a4 unzip "$z3_package" rm "$z3_package" cp "${z3_dir}/bin/libz3.a" /usr/local/lib diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 353d81cd6..5bd5ed9f1 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -28,27 +28,32 @@ set -e REPODIR="$(realpath "$(dirname "$0")"/..)" +# shellcheck source=scripts/common.sh +source "${REPODIR}/scripts/common.sh" + +# NOTE: If you add/remove values, remember to update `parallelism` setting in CircleCI config. EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london) DEFAULT_EVM=london [[ " ${EVM_VALUES[*]} " =~ $DEFAULT_EVM ]] OPTIMIZE_VALUES=(0 1) STEPS=$(( 1 + ${#EVM_VALUES[@]} * ${#OPTIMIZE_VALUES[@]} )) -if (( CIRCLE_NODE_TOTAL )) && (( CIRCLE_NODE_TOTAL > 1 )) -then - RUN_STEPS=$(seq "$STEPS" | circleci tests split | xargs) -else - RUN_STEPS=$(seq "$STEPS" | xargs) -fi - -echo "Running steps $RUN_STEPS..." +RUN_STEPS=$(circleci_select_steps "$(seq "$STEPS")") +printTask "Running steps $RUN_STEPS..." STEP=1 # Run for ABI encoder v1, without SMTChecker tests. -[[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="${DEFAULT_EVM}" OPTIMIZE=1 ABI_ENCODER_V1=1 BOOST_TEST_ARGS="-t !smtCheckerTests" "${REPODIR}/.circleci/soltest.sh" -STEP=$((STEP + 1)) +if circleci_step_selected "$RUN_STEPS" "$STEP" +then + EVM="${DEFAULT_EVM}" \ + OPTIMIZE=1 \ + ABI_ENCODER_V1=1 \ + BOOST_TEST_ARGS="-t !smtCheckerTests" \ + "${REPODIR}/.circleci/soltest.sh" +fi +((++STEP)) for OPTIMIZE in "${OPTIMIZE_VALUES[@]}" do @@ -63,13 +68,16 @@ do DISABLE_SMTCHECKER="" [ "${OPTIMIZE}" != "0" ] && DISABLE_SMTCHECKER="-t !smtCheckerTests" - [[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" SOLTEST_FLAGS="$SOLTEST_FLAGS $ENFORCE_GAS_ARGS $EWASM_ARGS" BOOST_TEST_ARGS="-t !@nooptions $DISABLE_SMTCHECKER" "${REPODIR}/.circleci/soltest.sh" - STEP=$((STEP + 1)) + if circleci_step_selected "$RUN_STEPS" "$STEP" + then + EVM="$EVM" \ + OPTIMIZE="$OPTIMIZE" \ + SOLTEST_FLAGS="$SOLTEST_FLAGS $ENFORCE_GAS_ARGS $EWASM_ARGS" \ + BOOST_TEST_ARGS="-t !@nooptions $DISABLE_SMTCHECKER" \ + "${REPODIR}/.circleci/soltest.sh" + fi + ((++STEP)) done done -if ((STEP != STEPS + 1)) -then - echo "Step counter not properly adjusted!" >&2 - exit 1 -fi +((STEP == STEPS + 1)) || assertFail "Step counter not properly adjusted!" diff --git a/CMakeLists.txt b/CMakeLists.txt index e3dc030c1..b4e91f826 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/licens include(EthOptions) configure_project(TESTS) -set(LATEST_Z3_VERSION "4.8.12") +set(LATEST_Z3_VERSION "4.8.13") set(MINIMUM_Z3_VERSION "4.8.0") find_package(Z3) if (${Z3_FOUND}) diff --git a/Changelog.md b/Changelog.md index adfbe9e5e..c5c33d154 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,10 @@ Compiler Features: Bugfixes: + * Code Generator: Fix a crash when using ``@use-src`` and compiling from Yul to ewasm. + * SMTChecker: Fix internal error when an unsafe target is solved more than once and the counterexample messages are different. + * Fix internal error when a function has a calldata struct argument with an internal type inside. + ### 0.8.10 (2021-11-09) @@ -111,7 +115,7 @@ Bugfixes: * SMTChecker: Fix false positive in external calls from constructors. * SMTChecker: Fix internal error on some multi-source uses of ``abi.*``, cryptographic functions and constants. * Standard JSON: Fix non-fatal errors in Yul mode being discarded if followed by a fatal error. - * Type Checker: Correct wrong error message in inline assembly complaining about ``.slot`` or ``.offset` not valid when actually ``.length`` was used. + * Type Checker: Correct wrong error message in inline assembly complaining about ``.slot`` or ``.offset`` not valid when actually ``.length`` was used. * Type Checker: Disallow modifier declarations and definitions in interfaces. * Yul Optimizer: Fix a crash in LoadResolver, when ``keccak256`` has particular non-identifier arguments. diff --git a/docs/_templates/versions.html b/docs/_templates/versions.html index f680b6506..a2432e370 100644 --- a/docs/_templates/versions.html +++ b/docs/_templates/versions.html @@ -13,13 +13,13 @@
-
{{ _('Versions') }}
{% for slug, url in versions %} -
{{ slug }}
+
{{ _('Downloads') }}
{% for type, url in downloads %} +
{{ type }}
{% endfor %}
-
{{ _('Downloads') }}
{% for type, url in downloads %} -
{{ type }}
+
{{ _('Versions') }}
{% for slug, url in versions %} +
{{ slug }}
{% endfor %}
@@ -33,4 +33,4 @@
- \ No newline at end of file + diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 6f50c70d9..02e5f8b2a 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -749,7 +749,7 @@ Non-standard Packed Mode Through ``abi.encodePacked()``, Solidity supports a non-standard packed mode where: -- types shorter than 32 bytes are neither zero padded nor sign extended and +- types shorter than 32 bytes are concatenated directly, without padding or sign extension - dynamic types are encoded in-place and without the length. - array elements are padded, but still encoded in-place diff --git a/docs/brand-guide.rst b/docs/brand-guide.rst index fc03f35d9..5601b16a8 100644 --- a/docs/brand-guide.rst +++ b/docs/brand-guide.rst @@ -59,7 +59,7 @@ Under the following terms: - **Attribution** — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any - reasonable manner, but not in any way that suggests the the Solidity + reasonable manner, but not in any way that suggests that the Solidity core team endorses you or your use. When using the Solidity logo, please respect the Solidity logo guidelines. diff --git a/docs/cheatsheet.rst b/docs/cheatsheet.rst index d36a96360..17537914a 100644 --- a/docs/cheatsheet.rst +++ b/docs/cheatsheet.rst @@ -81,7 +81,7 @@ Global Variables - ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory)``: :ref:`ABI `-encodes the given arguments starting from the second and prepends the given four-byte selector - ``abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)``: Equivalent - to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)``` + to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)`` - ``bytes.concat(...) returns (bytes memory)``: :ref:`Concatenates variable number of arguments to one byte array` - ``block.basefee`` (``uint``): current block's base fee (`EIP-3198 `_ and `EIP-1559 `_) diff --git a/docs/index.rst b/docs/index.rst index 3dbbfddb0..390ee0842 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -31,6 +31,12 @@ a 0.y.z version number `to indicate this fast pace of change ` for more details. +.. Hint:: + + You can download this documentation as PDF, HTML or Epub by clicking on the versions + flyout menu in the bottom-left corner and selecting the preferred download format. + + Getting Started --------------- diff --git a/docs/internals/optimizer.rst b/docs/internals/optimizer.rst index 28c342902..19bca791e 100644 --- a/docs/internals/optimizer.rst +++ b/docs/internals/optimizer.rst @@ -521,7 +521,7 @@ ExpressionSplitter The expression splitter turns expressions like ``add(mload(0x123), mul(mload(0x456), 0x20))`` into a sequence of declarations of unique variables that are assigned sub-expressions -of that expression so that each function call has only variables or literals +of that expression so that each function call has only variables as arguments. The above would be transformed into @@ -529,10 +529,13 @@ The above would be transformed into .. code-block:: yul { - let _1 := mload(0x123) - let _2 := mul(_1, 0x20) - let _3 := mload(0x456) - let z := add(_3, _2) + let _1 := 0x20 + let _2 := 0x456 + let _3 := mload(_2) + let _4 := mul(_3, _1) + let _5 := 0x123 + let _6 := mload(_5) + let z := add(_6, _4) } Note that this transformation does not change the order of opcodes or function calls. @@ -543,7 +546,7 @@ this "outlining" of the inner expressions in all cases. We can sidestep this lim The final program should be in a form such that (with the exception of loop conditions) function calls cannot appear nested inside expressions -and all function call arguments have to be literals or variables. +and all function call arguments have to be variables. The benefits of this form are that it is much easier to re-order the sequence of opcodes and it is also easier to perform function call inlining. Furthermore, it is simpler @@ -972,15 +975,19 @@ BlockFlattener ^^^^^^^^^^^^^^ This stage eliminates nested blocks by inserting the statement in the -inner block at the appropriate place in the outer block: +inner block at the appropriate place in the outer block. It depends on the +FunctionGrouper and does not flatten the outermost block to keep the form +produced by the FunctionGrouper. .. code-block:: yul { - let x := 2 { - let y := 3 - mstore(x, y) + let x := 2 + { + let y := 3 + mstore(x, y) + } } } @@ -989,9 +996,11 @@ is transformed to .. code-block:: yul { - let x := 2 - let y := 3 - mstore(x, y) + { + let x := 2 + let y := 3 + mstore(x, y) + } } As long as the code is disambiguated, this does not cause a problem because diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index d19a0decf..aab0faf7c 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -313,7 +313,7 @@ likely it will be. since it is not up to the submitter of a transaction, but up to the miners to determine in which block the transaction is included. If you want to schedule future calls of your contract, you can use - the `alarm clock `_ or a similar oracle service. + a smart contract automation tool or an oracle service. .. _the-ethereum-virtual-machine: @@ -584,5 +584,5 @@ but instead is implemented in the EVM execution environment itself. Different EVM-compatible chains might use a different set of precompiled contracts. It might also be possible that new precompiled contracts are added to the Ethereum main chain in the future, -but you can reasonabyly expect them to always be in the range between -``1`` and ``0xffff`` (inclusive). \ No newline at end of file +but you can reasonably expect them to always be in the range between +``1`` and ``0xffff`` (inclusive). diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 9e0fba5f6..64e76526f 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -747,7 +747,7 @@ Yes: function thisFunctionNameIsReallyLong( address x, address y, - address z, + address z ) public onlyOwner diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index f849f3f7e..49e35d9ea 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -437,14 +437,16 @@ an error. You can prepend (for integer types) or append (for bytesNN types) zero Rational and Integer Literals ----------------------------- -Integer literals are formed from a sequence of numbers in the range 0-9. +Integer literals are formed from a sequence of digits in the range 0-9. They are interpreted as decimals. For example, ``69`` means sixty nine. Octal literals do not exist in Solidity and leading zeros are invalid. -Decimal fraction literals are formed by a ``.`` with at least one number on +Decimal fractional literals are formed by a ``.`` with at least one number on one side. Examples include ``1.``, ``.1`` and ``1.3``. -Scientific notation is also supported, where the base can have fractions and the exponent cannot. +Scientific notation in the form of ``2e10`` is also supported, where the +mantissa can be fractional but the exponent has to be an integer. +The literal ``MeE`` is equivalent to ``M * 10**E``. Examples include ``2e10``, ``-2e10``, ``2e-10``, ``2.5e1``. Underscores can be used to separate the digits of a numeric literal to aid readability. @@ -507,7 +509,7 @@ String literals are written with either double or single-quotes (``"foo"`` or `` For example, with ``bytes32 samevar = "stringliteral"`` the string literal is interpreted in its raw byte form when assigned to a ``bytes32`` type. -String literals can only contain printable ASCII characters, which means the characters between and including 0x1F .. 0x7E. +String literals can only contain printable ASCII characters, which means the characters between and including 0x20 .. 0x7E. Additionally, string literals also support the following escape characters: diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 8a6173280..ac11e0806 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -135,7 +135,7 @@ ABI Encoding and Decoding Functions - ``abi.encode(...) returns (bytes memory)``: ABI-encodes the given arguments - ``abi.encodePacked(...) returns (bytes memory)``: Performs :ref:`packed encoding ` of the given arguments. Note that packed encoding can be ambiguous! - ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory)``: ABI-encodes the given arguments starting from the second and prepends the given four-byte selector -- ``abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature))), ...)``` +- ``abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature))), ...)`` .. note:: These encoding functions can be used to craft data for external function calls without actually diff --git a/docs/yul.rst b/docs/yul.rst index 8f59f2811..219905cd5 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -166,7 +166,7 @@ Inside a code block, the following elements can be used - if statements, e.g. ``if lt(a, b) { sstore(0, 1) }`` - switch statements, e.g. ``switch mload(0) case 0 { revert() } default { mstore(0, 1) }`` - for loops, e.g. ``for { let i := 0} lt(i, 10) { i := add(i, 1) } { mstore(i, 7) }`` -- function definitions, e.g. ``function f(a, b) -> c { c := add(a, b) }``` +- function definitions, e.g. ``function f(a, b) -> c { c := add(a, b) }`` Multiple syntactical elements can follow each other simply separated by whitespace, i.e. there is no terminating ``;`` or newline required. @@ -714,13 +714,15 @@ We will use a destructuring notation for the AST nodes. L'[$parami] = vi and L'[$reti] = 0 for all i. Let G'', L'', mode = E(Gn, L', block) G'', Ln, L''[$ret1], ..., L''[$retm] - E(G, L, l: StringLiteral) = G, L, utf8EncodeLeftAligned(l), - where utf8EncodeLeftAligned performs a UTF-8 encoding of l - and aligns it left into 32 bytes + E(G, L, l: StringLiteral) = G, L, str(l), + where str is the string evaluation function, + which for the EVM dialect is defined in the section 'Literals' above E(G, L, n: HexNumber) = G, L, hex(n) - where hex is the hexadecimal decoding function + where hex is the hexadecimal evaluation function, + which turns a sequence of hexadecimal digits into their big endian value E(G, L, n: DecimalNumber) = G, L, dec(n), - where dec is the decimal decoding function + where dec is the decimal evaluation function, + which turns a sequence of decimal digits into their big endian value .. _opcodes: diff --git a/liblangutil/CharStream.cpp b/liblangutil/CharStream.cpp index 3b30bad77..6ecd85bfe 100644 --- a/liblangutil/CharStream.cpp +++ b/liblangutil/CharStream.cpp @@ -100,7 +100,7 @@ string CharStream::lineAtPosition(int _position) const return line; } -tuple CharStream::translatePositionToLineColumn(int _position) const +LineColumn CharStream::translatePositionToLineColumn(int _position) const { using size_type = string::size_type; using diff_type = string::difference_type; @@ -114,7 +114,7 @@ tuple CharStream::translatePositionToLineColumn(int _position) const lineStart = m_source.rfind('\n', searchPosition - 1); lineStart = lineStart == string::npos ? 0 : lineStart + 1; } - return tuple(lineNumber, searchPosition - lineStart); + return LineColumn{lineNumber, static_cast(searchPosition - lineStart)}; } string_view CharStream::text(SourceLocation const& _location) const @@ -144,3 +144,32 @@ string CharStream::singleLineSnippet(string const& _sourceCode, SourceLocation c return cut; } + +optional CharStream::translateLineColumnToPosition(LineColumn const& _lineColumn) const +{ + return translateLineColumnToPosition(m_source, _lineColumn); +} + +optional CharStream::translateLineColumnToPosition(std::string const& _text, LineColumn const& _input) +{ + if (_input.line < 0) + return nullopt; + + size_t offset = 0; + for (int i = 0; i < _input.line; i++) + { + offset = _text.find('\n', offset); + if (offset == _text.npos) + return nullopt; + offset++; // Skip linefeed. + } + + size_t endOfLine = _text.find('\n', offset); + if (endOfLine == string::npos) + endOfLine = _text.size(); + + if (offset + static_cast(_input.column) > endOfLine) + return nullopt; + return offset + static_cast(_input.column); +} + diff --git a/liblangutil/CharStream.h b/liblangutil/CharStream.h index 761cece31..08f86129b 100644 --- a/liblangutil/CharStream.h +++ b/liblangutil/CharStream.h @@ -51,6 +51,7 @@ #pragma once #include +#include #include #include #include @@ -59,6 +60,7 @@ namespace solidity::langutil { struct SourceLocation; +struct LineColumn; /** * Bidirectional stream of characters. @@ -97,9 +99,15 @@ public: /// Functions that help pretty-printing parse errors /// Do only use in error cases, they are quite expensive. std::string lineAtPosition(int _position) const; - std::tuple translatePositionToLineColumn(int _position) const; + LineColumn translatePositionToLineColumn(int _position) const; ///@} + /// Translates a line:column to the absolute position. + std::optional translateLineColumnToPosition(LineColumn const& _lineColumn) const; + + /// Translates a line:column to the absolute position for the given input text. + static std::optional translateLineColumnToPosition(std::string const& _text, LineColumn const& _input); + /// Tests whether or not given octet sequence is present at the current position in stream. /// @returns true if the sequence could be found, false otherwise. bool prefixMatch(std::string_view _sequence) diff --git a/liblangutil/Exceptions.cpp b/liblangutil/Exceptions.cpp index a410a9863..2595c7755 100644 --- a/liblangutil/Exceptions.cpp +++ b/liblangutil/Exceptions.cpp @@ -75,6 +75,16 @@ Error::Error( *this << util::errinfo_comment(_description); } +SourceLocation const* Error::sourceLocation() const noexcept +{ + return boost::get_error_info(*this); +} + +SecondarySourceLocation const* Error::secondarySourceLocation() const noexcept +{ + return boost::get_error_info(*this); +} + optional Error::severityFromString(string _input) { boost::algorithm::to_lower(_input); diff --git a/liblangutil/Exceptions.h b/liblangutil/Exceptions.h index 0c8f03cb9..10fca8029 100644 --- a/liblangutil/Exceptions.h +++ b/liblangutil/Exceptions.h @@ -197,6 +197,9 @@ public: Type type() const { return m_type; } std::string const& typeName() const { return m_typeName; } + SourceLocation const* sourceLocation() const noexcept; + SecondarySourceLocation const* secondarySourceLocation() const noexcept; + /// helper functions static Error const* containsErrorOfType(ErrorList const& _list, Error::Type _type) { @@ -206,7 +209,7 @@ public: return nullptr; } - static Severity errorSeverity(Type _type) + static constexpr Severity errorSeverity(Type _type) { if (_type == Type::Info) return Severity::Info; diff --git a/liblangutil/SourceLocation.h b/liblangutil/SourceLocation.h index ea9958933..ddb457535 100644 --- a/liblangutil/SourceLocation.h +++ b/liblangutil/SourceLocation.h @@ -119,4 +119,23 @@ SourceLocation parseSourceLocation( /// Stream output for Location (used e.g. in boost exceptions). std::ostream& operator<<(std::ostream& _out, SourceLocation const& _location); + +/** + * Alternative, line-column-based representation for source locations. + * Both line and column are zero-based. + * If used as a range, the second location is considered exclusive. + * Negative values are invalid. + */ +struct LineColumn +{ + /// Line value, can be between zero and number of `\n` characters in the source file. + int line = -1; + /// Column value, can be between zero and number of characters in the line (inclusive). + int column = -1; + + LineColumn() = default; + explicit LineColumn(int _line, int _column): line(_line), column(_column) {} +}; + + } diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h index 6aeb6065e..3b418fcfa 100644 --- a/liblangutil/SourceReferenceExtractor.h +++ b/liblangutil/SourceReferenceExtractor.h @@ -30,15 +30,6 @@ namespace solidity::langutil class CharStreamProvider; -struct LineColumn -{ - int line = {-1}; - int column = {-1}; - - LineColumn() = default; - LineColumn(std::tuple const& _t): line{std::get<0>(_t)}, column{std::get<1>(_t)} {} -}; - struct SourceReference { std::string message; ///< A message that relates to this source reference (such as a warning, info or an error message). diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 750cd6723..b45245627 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -387,7 +387,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) _var.referenceLocation() == VariableDeclaration::Location::Storage && !m_currentContract->abstract() ) - m_errorReporter.typeError( + m_errorReporter.fatalTypeError( 3644_error, _var.location(), "This parameter has a type that can only be used internally. " @@ -403,7 +403,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) solAssert(!message.empty(), "Expected detailed error message!"); if (_function.isConstructor()) message += " You can make the contract abstract to avoid this problem."; - m_errorReporter.typeError(4103_error, _var.location(), message); + m_errorReporter.fatalTypeError(4103_error, _var.location(), message); } else if ( !useABICoderV2() && diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index 76a5ded99..0edfc27ff 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -972,8 +972,6 @@ void CHC::resetSourceAnalysis() { SMTEncoder::resetSourceAnalysis(); - m_safeTargets.clear(); - m_unsafeTargets.clear(); m_unprovedTargets.clear(); m_invariants.clear(); m_functionTargetIds.clear(); diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index da28cf29f..39ed7c10f 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -129,7 +129,7 @@ Json::Value formatErrorWithException( _charStreamProvider ); - if (string const* description = boost::get_error_info(_exception)) + if (string const* description = _exception.comment()) message = ((_message.length() > 0) ? (_message + ":") : "") + *description; else message = _message; diff --git a/libsolutil/CommonIO.cpp b/libsolutil/CommonIO.cpp index 9da5b2422..6089f4db6 100644 --- a/libsolutil/CommonIO.cpp +++ b/libsolutil/CommonIO.cpp @@ -79,6 +79,17 @@ string solidity::util::readUntilEnd(istream& _stdin) return ss.str(); } +string solidity::util::readBytes(istream& _input, size_t _length) +{ + string output; + output.resize(_length); + _input.read(output.data(), static_cast(_length)); + // If read() reads fewer bytes it sets failbit in addition to eofbit. + if (_input.fail()) + output.resize(static_cast(_input.gcount())); + return output; +} + #if defined(_WIN32) class DisableConsoleBuffering { diff --git a/libsolutil/CommonIO.h b/libsolutil/CommonIO.h index ab0000f86..e6cd0c161 100644 --- a/libsolutil/CommonIO.h +++ b/libsolutil/CommonIO.h @@ -57,6 +57,10 @@ std::string readFileAsString(boost::filesystem::path const& _file); /// Retrieves and returns the whole content of the specified input stream (until EOF). std::string readUntilEnd(std::istream& _stdin); +/// Tries to read exactly @a _length bytes from @a _input. +/// Returns a string containing as much data as has been read. +std::string readBytes(std::istream& _input, size_t _length); + /// Retrieves and returns a character from standard input (without waiting for EOL). int readStandardInputChar(); diff --git a/libsolutil/Exceptions.h b/libsolutil/Exceptions.h index d83d8004b..66b2442ef 100644 --- a/libsolutil/Exceptions.h +++ b/libsolutil/Exceptions.h @@ -39,8 +39,6 @@ struct Exception: virtual std::exception, virtual boost::exception /// @returns the errinfo_comment of this exception. std::string const* comment() const noexcept; - -private: }; /// Throws an exception with a given description and extra information about the location the @@ -56,6 +54,10 @@ private: ::boost::throw_line(__LINE__) \ ) +/// Defines an exception type that's meant to signal a specific condition and be caught rather than +/// unwind the stack all the way to the top-level exception handler and interrupt the program. +/// As such it does not carry a message - the code catching it is expected to handle it without +/// letting it escape. #define DEV_SIMPLE_EXCEPTION(X) struct X: virtual ::solidity::util::Exception { const char* what() const noexcept override { return #X; } } DEV_SIMPLE_EXCEPTION(InvalidAddress); diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 039e24ea9..16b68535a 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -173,10 +173,10 @@ add_library(yul optimiser/OptimizerUtilities.h optimiser/ReasoningBasedSimplifier.cpp optimiser/ReasoningBasedSimplifier.h - optimiser/RedundantAssignEliminator.cpp - optimiser/RedundantAssignEliminator.h - optimiser/RedundantStoreBase.cpp - optimiser/RedundantStoreBase.h + optimiser/UnusedAssignEliminator.cpp + optimiser/UnusedAssignEliminator.h + optimiser/UnusedStoreBase.cpp + optimiser/UnusedStoreBase.h optimiser/Rematerialiser.cpp optimiser/Rematerialiser.h optimiser/SMTSolver.cpp diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index eb7a60a32..359cc023b 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -137,7 +137,11 @@ void EVMToEwasmTranslator::parsePolyfill() string(solidity::yul::wasm::polyfill::Logical) + string(solidity::yul::wasm::polyfill::Memory) + "}", ""); - m_polyfill = Parser(errorReporter, WasmDialect::instance()).parse(charStream); + + // Passing an empty SourceLocation() here is a workaround to prevent a crash + // when compiling from yul->ewasm. We're stripping nativeLocation and + // originLocation from the AST (but we only really need to strip nativeLocation) + m_polyfill = Parser(errorReporter, WasmDialect::instance(), langutil::SourceLocation()).parse(charStream); if (!errors.empty()) { string message; diff --git a/libyul/optimiser/BlockFlattener.cpp b/libyul/optimiser/BlockFlattener.cpp index bcbe19c18..0bb828ee5 100644 --- a/libyul/optimiser/BlockFlattener.cpp +++ b/libyul/optimiser/BlockFlattener.cpp @@ -43,3 +43,15 @@ void BlockFlattener::operator()(Block& _block) } ); } + +void BlockFlattener::run(OptimiserStepContext&, Block& _ast) +{ + BlockFlattener flattener; + for (auto& statement: _ast.statements) + if (auto* block = get_if(&statement)) + flattener(*block); + else if (auto* function = get_if(&statement)) + flattener(function->body); + else + yulAssert(false, "BlockFlattener requires the FunctionGrouper."); +} diff --git a/libyul/optimiser/BlockFlattener.h b/libyul/optimiser/BlockFlattener.h index 87a1af7cf..3825647de 100644 --- a/libyul/optimiser/BlockFlattener.h +++ b/libyul/optimiser/BlockFlattener.h @@ -27,7 +27,7 @@ class BlockFlattener: public ASTModifier { public: static constexpr char const* name{"BlockFlattener"}; - static void run(OptimiserStepContext&, Block& _ast) { BlockFlattener{}(_ast); } + static void run(OptimiserStepContext&, Block& _ast); using ASTModifier::operator(); void operator()(Block& _block) override; diff --git a/libyul/optimiser/CircularReferencesPruner.cpp b/libyul/optimiser/CircularReferencesPruner.cpp index 1078779c5..ba1fbf11d 100644 --- a/libyul/optimiser/CircularReferencesPruner.cpp +++ b/libyul/optimiser/CircularReferencesPruner.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -29,6 +30,7 @@ using namespace solidity::yul; void CircularReferencesPruner::run(OptimiserStepContext& _context, Block& _ast) { CircularReferencesPruner{_context.reservedIdentifiers}(_ast); + FunctionGrouper::run(_context, _ast); } void CircularReferencesPruner::operator()(Block& _block) diff --git a/libyul/optimiser/ExpressionJoiner.cpp b/libyul/optimiser/ExpressionJoiner.cpp index 9d1df8694..dbb684007 100644 --- a/libyul/optimiser/ExpressionJoiner.cpp +++ b/libyul/optimiser/ExpressionJoiner.cpp @@ -22,6 +22,7 @@ #include +#include #include #include #include @@ -37,9 +38,10 @@ using namespace std; using namespace solidity; using namespace solidity::yul; -void ExpressionJoiner::run(OptimiserStepContext&, Block& _ast) +void ExpressionJoiner::run(OptimiserStepContext& _context, Block& _ast) { ExpressionJoiner{_ast}(_ast); + FunctionGrouper::run(_context, _ast); } diff --git a/libyul/optimiser/FunctionGrouper.h b/libyul/optimiser/FunctionGrouper.h index fa5409936..57ea80cac 100644 --- a/libyul/optimiser/FunctionGrouper.h +++ b/libyul/optimiser/FunctionGrouper.h @@ -34,7 +34,7 @@ struct OptimiserStepContext; * all function definitions. * * After this step, a block is of the form - * { { I...} F... } + * { { I... } F... } * Where I are (non-function-definition) instructions and F are function definitions. */ class FunctionGrouper diff --git a/libyul/optimiser/OptimizerUtilities.h b/libyul/optimiser/OptimizerUtilities.h index 09ea9ed5a..d80b16316 100644 --- a/libyul/optimiser/OptimizerUtilities.h +++ b/libyul/optimiser/OptimizerUtilities.h @@ -37,6 +37,8 @@ namespace solidity::yul { /// Removes statements that are just empty blocks (non-recursive). +/// If this is run on the outermost block, the FunctionGrouper should be run afterwards to keep +/// the canonical form. void removeEmptyBlocks(Block& _block); /// Returns true if a given literal can not be used as an identifier. diff --git a/libyul/optimiser/SSATransform.h b/libyul/optimiser/SSATransform.h index 66015362a..64181bf20 100644 --- a/libyul/optimiser/SSATransform.h +++ b/libyul/optimiser/SSATransform.h @@ -70,7 +70,7 @@ class NameDispenser; * variable references can use the SSA variable. The only exception to this rule are * for loop conditions, as we cannot insert a variable declaration there. * - * After this stage, redundantAssignmentRemover is recommended to remove the unnecessary + * After this stage, UnusedAssignmentEliminator is recommended to remove the unnecessary * intermediate assignments. * * This stage provides best results if CSE is run right before it, because diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 32ea08dbe..4012fa970 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include #include @@ -118,7 +118,7 @@ void OptimiserSuite::run( // Some steps depend on properties ensured by FunctionHoister, BlockFlattener, FunctionGrouper and // ForLoopInitRewriter. Run them first to be able to run arbitrary sequences safely. - suite.runSequence("hfgo", ast); + suite.runSequence("hgfo", ast); NameSimplifier::run(suite.m_context, ast); // Now the user-supplied part @@ -219,7 +219,7 @@ map> const& OptimiserSuite::allSteps() LiteralRematerialiser, LoadResolver, LoopInvariantCodeMotion, - RedundantAssignEliminator, + UnusedAssignEliminator, ReasoningBasedSimplifier, Rematerialiser, SSAReverser, @@ -260,7 +260,7 @@ map const& OptimiserSuite::stepNameToAbbreviationMap() {LoadResolver::name, 'L'}, {LoopInvariantCodeMotion::name, 'M'}, {ReasoningBasedSimplifier::name, 'R'}, - {RedundantAssignEliminator::name, 'r'}, + {UnusedAssignEliminator::name, 'r'}, {Rematerialiser::name, 'm'}, {SSAReverser::name, 'V'}, {SSATransform::name, 'a'}, diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/UnusedAssignEliminator.cpp similarity index 74% rename from libyul/optimiser/RedundantAssignEliminator.cpp rename to libyul/optimiser/UnusedAssignEliminator.cpp index b6ac69c8f..74dd599a1 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/UnusedAssignEliminator.cpp @@ -20,7 +20,7 @@ * until they go out of scope or are re-assigned. */ -#include +#include #include #include @@ -33,36 +33,36 @@ using namespace std; using namespace solidity; using namespace solidity::yul; -void RedundantAssignEliminator::run(OptimiserStepContext& _context, Block& _ast) +void UnusedAssignEliminator::run(OptimiserStepContext& _context, Block& _ast) { - RedundantAssignEliminator rae{_context.dialect}; + UnusedAssignEliminator rae{_context.dialect}; rae(_ast); StatementRemover remover{rae.m_pendingRemovals}; remover(_ast); } -void RedundantAssignEliminator::operator()(Identifier const& _identifier) +void UnusedAssignEliminator::operator()(Identifier const& _identifier) { changeUndecidedTo(_identifier.name, State::Used); } -void RedundantAssignEliminator::operator()(VariableDeclaration const& _variableDeclaration) +void UnusedAssignEliminator::operator()(VariableDeclaration const& _variableDeclaration) { - RedundantStoreBase::operator()(_variableDeclaration); + UnusedStoreBase::operator()(_variableDeclaration); for (auto const& var: _variableDeclaration.variables) m_declaredVariables.emplace(var.name); } -void RedundantAssignEliminator::operator()(Assignment const& _assignment) +void UnusedAssignEliminator::operator()(Assignment const& _assignment) { visit(*_assignment.value); for (auto const& var: _assignment.variableNames) changeUndecidedTo(var.name, State::Unused); } -void RedundantAssignEliminator::operator()(FunctionDefinition const& _functionDefinition) +void UnusedAssignEliminator::operator()(FunctionDefinition const& _functionDefinition) { ScopedSaveAndRestore outerDeclaredVariables(m_declaredVariables, {}); ScopedSaveAndRestore outerReturnVariables(m_returnVariables, {}); @@ -70,28 +70,28 @@ void RedundantAssignEliminator::operator()(FunctionDefinition const& _functionDe for (auto const& retParam: _functionDefinition.returnVariables) m_returnVariables.insert(retParam.name); - RedundantStoreBase::operator()(_functionDefinition); + UnusedStoreBase::operator()(_functionDefinition); } -void RedundantAssignEliminator::operator()(Leave const&) +void UnusedAssignEliminator::operator()(Leave const&) { for (YulString name: m_returnVariables) changeUndecidedTo(name, State::Used); } -void RedundantAssignEliminator::operator()(Block const& _block) +void UnusedAssignEliminator::operator()(Block const& _block) { ScopedSaveAndRestore outerDeclaredVariables(m_declaredVariables, {}); - RedundantStoreBase::operator()(_block); + UnusedStoreBase::operator()(_block); for (auto const& var: m_declaredVariables) finalize(var, State::Unused); } -void RedundantAssignEliminator::visit(Statement const& _statement) +void UnusedAssignEliminator::visit(Statement const& _statement) { - RedundantStoreBase::visit(_statement); + UnusedStoreBase::visit(_statement); if (auto const* assignment = get_if(&_statement)) if (assignment->variableNames.size() == 1) @@ -99,7 +99,7 @@ void RedundantAssignEliminator::visit(Statement const& _statement) m_stores[assignment->variableNames.front().name][&_statement]; } -void RedundantAssignEliminator::shortcutNestedLoop(TrackedStores const& _zeroRuns) +void UnusedAssignEliminator::shortcutNestedLoop(TrackedStores const& _zeroRuns) { // Shortcut to avoid horrible runtime: // Change all assignments that were newly introduced in the for loop to "used". @@ -116,7 +116,7 @@ void RedundantAssignEliminator::shortcutNestedLoop(TrackedStores const& _zeroRun } } -void RedundantAssignEliminator::finalizeFunctionDefinition(FunctionDefinition const& _functionDefinition) +void UnusedAssignEliminator::finalizeFunctionDefinition(FunctionDefinition const& _functionDefinition) { for (auto const& param: _functionDefinition.parameters) finalize(param.name, State::Unused); @@ -124,14 +124,14 @@ void RedundantAssignEliminator::finalizeFunctionDefinition(FunctionDefinition co finalize(retParam.name, State::Used); } -void RedundantAssignEliminator::changeUndecidedTo(YulString _variable, RedundantAssignEliminator::State _newState) +void UnusedAssignEliminator::changeUndecidedTo(YulString _variable, UnusedAssignEliminator::State _newState) { for (auto& assignment: m_stores[_variable]) if (assignment.second == State::Undecided) assignment.second = _newState; } -void RedundantAssignEliminator::finalize(YulString _variable, RedundantAssignEliminator::State _finalState) +void UnusedAssignEliminator::finalize(YulString _variable, UnusedAssignEliminator::State _finalState) { std::map stores = std::move(m_stores[_variable]); m_stores.erase(_variable); diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/UnusedAssignEliminator.h similarity index 94% rename from libyul/optimiser/RedundantAssignEliminator.h rename to libyul/optimiser/UnusedAssignEliminator.h index 65bbb53fa..b5a2998a1 100644 --- a/libyul/optimiser/RedundantAssignEliminator.h +++ b/libyul/optimiser/UnusedAssignEliminator.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -107,13 +107,13 @@ struct Dialect; * * Prerequisite: Disambiguator, ForLoopInitRewriter. */ -class RedundantAssignEliminator: public RedundantStoreBase +class UnusedAssignEliminator: public UnusedStoreBase { public: - static constexpr char const* name{"RedundantAssignEliminator"}; + static constexpr char const* name{"UnusedAssignEliminator"}; static void run(OptimiserStepContext&, Block& _ast); - explicit RedundantAssignEliminator(Dialect const& _dialect): RedundantStoreBase(_dialect) {} + explicit UnusedAssignEliminator(Dialect const& _dialect): UnusedStoreBase(_dialect) {} void operator()(Identifier const& _identifier) override; void operator()(VariableDeclaration const& _variableDeclaration) override; @@ -122,7 +122,7 @@ public: void operator()(Leave const&) override; void operator()(Block const& _block) override; - using RedundantStoreBase::visit; + using UnusedStoreBase::visit; void visit(Statement const& _statement) override; private: diff --git a/libyul/optimiser/UnusedPruner.cpp b/libyul/optimiser/UnusedPruner.cpp index dae4d4c6f..cb60f9da8 100644 --- a/libyul/optimiser/UnusedPruner.cpp +++ b/libyul/optimiser/UnusedPruner.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,12 @@ using namespace std; using namespace solidity; using namespace solidity::yul; +void UnusedPruner::run(OptimiserStepContext& _context, Block& _ast) +{ + UnusedPruner::runUntilStabilisedOnFullAST(_context.dialect, _ast, _context.reservedIdentifiers); + FunctionGrouper::run(_context, _ast); +} + UnusedPruner::UnusedPruner( Dialect const& _dialect, Block& _ast, diff --git a/libyul/optimiser/UnusedPruner.h b/libyul/optimiser/UnusedPruner.h index af77d911a..e4587d5d7 100644 --- a/libyul/optimiser/UnusedPruner.h +++ b/libyul/optimiser/UnusedPruner.h @@ -50,9 +50,7 @@ class UnusedPruner: public ASTModifier { public: static constexpr char const* name{"UnusedPruner"}; - static void run(OptimiserStepContext& _context, Block& _ast) { - UnusedPruner::runUntilStabilisedOnFullAST(_context.dialect, _ast, _context.reservedIdentifiers); - } + static void run(OptimiserStepContext& _context, Block& _ast); using ASTModifier::operator(); diff --git a/libyul/optimiser/RedundantStoreBase.cpp b/libyul/optimiser/UnusedStoreBase.cpp similarity index 86% rename from libyul/optimiser/RedundantStoreBase.cpp rename to libyul/optimiser/UnusedStoreBase.cpp index 6fc0570b7..27700bdf7 100644 --- a/libyul/optimiser/RedundantStoreBase.cpp +++ b/libyul/optimiser/UnusedStoreBase.cpp @@ -16,10 +16,10 @@ */ // SPDX-License-Identifier: GPL-3.0 /** - * Base class for both RedundantAssignEliminator and RedundantStoreEliminator. + * Base class for both UnusedAssignEliminator and UnusedStoreEliminator. */ -#include +#include #include #include @@ -33,7 +33,7 @@ using namespace std; using namespace solidity; using namespace solidity::yul; -void RedundantStoreBase::operator()(If const& _if) +void UnusedStoreBase::operator()(If const& _if) { visit(*_if.condition); @@ -43,7 +43,7 @@ void RedundantStoreBase::operator()(If const& _if) merge(m_stores, move(skipBranch)); } -void RedundantStoreBase::operator()(Switch const& _switch) +void UnusedStoreBase::operator()(Switch const& _switch) { visit(*_switch.expression); @@ -69,7 +69,7 @@ void RedundantStoreBase::operator()(Switch const& _switch) merge(m_stores, move(branch)); } -void RedundantStoreBase::operator()(FunctionDefinition const& _functionDefinition) +void UnusedStoreBase::operator()(FunctionDefinition const& _functionDefinition) { ScopedSaveAndRestore outerAssignments(m_stores, {}); ScopedSaveAndRestore forLoopInfo(m_forLoopInfo, {}); @@ -79,7 +79,7 @@ void RedundantStoreBase::operator()(FunctionDefinition const& _functionDefinitio finalizeFunctionDefinition(_functionDefinition); } -void RedundantStoreBase::operator()(ForLoop const& _forLoop) +void UnusedStoreBase::operator()(ForLoop const& _forLoop) { ScopedSaveAndRestore outerForLoopInfo(m_forLoopInfo, {}); ScopedSaveAndRestore forLoopNestingDepth(m_forLoopNestingDepth, m_forLoopNestingDepth + 1); @@ -127,19 +127,19 @@ void RedundantStoreBase::operator()(ForLoop const& _forLoop) m_forLoopInfo.pendingBreakStmts.clear(); } -void RedundantStoreBase::operator()(Break const&) +void UnusedStoreBase::operator()(Break const&) { m_forLoopInfo.pendingBreakStmts.emplace_back(move(m_stores)); m_stores.clear(); } -void RedundantStoreBase::operator()(Continue const&) +void UnusedStoreBase::operator()(Continue const&) { m_forLoopInfo.pendingContinueStmts.emplace_back(move(m_stores)); m_stores.clear(); } -void RedundantStoreBase::merge(TrackedStores& _target, TrackedStores&& _other) +void UnusedStoreBase::merge(TrackedStores& _target, TrackedStores&& _other) { util::joinMap(_target, move(_other), []( map& _assignmentHere, @@ -150,7 +150,7 @@ void RedundantStoreBase::merge(TrackedStores& _target, TrackedStores&& _other) }); } -void RedundantStoreBase::merge(TrackedStores& _target, vector&& _source) +void UnusedStoreBase::merge(TrackedStores& _target, vector&& _source) { for (TrackedStores& ts: _source) merge(_target, move(ts)); diff --git a/libyul/optimiser/RedundantStoreBase.h b/libyul/optimiser/UnusedStoreBase.h similarity index 85% rename from libyul/optimiser/RedundantStoreBase.h rename to libyul/optimiser/UnusedStoreBase.h index ed588927c..3bd4e4297 100644 --- a/libyul/optimiser/RedundantStoreBase.h +++ b/libyul/optimiser/UnusedStoreBase.h @@ -16,7 +16,7 @@ */ // SPDX-License-Identifier: GPL-3.0 /** - * Base class for both RedundantAssignEliminator and RedundantStoreEliminator. + * Base class for both UnusedAssignEliminator and UnusedStoreEliminator. */ #pragma once @@ -34,14 +34,19 @@ namespace solidity::yul struct Dialect; /** - * Base class for both RedundantAssignEliminator and RedundantStoreEliminator. + * Base class for both UnusedAssignEliminator and UnusedStoreEliminator. + * + * The class tracks the state of abstract "stores" (assignments or mstore/sstore + * statements) across the control-flow. It is the job of the derived class to create + * the stores and track references, but the base class adjusts their "used state" at + * control-flow splits and joins. * * Prerequisite: Disambiguator, ForLoopInitRewriter. */ -class RedundantStoreBase: public ASTWalker +class UnusedStoreBase: public ASTWalker { public: - explicit RedundantStoreBase(Dialect const& _dialect): m_dialect(_dialect) {} + explicit UnusedStoreBase(Dialect const& _dialect): m_dialect(_dialect) {} using ASTWalker::operator(); void operator()(If const& _if) override; diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 7b8510026..f6c9151eb 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -34,7 +34,7 @@ else BUILD_DIR="$1" fi -# solbuildpackpusher/solidity-buildpack-deps:emscripten-7 +# solbuildpackpusher/solidity-buildpack-deps:emscripten-8 docker run -v "$(pwd):/root/project" -w /root/project \ - solbuildpackpusher/solidity-buildpack-deps@sha256:9ffcd0944433fe100e9433f2aa9ba5c21e096e758ad8a05a4a76feaed3d1f463 \ + solbuildpackpusher/solidity-buildpack-deps@sha256:842d6074e0e7e5355c89122c1cafc1fdb59696596750e7d56e5f35c0d883ad59 \ ./scripts/ci/build_emscripten.sh "$BUILD_DIR" diff --git a/scripts/common.sh b/scripts/common.sh index 3e40754a6..3e67c4f56 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -171,6 +171,18 @@ function msg_on_error fi } +function diff_values +{ + (( $# >= 2 )) || fail "diff_values requires at least 2 arguments." + + local value1="$1" + local value2="$2" + shift + shift + + diff --color=auto --unified=0 <(echo "$value1") <(echo "$value2") "$@" +} + function safe_kill { local PID=${1} @@ -196,3 +208,25 @@ function safe_kill kill -9 "$PID" fi } + +function circleci_select_steps +{ + local all_steps="$1" + (( $# == 1 )) || assertFail + + if (( CIRCLE_NODE_TOTAL )) && (( CIRCLE_NODE_TOTAL > 1 )) + then + echo "$all_steps" | circleci tests split | xargs + else + echo "$all_steps" | xargs + fi +} + +function circleci_step_selected +{ + local selected_steps="$1" + local step="$2" + [[ $step != *" "* ]] || assertFail "Step names must not contain spaces." + + [[ " $selected_steps " == *" $step "* ]] || return 1 +} diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index 66fbd3fa7..e8dec0fae 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -25,7 +25,7 @@ set -ev keyid=70D110489D66E2F6 email=builds@ethereum.org packagename=z3-static -version=4.8.12 +version=4.8.13 DISTRIBUTIONS="focal groovy hirsute" diff --git a/scripts/docker/buildpack-deps/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten index 9a3ca36af..5f86b1e19 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -33,12 +33,12 @@ # Using $(em-config CACHE)/sysroot/usr seems to work, though, and still has cmake find the # dependencies automatically. FROM emscripten/emsdk:2.0.33 AS base -LABEL version="7" +LABEL version="8" ADD emscripten.jam /usr/src RUN set -ex; \ cd /usr/src; \ - git clone https://github.com/Z3Prover/z3.git -b z3-4.8.12 --depth 1 ; \ + git clone https://github.com/Z3Prover/z3.git -b z3-4.8.13 --depth 1 ; \ cd z3; \ mkdir build; \ cd build; \ diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz index 48e9839dd..1d00eabce 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-2021 solidity contributors. #------------------------------------------------------------------------------ FROM gcr.io/oss-fuzz-base/base-clang:latest as base -LABEL version="13" +LABEL version="14" ARG DEBIAN_FRONTEND=noninteractive @@ -61,7 +61,7 @@ RUN set -ex; \ # Z3 RUN set -ex; \ - git clone --depth 1 -b z3-4.8.12 https://github.com/Z3Prover/z3.git \ + git clone --depth 1 -b z3-4.8.13 https://github.com/Z3Prover/z3.git \ /usr/src/z3; \ cd /usr/src/z3; \ mkdir build; \ @@ -102,18 +102,6 @@ RUN set -ex; \ ninja install/strip; \ rm -rf /usr/src/evmone -# HERA -RUN set -ex; \ - cd /usr/src; \ - git clone --branch="v0.5.0" --depth 1 --recurse-submodules https://github.com/ewasm/hera.git; \ - cd hera; \ - mkdir build; \ - cd build; \ - cmake -G Ninja -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="/usr" ..; \ - ninja; \ - ninja install/strip; \ - rm -rf /usr/src/hera - # gmp RUN set -ex; \ # Replace system installed libgmp static library diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 index 63f09e513..8ed35d67e 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="8" +LABEL version="9" ARG DEBIAN_FRONTEND=noninteractive diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang index 1f96e41d5..0ac9d4abf 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="8" +LABEL version="9" ARG DEBIAN_FRONTEND=noninteractive diff --git a/solc/CMakeLists.txt b/solc/CMakeLists.txt index fe68d4eb9..8d9d2b364 100644 --- a/solc/CMakeLists.txt +++ b/solc/CMakeLists.txt @@ -1,6 +1,7 @@ set(libsolcli_sources CommandLineInterface.cpp CommandLineInterface.h CommandLineParser.cpp CommandLineParser.h + Exceptions.h ) add_library(solcli ${libsolcli_sources}) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 1d069f925..461074102 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -23,6 +23,8 @@ */ #include +#include + #include "license.h" #include "solidity/BuildInfo.h" @@ -402,7 +404,7 @@ void CommandLineInterface::handleGasEstimation(string const& _contract) } } -bool CommandLineInterface::readInputFiles() +void CommandLineInterface::readInputFiles() { solAssert(!m_standardJsonInput.has_value(), ""); @@ -411,23 +413,17 @@ bool CommandLineInterface::readInputFiles() m_options.input.mode == InputMode::License || m_options.input.mode == InputMode::Version ) - return true; + return; m_fileReader.setBasePath(m_options.input.basePath); if (m_fileReader.basePath() != "") { if (!boost::filesystem::exists(m_fileReader.basePath())) - { - serr() << "Base path does not exist: " << m_fileReader.basePath() << endl; - return false; - } + solThrow(CommandLineValidationError, "Base path does not exist: \"" + m_fileReader.basePath().string() + '"'); if (!boost::filesystem::is_directory(m_fileReader.basePath())) - { - serr() << "Base path is not a directory: " << m_fileReader.basePath() << endl; - return false; - } + solThrow(CommandLineValidationError, "Base path is not a directory: \"" + m_fileReader.basePath().string() + '"'); } for (boost::filesystem::path const& includePath: m_options.input.includePaths) @@ -442,16 +438,18 @@ bool CommandLineInterface::readInputFiles() { auto pathToQuotedString = [](boost::filesystem::path const& _path){ return "\"" + _path.string() + "\""; }; - serr() << "Source unit name collision detected. "; - serr() << "The specified values of base path and/or include paths would result in multiple "; - serr() << "input files being assigned the same source unit name:" << endl; + string message = + "Source unit name collision detected. " + "The specified values of base path and/or include paths would result in multiple " + "input files being assigned the same source unit name:\n"; + for (auto const& [sourceUnitName, normalizedInputPaths]: collisions) { - serr() << sourceUnitName << " matches: "; - serr() << joinHumanReadable(normalizedInputPaths | ranges::views::transform(pathToQuotedString)) << endl; + message += sourceUnitName + " matches: "; + message += joinHumanReadable(normalizedInputPaths | ranges::views::transform(pathToQuotedString)) + "\n"; } - return false; + solThrow(CommandLineValidationError, message); } for (boost::filesystem::path const& infile: m_options.input.paths) @@ -459,10 +457,7 @@ bool CommandLineInterface::readInputFiles() if (!boost::filesystem::exists(infile)) { if (!m_options.input.ignoreMissingFiles) - { - serr() << infile << " is not found." << endl; - return false; - } + solThrow(CommandLineValidationError, '"' + infile.string() + "\" is not found."); else serr() << infile << " is not found. Skipping." << endl; @@ -472,10 +467,7 @@ bool CommandLineInterface::readInputFiles() if (!boost::filesystem::is_regular_file(infile)) { if (!m_options.input.ignoreMissingFiles) - { - serr() << infile << " is not a valid file." << endl; - return false; - } + solThrow(CommandLineValidationError, '"' + infile.string() + "\" is not a valid file."); else serr() << infile << " is not a valid file. Skipping." << endl; @@ -508,12 +500,7 @@ bool CommandLineInterface::readInputFiles() } if (m_fileReader.sourceCodes().empty() && !m_standardJsonInput.has_value()) - { - serr() << "All specified input files either do not exist or are not regular files." << endl; - return false; - } - - return true; + solThrow(CommandLineValidationError, "All specified input files either do not exist or are not regular files."); } map CommandLineInterface::parseAstFromInput() @@ -559,19 +546,12 @@ void CommandLineInterface::createFile(string const& _fileName, string const& _da string pathName = (m_options.output.dir / _fileName).string(); if (fs::exists(pathName) && !m_options.output.overwriteFiles) - { - serr() << "Refusing to overwrite existing file \"" << pathName << "\" (use --overwrite to force)." << endl; - m_outputFailed = true; - return; - } + solThrow(CommandLineOutputError, "Refusing to overwrite existing file \"" + pathName + "\" (use --overwrite to force)."); + ofstream outFile(pathName); outFile << _data; if (!outFile) - { - serr() << "Could not write to file \"" << pathName << "\"." << endl; - m_outputFailed = true; - return; - } + solThrow(CommandLineOutputError, "Could not write to file \"" + pathName + "\"."); } void CommandLineInterface::createJson(string const& _fileName, string const& _json) @@ -579,9 +559,33 @@ void CommandLineInterface::createJson(string const& _fileName, string const& _js createFile(boost::filesystem::basename(_fileName) + string(".json"), _json); } +bool CommandLineInterface::run(int _argc, char const* const* _argv) +{ + try + { + if (!parseArguments(_argc, _argv)) + return false; + + readInputFiles(); + processInput(); + return true; + } + catch (CommandLineError const& _exception) + { + m_hasOutput = true; + + // There might be no message in the exception itself if the error output is bulky and has + // already been printed to stderr (this happens e.g. for compiler errors). + if (_exception.what() != ""s) + serr() << _exception.what() << endl; + + return false; + } +} + bool CommandLineInterface::parseArguments(int _argc, char const* const* _argv) { - CommandLineParser parser(serr(/* _markAsUsed */ false)); + CommandLineParser parser; if (isatty(fileno(stdin)) && _argc == 1) { @@ -592,16 +596,13 @@ bool CommandLineInterface::parseArguments(int _argc, char const* const* _argv) return false; } - bool success = parser.parse(_argc, _argv); - if (!success) - return false; - m_hasOutput = m_hasOutput || parser.hasOutput(); + parser.parse(_argc, _argv); m_options = parser.options(); return true; } -bool CommandLineInterface::processInput() +void CommandLineInterface::processInput() { switch (m_options.input.mode) { @@ -624,22 +625,17 @@ bool CommandLineInterface::processInput() break; } case InputMode::Assembler: - if (!assemble(m_options.assembly.inputLanguage, m_options.assembly.targetMachine)) - return false; + assemble(m_options.assembly.inputLanguage, m_options.assembly.targetMachine); break; case InputMode::Linker: - if (!link()) - return false; + link(); writeLinkedFiles(); break; case InputMode::Compiler: case InputMode::CompilerWithASTImport: - if (!compile()) - return false; + compile(); outputCompilationResults(); } - - return !m_outputFailed; } void CommandLineInterface::printVersion() @@ -655,7 +651,7 @@ void CommandLineInterface::printLicense() sout() << licenseText << endl; } -bool CommandLineInterface::compile() +void CommandLineInterface::compile() { solAssert(m_options.input.mode == InputMode::Compiler || m_options.input.mode == InputMode::CompilerWithASTImport, ""); @@ -718,8 +714,9 @@ bool CommandLineInterface::compile() } catch (Exception const& _exc) { - serr() << string("Failed to import AST: ") << _exc.what() << endl; - return false; + // FIXME: AST import is missing proper validations. This hack catches failing + // assertions and presents them as if they were compiler errors. + solThrow(CommandLineExecutionError, "Failed to import AST: "s + _exc.what()); } } else @@ -736,29 +733,29 @@ bool CommandLineInterface::compile() formatter.printErrorInformation(*error); } - if (!successful) - return m_options.input.errorRecovery; + if (!successful && !m_options.input.errorRecovery) + solThrow(CommandLineExecutionError, ""); } catch (CompilerError const& _exception) { m_hasOutput = true; formatter.printExceptionInformation(_exception, "Compiler error"); - return false; + solThrow(CommandLineExecutionError, ""); } catch (Error const& _error) { if (_error.type() == Error::Type::DocstringParsingError) - serr() << "Documentation parsing error: " << *boost::get_error_info(_error) << endl; + { + serr() << *boost::get_error_info(_error); + solThrow(CommandLineExecutionError, "Documentation parsing failed."); + } else { m_hasOutput = true; formatter.printExceptionInformation(_error, _error.typeName()); + solThrow(CommandLineExecutionError, ""); } - - return false; } - - return true; } void CommandLineInterface::handleCombinedJSON() @@ -887,7 +884,7 @@ void CommandLineInterface::handleAst() } } -bool CommandLineInterface::link() +void CommandLineInterface::link() { solAssert(m_options.input.mode == InputMode::Linker, ""); @@ -925,11 +922,11 @@ bool CommandLineInterface::link() *(it + placeholderSize - 2) != '_' || *(it + placeholderSize - 1) != '_' ) - { - serr() << "Error in binary object file " << src.first << " at position " << (it - src.second.begin()) << endl; - serr() << '"' << string(it, it + min(placeholderSize, static_cast(end - it))) << "\" is not a valid link reference." << endl; - return false; - } + solThrow( + CommandLineExecutionError, + "Error in binary object file " + src.first + " at position " + to_string(it - src.second.begin()) + "\n" + + '"' + string(it, it + min(placeholderSize, static_cast(end - it))) + "\" is not a valid link reference." + ); string foundPlaceholder(it, it + placeholderSize); if (librariesReplacements.count(foundPlaceholder)) @@ -948,8 +945,6 @@ bool CommandLineInterface::link() src.second.resize(src.second.size() - 1); } m_fileReader.setSources(move(sourceCodes)); - - return true; } void CommandLineInterface::writeLinkedFiles() @@ -964,11 +959,7 @@ void CommandLineInterface::writeLinkedFiles() ofstream outFile(src.first); outFile << src.second; if (!outFile) - { - serr() << "Could not write to file " << src.first << ". Aborting." << endl; - m_outputFailed = true; - return; - } + solThrow(CommandLineOutputError, "Could not write to file " + src.first + ". Aborting."); } sout() << "Linking completed." << endl; } @@ -990,10 +981,12 @@ string CommandLineInterface::objectWithLinkRefsHex(evmasm::LinkerObject const& _ return out; } -bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine) +void CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine) { solAssert(m_options.input.mode == InputMode::Assembler, ""); + serr() << "Warning: Yul is still experimental. Please use the output with care." << endl; + bool successful = true; map assemblyStacks; for (auto const& src: m_fileReader.sourceCodes()) @@ -1031,7 +1024,10 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul: } if (!successful) - return false; + { + solAssert(m_hasOutput); + solThrow(CommandLineExecutionError, ""); + } for (auto const& src: m_fileReader.sourceCodes()) { @@ -1089,8 +1085,6 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul: serr() << "No text representation found." << endl; } } - - return true; } void CommandLineInterface::outputCompilationResults() @@ -1127,13 +1121,9 @@ void CommandLineInterface::outputCompilationResults() ret = m_compiler->assemblyString(contract, m_fileReader.sourceCodes()); if (!m_options.output.dir.empty()) - { createFile(m_compiler->filesystemFriendlyName(contract) + (m_options.compiler.outputs.asmJson ? "_evm.json" : ".evm"), ret); - } else - { sout() << "EVM assembly:" << endl << ret << endl; - } } if (m_options.compiler.estimateGas) diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index ee5057468..9d1646e52 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -51,12 +51,28 @@ public: m_options(_options) {} - /// Parse command line arguments and return false if we should not continue + /// Parses command-line arguments, executes the requested operation and handles validation and + /// execution errors. + /// @returns false if it catches a @p CommandLineValidationError or if the application is + /// expected to exit with a non-zero exit code despite there being no error. + bool run(int _argc, char const* const* _argv); + + /// Parses command line arguments and stores the result in @p m_options. + /// @throws CommandLineValidationError if command-line arguments are invalid. + /// @returns false if the application is expected to exit with a non-zero exit code despite + /// there being no error. bool parseArguments(int _argc, char const* const* _argv); - /// Read the content of all input files and initialize the file reader. - bool readInputFiles(); - /// Parse the files, create source code objects, print the output. - bool processInput(); + + /// Reads the content of all input files and initializes the file reader. + /// @throws CommandLineValidationError if it fails to read the input files (invalid paths, + /// non-existent files, not enough or too many input files, etc.). + void readInputFiles(); + + /// Executes the requested operation (compilation, assembling, standard JSON, etc.) and prints + /// results to the terminal. + /// @throws CommandLineExecutionError if execution fails due to errors in the input files. + /// @throws CommandLineOutputError if creating output files or writing to them fails. + void processInput(); CommandLineOptions const& options() const { return m_options; } FileReader const& fileReader() const { return m_fileReader; } @@ -65,15 +81,15 @@ public: private: void printVersion(); void printLicense(); - bool compile(); - bool link(); + void compile(); + void link(); void writeLinkedFiles(); /// @returns the ``// -> name`` hint for library placeholders. static std::string libraryPlaceholderHint(std::string const& _libraryName); /// @returns the full object with library placeholder hints in hex. static std::string objectWithLinkRefsHex(evmasm::LinkerObject const& _obj); - bool assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine); + void assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine); void outputCompilationResults(); @@ -120,7 +136,6 @@ private: std::ostream& m_sout; std::ostream& m_serr; bool m_hasOutput = false; - bool m_outputFailed = false; ///< If true, creation or write to some of the output files failed. FileReader m_fileReader; std::optional m_standardJsonInput; std::unique_ptr m_compiler; diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index ad04dfae9..6ed625db0 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -17,7 +17,11 @@ // SPDX-License-Identifier: GPL-3.0 #include + +#include + #include + #include #include @@ -34,14 +38,6 @@ namespace po = boost::program_options; namespace solidity::frontend { -ostream& CommandLineParser::serr() -{ - m_hasOutput = true; - return m_serr; -} - -#define cerr - static string const g_strAllowPaths = "allow-paths"; static string const g_strBasePath = "base-path"; static string const g_strIncludePath = "include-path"; @@ -131,6 +127,9 @@ static set const g_metadataHashArgs }; static map const g_inputModeName = { + {InputMode::Help, "help"}, + {InputMode::License, "license"}, + {InputMode::Version, "version"}, {InputMode::Compiler, "compiler"}, {InputMode::CompilerWithASTImport, "compiler (AST import)"}, {InputMode::Assembler, "assembler"}, @@ -138,15 +137,16 @@ static map const g_inputModeName = { {InputMode::Linker, "linker"}, }; -bool CommandLineParser::checkMutuallyExclusive(vector const& _optionNames) +void CommandLineParser::checkMutuallyExclusive(vector const& _optionNames) { if (countEnabledOptions(_optionNames) > 1) { - serr() << "The following options are mutually exclusive: " << joinOptionNames(_optionNames) << ". "; - serr() << "Select at most one." << endl; - return false; + solThrow( + CommandLineValidationError, + "The following options are mutually exclusive: " + joinOptionNames(_optionNames) + ". " + + "Select at most one." + ); } - return true; } bool CompilerOutputs::operator==(CompilerOutputs const& _other) const noexcept @@ -268,17 +268,13 @@ OptimiserSettings CommandLineOptions::optimiserSettings() const return settings; } -bool CommandLineParser::parse(int _argc, char const* const* _argv) +void CommandLineParser::parse(int _argc, char const* const* _argv) { - m_hasOutput = false; - - if (!parseArgs(_argc, _argv)) - return false; - - return processArgs(); + parseArgs(_argc, _argv); + processArgs(); } -bool CommandLineParser::parseInputPathsAndRemappings() +void CommandLineParser::parseInputPathsAndRemappings() { m_options.input.ignoreMissingFiles = (m_args.count(g_strIgnoreMissingFiles) > 0); @@ -289,17 +285,14 @@ bool CommandLineParser::parseInputPathsAndRemappings() { optional remapping = ImportRemapper::parseRemapping(positionalArg); if (!remapping.has_value()) - { - serr() << "Invalid remapping: \"" << positionalArg << "\"." << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid remapping: \"" + positionalArg + "\"."); if (m_options.input.mode == InputMode::StandardJson) - { - serr() << "Import remappings are not accepted on the command line in Standard JSON mode." << endl; - serr() << "Please put them under 'settings.remappings' in the JSON input." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Import remappings are not accepted on the command line in Standard JSON mode.\n" + "Please put them under 'settings.remappings' in the JSON input." + ); m_options.input.remappings.emplace_back(move(remapping.value())); } @@ -312,26 +305,24 @@ bool CommandLineParser::parseInputPathsAndRemappings() if (m_options.input.mode == InputMode::StandardJson) { if (m_options.input.paths.size() > 1 || (m_options.input.paths.size() == 1 && m_options.input.addStdin)) - { - serr() << "Too many input files for --" << g_strStandardJSON << "." << endl; - serr() << "Please either specify a single file name or provide its content on standard input." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Too many input files for --" + g_strStandardJSON + ".\n" + "Please either specify a single file name or provide its content on standard input." + ); else if (m_options.input.paths.size() == 0) // Standard JSON mode input used to be handled separately and zero files meant "read from stdin". // Keep it working that way for backwards-compatibility. m_options.input.addStdin = true; } else if (m_options.input.paths.size() == 0 && !m_options.input.addStdin) - { - serr() << "No input files given. If you wish to use the standard input please specify \"-\" explicitly." << endl; - return false; - } - - return true; + solThrow( + CommandLineValidationError, + "No input files given. If you wish to use the standard input please specify \"-\" explicitly." + ); } -bool CommandLineParser::parseLibraryOption(string const& _input) +void CommandLineParser::parseLibraryOption(string const& _input) { namespace fs = boost::filesystem; string data = _input; @@ -366,71 +357,71 @@ bool CommandLineParser::parseLibraryOption(string const& _input) { separator = lib.rfind(':'); if (separator == string::npos) - { - serr() << "Equal sign separator missing in library address specifier \"" << lib << "\"" << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Equal sign separator missing in library address specifier \"" + lib + "\"" + ); else isSeparatorEqualSign = false; // separator is colon } else if (lib.rfind('=') != lib.find('=')) - { - serr() << "Only one equal sign \"=\" is allowed in the address string \"" << lib << "\"." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Only one equal sign \"=\" is allowed in the address string \"" + lib + "\"." + ); string libName(lib.begin(), lib.begin() + static_cast(separator)); boost::trim(libName); if (m_options.linker.libraries.count(libName)) - { - serr() << "Address specified more than once for library \"" << libName << "\"." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Address specified more than once for library \"" + libName + "\"." + ); string addrString(lib.begin() + static_cast(separator) + 1, lib.end()); boost::trim(addrString); if (addrString.empty()) - { - serr() << "Empty address provided for library \"" << libName << "\"." << endl; - serr() << "Note that there should not be any whitespace after the " << (isSeparatorEqualSign ? "equal sign" : "colon") << "." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Empty address provided for library \"" + libName + "\".\n" + "Note that there should not be any whitespace after the " + + (isSeparatorEqualSign ? "equal sign" : "colon") + "." + ); if (addrString.substr(0, 2) == "0x") addrString = addrString.substr(2); else - { - serr() << "The address " << addrString << " is not prefixed with \"0x\"." << endl; - serr() << "Note that the address must be prefixed with \"0x\"." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "The address " + addrString + " is not prefixed with \"0x\".\n" + "Note that the address must be prefixed with \"0x\"." + ); if (addrString.length() != 40) - { - serr() << "Invalid length for address for library \"" << libName << "\": " << addrString.length() << " instead of 40 characters." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Invalid length for address for library \"" + libName + "\": " + + to_string(addrString.length()) + " instead of 40 characters." + ); if (!passesAddressChecksum(addrString, false)) - { - serr() << "Invalid checksum on address for library \"" << libName << "\": " << addrString << endl; - serr() << "The correct checksum is " << getChecksummedAddress(addrString) << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Invalid checksum on address for library \"" + libName + "\": " + addrString + "\n" + "The correct checksum is " + getChecksummedAddress(addrString) + ); bytes binAddr = fromHex(addrString); h160 address(binAddr, h160::AlignRight); if (binAddr.size() > 20 || address == h160()) - { - serr() << "Invalid address for library \"" << libName << "\": " << addrString << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Invalid address for library \"" + libName + "\": " + addrString + ); m_options.linker.libraries[libName] = address; } - - return true; } -bool CommandLineParser::parseOutputSelection() +void CommandLineParser::parseOutputSelection() { static auto outputSupported = [](InputMode _mode, string_view _outputName) { @@ -486,13 +477,11 @@ bool CommandLineParser::parseOutputSelection() unsupportedOutputs.push_back(optionName); if (!unsupportedOutputs.empty()) - { - serr() << "The following outputs are not supported in " << g_inputModeName.at(m_options.input.mode) << " mode: "; - serr() << joinOptionNames(unsupportedOutputs) << "."; - return false; - } - - return true; + solThrow( + CommandLineValidationError, + "The following outputs are not supported in " + g_inputModeName.at(m_options.input.mode) + " mode: " + + joinOptionNames(unsupportedOutputs) + "." + ); } po::options_description CommandLineParser::optionsDescription() @@ -831,7 +820,7 @@ po::positional_options_description CommandLineParser::positionalOptionsDescripti return filesPositions; } -bool CommandLineParser::parseArgs(int _argc, char const* const* _argv) +void CommandLineParser::parseArgs(int _argc, char const* const* _argv) { po::options_description allOptions = optionsDescription(); po::positional_options_description filesPositions = positionalOptionsDescription(); @@ -846,18 +835,15 @@ bool CommandLineParser::parseArgs(int _argc, char const* const* _argv) } catch (po::error const& _exception) { - serr() << _exception.what() << endl; - return false; + solThrow(CommandLineValidationError, _exception.what()); } po::notify(m_args); - - return true; } -bool CommandLineParser::processArgs() +void CommandLineParser::processArgs() { - if (!checkMutuallyExclusive({ + checkMutuallyExclusive({ g_strHelp, g_strLicense, g_strVersion, @@ -867,8 +853,7 @@ bool CommandLineParser::processArgs() g_strStrictAssembly, g_strYul, g_strImportAst, - })) - return false; + }); if (m_args.count(g_strHelp) > 0) m_options.input.mode = InputMode::Help; @@ -892,7 +877,7 @@ bool CommandLineParser::processArgs() m_options.input.mode == InputMode::License || m_options.input.mode == InputMode::Version ) - return true; + return; map> validOptionInputModeCombinations = { // TODO: This should eventually contain all options. @@ -907,13 +892,13 @@ bool CommandLineParser::processArgs() } if (!invalidOptionsForCurrentInputMode.empty()) - { - serr() << "The following options are not supported in the current input mode: " << joinOptionNames(invalidOptionsForCurrentInputMode) << endl; - return false; - } + solThrow( + CommandLineValidationError, + "The following options are not supported in the current input mode: " + + joinOptionNames(invalidOptionsForCurrentInputMode) + ); - if (!checkMutuallyExclusive({g_strColor, g_strNoColor})) - return false; + checkMutuallyExclusive({g_strColor, g_strNoColor}); array const conflictingWithStopAfter{ CompilerOutputs::componentName(&CompilerOutputs::binary), @@ -928,8 +913,7 @@ bool CommandLineParser::processArgs() }; for (auto& option: conflictingWithStopAfter) - if (!checkMutuallyExclusive({g_strStopAfter, option})) - return false; + checkMutuallyExclusive({g_strStopAfter, option}); if ( m_options.input.mode != InputMode::Compiler && @@ -938,23 +922,23 @@ bool CommandLineParser::processArgs() ) { if (!m_args[g_strOptimizeRuns].defaulted()) - { - serr() << "Option --" << g_strOptimizeRuns << " is only valid in compiler and assembler modes." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Option --" + g_strOptimizeRuns + " is only valid in compiler and assembler modes." + ); for (string const& option: {g_strOptimize, g_strNoOptimizeYul, g_strOptimizeYul, g_strYulOptimizations}) if (m_args.count(option) > 0) - { - serr() << "Option --" << option << " is only valid in compiler and assembler modes." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Option --" + option + " is only valid in compiler and assembler modes." + ); if (!m_args[g_strDebugInfo].defaulted()) - { - serr() << "Option --" << g_strDebugInfo << " is only valid in compiler and assembler modes." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Option --" + g_strDebugInfo + " is only valid in compiler and assembler modes." + ); } if (m_args.count(g_strColor) > 0) @@ -969,15 +953,15 @@ bool CommandLineParser::processArgs() string revertStringsString = m_args[g_strRevertStrings].as(); std::optional revertStrings = revertStringsFromString(revertStringsString); if (!revertStrings) - { - serr() << "Invalid option for --" << g_strRevertStrings << ": " << revertStringsString << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Invalid option for --" + g_strRevertStrings + ": " + revertStringsString + ); if (*revertStrings == RevertStrings::VerboseDebug) - { - serr() << "Only \"default\", \"strip\" and \"debug\" are implemented for --" << g_strRevertStrings << " for now." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "Only \"default\", \"strip\" and \"debug\" are implemented for --" + g_strRevertStrings + " for now." + ); m_options.output.revertStrings = *revertStrings; } @@ -986,20 +970,13 @@ bool CommandLineParser::processArgs() string optionValue = m_args[g_strDebugInfo].as(); m_options.output.debugInfoSelection = DebugInfoSelection::fromString(optionValue); if (!m_options.output.debugInfoSelection.has_value()) - { - serr() << "Invalid value for --" << g_strDebugInfo << " option: " << optionValue << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid value for --" + g_strDebugInfo + " option: " + optionValue); if (m_options.output.debugInfoSelection->snippet && !m_options.output.debugInfoSelection->location) - { - serr() << "To use 'snippet' with --" << g_strDebugInfo << " you must select also 'location'." << endl; - return false; - } + solThrow(CommandLineValidationError, "To use 'snippet' with --" + g_strDebugInfo + " you must select also 'location'."); } - if (!parseCombinedJsonOption()) - return false; + parseCombinedJsonOption(); if (m_args.count(g_strOutputDir)) m_options.output.dir = m_args.at(g_strOutputDir).as(); @@ -1016,8 +993,7 @@ bool CommandLineParser::processArgs() m_options.formatting.json.indent = m_args[g_strJsonIndent].as(); } - if (!parseOutputSelection()) - return false; + parseOutputSelection(); m_options.compiler.estimateGas = (m_args.count(g_strGas) > 0); @@ -1027,18 +1003,13 @@ bool CommandLineParser::processArgs() if (m_args.count(g_strIncludePath) > 0) { if (m_options.input.basePath.empty()) - { - serr() << "--" << g_strIncludePath << " option requires a non-empty base path." << endl; - return false; - } + solThrow(CommandLineValidationError, "--" + g_strIncludePath + " option requires a non-empty base path."); for (string const& includePath: m_args[g_strIncludePath].as>()) { if (includePath.empty()) - { - serr() << "Empty values are not allowed in --" << g_strIncludePath << "." << endl; - return false; - } + solThrow(CommandLineValidationError, "Empty values are not allowed in --" + g_strIncludePath + "."); + m_options.input.includePaths.push_back(includePath); } } @@ -1054,37 +1025,29 @@ bool CommandLineParser::processArgs() if (m_args.count(g_strStopAfter)) { if (m_args[g_strStopAfter].as() != "parsing") - { - serr() << "Valid options for --" << g_strStopAfter << " are: \"parsing\".\n"; - return false; - } + solThrow(CommandLineValidationError, "Valid options for --" + g_strStopAfter + " are: \"parsing\".\n"); else m_options.output.stopAfter = CompilerStack::State::Parsed; } - if (!parseInputPathsAndRemappings()) - return false; + parseInputPathsAndRemappings(); if (m_options.input.mode == InputMode::StandardJson) - return true; + return; if (m_args.count(g_strLibraries)) for (string const& library: m_args[g_strLibraries].as>()) - if (!parseLibraryOption(library)) - return false; + parseLibraryOption(library); if (m_options.input.mode == InputMode::Linker) - return true; + return; if (m_args.count(g_strEVMVersion)) { string versionOptionStr = m_args[g_strEVMVersion].as(); std::optional versionOption = langutil::EVMVersion::fromString(versionOptionStr); if (!versionOption) - { - serr() << "Invalid option for --" << g_strEVMVersion << ": " << versionOptionStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strEVMVersion + ": " + versionOptionStr); m_options.output.evmVersion = *versionOption; } @@ -1097,10 +1060,7 @@ bool CommandLineParser::processArgs() { OptimiserSettings optimiserSettings = m_options.optimiserSettings(); if (!optimiserSettings.runYulOptimiser) - { - serr() << "--" << g_strYulOptimizations << " is invalid if Yul optimizer is disabled" << endl; - return false; - } + solThrow(CommandLineValidationError, "--" + g_strYulOptimizations + " is invalid if Yul optimizer is disabled"); try { @@ -1108,8 +1068,10 @@ bool CommandLineParser::processArgs() } catch (yul::OptimizerException const& _exception) { - serr() << "Invalid optimizer step sequence in --" << g_strYulOptimizations << ": " << _exception.what() << endl; - return false; + solThrow( + CommandLineValidationError, + "Invalid optimizer step sequence in --" + g_strYulOptimizations + ": " + _exception.what() + ); } m_options.optimizer.yulSteps = m_args[g_strYulOptimizations].as(); @@ -1130,12 +1092,11 @@ bool CommandLineParser::processArgs() auto optionEnabled = [&](string const& name){ return m_args.count(name) > 0; }; auto enabledOptions = nonAssemblyModeOptions | ranges::views::filter(optionEnabled) | ranges::to_vector; - serr() << "The following options are invalid in assembly mode: "; - serr() << joinOptionNames(enabledOptions) << "."; + string message = "The following options are invalid in assembly mode: " + joinOptionNames(enabledOptions) + "."; if (m_args.count(g_strOptimizeYul) || m_args.count(g_strNoOptimizeYul)) - serr() << " Optimization is disabled by default and can be enabled with --" << g_strOptimize << "." << endl; - serr() << endl; - return false; + message += " Optimization is disabled by default and can be enabled with --" + g_strOptimize + "."; + + solThrow(CommandLineValidationError, message); } // switch to assembly mode @@ -1151,10 +1112,7 @@ bool CommandLineParser::processArgs() else if (machine == g_strEwasm) m_options.assembly.targetMachine = Machine::Ewasm; else - { - serr() << "Invalid option for --" << g_strMachine << ": " << machine << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strMachine + ": " + machine); } if (m_options.assembly.targetMachine == Machine::Ewasm && m_options.assembly.inputLanguage == Input::StrictAssembly) m_options.assembly.inputLanguage = Input::Ewasm; @@ -1167,45 +1125,33 @@ bool CommandLineParser::processArgs() { m_options.assembly.inputLanguage = Input::Ewasm; if (m_options.assembly.targetMachine != Machine::Ewasm) - { - serr() << "If you select Ewasm as --" << g_strYulDialect << ", "; - serr() << "--" << g_strMachine << " has to be Ewasm as well." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "If you select Ewasm as --" + g_strYulDialect + ", " + "--" + g_strMachine + " has to be Ewasm as well." + ); } else - { - serr() << "Invalid option for --" << g_strYulDialect << ": " << dialect << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strYulDialect + ": " + dialect); } if (m_options.optimizer.enabled && (m_options.assembly.inputLanguage != Input::StrictAssembly && m_options.assembly.inputLanguage != Input::Ewasm)) - { - serr() << - "Optimizer can only be used for strict assembly. Use --" << - g_strStrictAssembly << - "." << - endl; - return false; - } + solThrow( + CommandLineValidationError, + "Optimizer can only be used for strict assembly. Use --" + g_strStrictAssembly + "." + ); if (m_options.assembly.targetMachine == Machine::Ewasm && m_options.assembly.inputLanguage != Input::StrictAssembly && m_options.assembly.inputLanguage != Input::Ewasm) - { - serr() << "The selected input language is not directly supported when targeting the Ewasm machine "; - serr() << "and automatic translation is not available." << endl; - return false; - } - serr() << - "Warning: Yul is still experimental. Please use the output with care." << - endl; - - return true; + solThrow( + CommandLineValidationError, + "The selected input language is not directly supported when targeting the Ewasm machine " + "and automatic translation is not available." + ); + return; } else if (countEnabledOptions({g_strYulDialect, g_strMachine}) >= 1) - { - serr() << "--" << g_strYulDialect << " and --" << g_strMachine << " "; - serr() << "are only valid in assembly mode." << endl; - return false; - } + solThrow( + CommandLineValidationError, + "--" + g_strYulDialect + " and --" + g_strMachine + " are only valid in assembly mode." + ); if (m_args.count(g_strMetadataHash)) { @@ -1217,10 +1163,7 @@ bool CommandLineParser::processArgs() else if (hashStr == g_strNone) m_options.metadata.hash = CompilerStack::MetadataHash::None; else - { - serr() << "Invalid option for --" << g_strMetadataHash << ": " << hashStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strMetadataHash + ": " + hashStr); } if (m_args.count(g_strModelCheckerContracts)) @@ -1228,10 +1171,7 @@ bool CommandLineParser::processArgs() string contractsStr = m_args[g_strModelCheckerContracts].as(); optional contracts = ModelCheckerContracts::fromString(contractsStr); if (!contracts) - { - serr() << "Invalid option for --" << g_strModelCheckerContracts << ": " << contractsStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerContracts + ": " + contractsStr); m_options.modelChecker.settings.contracts = move(*contracts); } @@ -1243,10 +1183,7 @@ bool CommandLineParser::processArgs() string engineStr = m_args[g_strModelCheckerEngine].as(); optional engine = ModelCheckerEngine::fromString(engineStr); if (!engine) - { - serr() << "Invalid option for --" << g_strModelCheckerEngine << ": " << engineStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerEngine + ": " + engineStr); m_options.modelChecker.settings.engine = *engine; } @@ -1255,10 +1192,7 @@ bool CommandLineParser::processArgs() string invsStr = m_args[g_strModelCheckerInvariants].as(); optional invs = ModelCheckerInvariants::fromString(invsStr); if (!invs) - { - serr() << "Invalid option for --" << g_strModelCheckerInvariants << ": " << invsStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerInvariants + ": " + invsStr); m_options.modelChecker.settings.invariants = *invs; } @@ -1270,10 +1204,7 @@ bool CommandLineParser::processArgs() string solversStr = m_args[g_strModelCheckerSolvers].as(); optional solvers = smtutil::SMTSolverChoice::fromString(solversStr); if (!solvers) - { - serr() << "Invalid option for --" << g_strModelCheckerSolvers << ": " << solversStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerSolvers + ": " + solversStr); m_options.modelChecker.settings.solvers = *solvers; } @@ -1282,10 +1213,7 @@ bool CommandLineParser::processArgs() string targetsStr = m_args[g_strModelCheckerTargets].as(); optional targets = ModelCheckerTargets::fromString(targetsStr); if (!targets) - { - serr() << "Invalid option for --" << g_strModelCheckerTargets << ": " << targetsStr << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerTargets + ": " + targetsStr); m_options.modelChecker.settings.targets = *targets; } @@ -1307,27 +1235,21 @@ bool CommandLineParser::processArgs() m_options.input.errorRecovery = (m_args.count(g_strErrorRecovery) > 0); solAssert(m_options.input.mode == InputMode::Compiler || m_options.input.mode == InputMode::CompilerWithASTImport); - return true; } -bool CommandLineParser::parseCombinedJsonOption() +void CommandLineParser::parseCombinedJsonOption() { if (!m_args.count(g_strCombinedJson)) - return true; + return; set requests; for (string const& item: boost::split(requests, m_args[g_strCombinedJson].as(), boost::is_any_of(","))) if (CombinedJsonRequests::componentMap().count(item) == 0) - { - serr() << "Invalid option to --" << g_strCombinedJson << ": " << item << endl; - return false; - } + solThrow(CommandLineValidationError, "Invalid option to --" + g_strCombinedJson + ": " + item); m_options.compiler.combinedJsonRequests = CombinedJsonRequests{}; for (auto&& [componentName, component]: CombinedJsonRequests::componentMap()) m_options.compiler.combinedJsonRequests.value().*component = (requests.count(componentName) > 0); - - return true; } size_t CommandLineParser::countEnabledOptions(vector const& _optionNames) const diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index a1d13c690..c1a95a11f 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -234,27 +234,17 @@ struct CommandLineOptions }; /// Parses the command-line arguments and produces a filled-out CommandLineOptions structure. -/// Validates provided values and prints error messages in case of errors. +/// Validates provided values and reports errors by throwing @p CommandLineValidationErrors. class CommandLineParser { public: - explicit CommandLineParser(std::ostream& _serr): - m_serr(_serr) - {} - /// Parses the command-line arguments and fills out the internal CommandLineOptions structure. - /// Performs validation and prints error messages. - /// @return true if there were no validation errors when parsing options and the - /// CommandLineOptions structure has been fully initialized. false if there were errors - in - /// this case CommandLineOptions may be only partially filled out. May also return false if - /// there is not further processing necessary and the program should just exit. - bool parse(int _argc, char const* const* _argv); + /// @throws CommandLineValidationError if the arguments cannot be properly parsed or are invalid. + /// When an exception is thrown, the @p CommandLineOptions may be only partially filled out. + void parse(int _argc, char const* const* _argv); CommandLineOptions const& options() const { return m_options; } - /// Returns true if the parser has written anything to any of its output streams. - bool hasOutput() const { return m_hasOutput; } - static void printHelp(std::ostream& _out) { _out << optionsDescription(); } private: @@ -269,40 +259,32 @@ private: /// Uses boost::program_options to parse the command-line arguments and leaves the result in @a m_args. /// Also handles the arguments that result in information being printed followed by immediate exit. /// @returns false if parsing fails due to syntactical errors or the arguments not matching the description. - bool parseArgs(int _argc, char const* const* _argv); + void parseArgs(int _argc, char const* const* _argv); /// Validates parsed arguments stored in @a m_args and fills out the internal CommandLineOptions /// structure. - /// @return false if there are any validation errors, true otherwise. - bool processArgs(); + /// @throws CommandLineValidationError in case of validation errors. + void processArgs(); /// Parses the value supplied to --combined-json. - /// @return false if there are any validation errors, true otherwise. - bool parseCombinedJsonOption(); + /// @throws CommandLineValidationError in case of validation errors. + void parseCombinedJsonOption(); - /// Parses the names of the input files, remappings for all modes except for Standard JSON. - /// Does not check if files actually exist. - /// @return false if there are any validation errors, true otherwise. - bool parseInputPathsAndRemappings(); + /// Parses the names of the input files, remappings. Does not check if the files actually exist. + /// @throws CommandLineValidationError in case of validation errors. + void parseInputPathsAndRemappings(); /// Tries to read from the file @a _input or interprets @a _input literally if that fails. - /// It then tries to parse the contents and appends to m_options.libraries. - /// @return false if there are any validation errors, true otherwise. - bool parseLibraryOption(std::string const& _input); + /// It then tries to parse the contents and appends to @a m_options.libraries. + /// @throws CommandLineValidationError in case of validation errors. + void parseLibraryOption(std::string const& _input); - bool parseOutputSelection(); + void parseOutputSelection(); - bool checkMutuallyExclusive(std::vector const& _optionNames); + void checkMutuallyExclusive(std::vector const& _optionNames); size_t countEnabledOptions(std::vector const& _optionNames) const; static std::string joinOptionNames(std::vector const& _optionNames, std::string _separator = ", "); - /// Returns the stream that should receive error output. Sets m_hasOutput to true if the - /// stream has ever been used. - std::ostream& serr(); - - std::ostream& m_serr; - bool m_hasOutput = false; - CommandLineOptions m_options; /// Map of command-line arguments produced by boost::program_options. diff --git a/solc/Exceptions.h b/solc/Exceptions.h new file mode 100644 index 000000000..39a464b9e --- /dev/null +++ b/solc/Exceptions.h @@ -0,0 +1,34 @@ +/* + 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 +/** + * Exceptions used by the command-line interface. + */ + +#pragma once + +#include + +namespace solidity::frontend +{ + +struct CommandLineError: virtual util::Exception {}; +struct CommandLineExecutionError: virtual CommandLineError {}; +struct CommandLineValidationError: virtual CommandLineError {}; +struct CommandLineOutputError: virtual CommandLineError {}; + +} diff --git a/solc/main.cpp b/solc/main.cpp index 874ee13ca..ce69d20a7 100644 --- a/solc/main.cpp +++ b/solc/main.cpp @@ -62,12 +62,7 @@ int main(int argc, char** argv) { setDefaultOrCLocale(); solidity::frontend::CommandLineInterface cli(cin, cout, cerr); - bool success = - cli.parseArguments(argc, argv) && - cli.readInputFiles() && - cli.processInput(); - - return success ? 0 : 1; + return cli.run(argc, argv) ? 0 : 1; } catch (smtutil::SMTLogicError const& _exception) { diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index c153cd471..600bedbf5 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -182,7 +182,7 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 message.kind = EVMC_CALL; message.destination = EVMHost::convertToEVMC(m_contractAddress); } - message.gas = m_gas.convert_to(); + message.gas = InitialGas.convert_to(); evmc::result result = m_evmcHost->call(message); @@ -190,7 +190,7 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 if (_isCreation) m_contractAddress = EVMHost::convertFromEVMC(result.create_address); - m_gasUsed = m_gas - result.gas_left; + m_gasUsed = InitialGas - result.gas_left; m_transactionSuccessful = (result.status_code == EVMC_SUCCESS); if (m_showMessages) @@ -216,7 +216,7 @@ void ExecutionFramework::sendEther(h160 const& _addr, u256 const& _amount) message.value = EVMHost::convertToEVMC(_amount); message.kind = EVMC_CALL; message.destination = EVMHost::convertToEVMC(_addr); - message.gas = m_gas.convert_to(); + message.gas = InitialGas.convert_to(); m_evmcHost->call(message); } diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 0ee0214d4..53a09eaf8 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -273,6 +273,9 @@ private: } protected: + u256 const GasPrice = 10 * gwei; + u256 const InitialGas = 100000000; + void selectVM(evmc_capabilities _cap = evmc_capabilities::EVMC_CAPABILITY_EVM1); void reset(); @@ -302,8 +305,6 @@ protected: bool m_transactionSuccessful = true; util::h160 m_sender = account(0); util::h160 m_contractAddress; - u256 const m_gasPrice = 10 * gwei; - u256 const m_gas = 100000000; bytes m_output; u256 m_gasUsed; }; diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 2076eb993..d33dd208c 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -54,7 +54,7 @@ do shift ;; *) - matching_tests=$(find . -mindepth 1 -maxdepth 1 -type d -name "$1" | cut --characters 3- | sort) + matching_tests=$(find . -mindepth 1 -maxdepth 1 -type d -name "$1" | cut -c 3- | sort) if [[ $matching_tests == "" ]] then @@ -308,6 +308,61 @@ function test_solc_assembly_output fi } +function test_via_ir_equivalence() +{ + (( $# <= 2 )) || fail "This function accepts at most two arguments." + + if [[ $2 != --optimize ]] && [[ $2 != "" ]] + then + fail "The second argument must be --optimize if present." + fi + + local solidity_code="$1" + local optimize_flag="$2" + + local optimizer_flags=() + [[ $optimize_flag == "" ]] || optimizer_flags+=("$optimize_flag") + + local ir_output + ir_output=$( + echo "$solidity_code" | + msg_on_error --no-stderr "$SOLC" - --ir-optimized --debug-info location "${optimizer_flags[@]}" | + sed '/^Optimized IR:$/d' + ) + + local asm_output_two_stage asm_output_via_ir + asm_output_two_stage=$( + echo "$ir_output" | + msg_on_error --no-stderr "$SOLC" - --strict-assembly --asm "${optimizer_flags[@]}" | + sed '/^======= /d' | + sed '/^Text representation:$/d' + ) + asm_output_via_ir=$( + echo "$solidity_code" | + msg_on_error --no-stderr "$SOLC" - --experimental-via-ir --asm --debug-info location "${optimizer_flags[@]}" | + sed '/^======= /d' | + sed '/^EVM assembly:$/d' + ) + + diff_values "$asm_output_two_stage" "$asm_output_via_ir" --ignore-space-change --ignore-blank-lines + + local bin_output_two_stage bin_output_via_ir + bin_output_two_stage=$( + echo "$ir_output" | + msg_on_error --no-stderr "$SOLC" - --strict-assembly --bin "${optimizer_flags[@]}" | + sed '/^======= /d' | + sed '/^Binary representation:$/d' + ) + bin_output_via_ir=$( + echo "$solidity_code" | + msg_on_error --no-stderr "$SOLC" - --experimental-via-ir --bin "${optimizer_flags[@]}" | + sed '/^======= /d' | + sed '/^Binary:$/d' + ) + + diff_values "$bin_output_two_stage" "$bin_output_via_ir" --ignore-space-change --ignore-blank-lines +} + ## RUN echo "Checking that the bug list is up to date..." @@ -533,6 +588,36 @@ printTask "Testing assemble, yul, strict-assembly and optimize..." test_solc_assembly_output "{ let x := 0 }" "{ { } }" "--strict-assembly --optimize" ) +printTask "Testing the eqivalence of --experimental-via-ir and a two-stage compilation..." +( + printTask " - Smoke test" + test_via_ir_equivalence "contract C {}" + + printTask " - Smoke test (optimized)" + test_via_ir_equivalence "contract C {}" --optimize + + externalContracts=( + deposit_contract.sol + FixedFeeRegistrar.sol + _stringutils/stringutils.sol + ) + requiresOptimizer=( + deposit_contract.sol + FixedFeeRegistrar.sol + ) + + for contractFile in "${externalContracts[@]}" + do + if ! [[ "${requiresOptimizer[*]}" =~ $contractFile ]] + then + printTask " - ${contractFile}" + test_via_ir_equivalence "$(cat "${REPO_ROOT}/test/libsolidity/semanticTests/externalContracts/${contractFile}")" + fi + + printTask " - ${contractFile} (optimized)" + test_via_ir_equivalence "$(cat "${REPO_ROOT}/test/libsolidity/semanticTests/externalContracts/${contractFile}")" --optimize + done +) printTask "Testing standard input..." SOLTMPDIR=$(mktemp -d) diff --git a/test/cmdlineTests/yul_to_wasm_source_location_crash/args b/test/cmdlineTests/yul_to_wasm_source_location_crash/args new file mode 100644 index 000000000..254a1883c --- /dev/null +++ b/test/cmdlineTests/yul_to_wasm_source_location_crash/args @@ -0,0 +1 @@ +--strict-assembly --yul-dialect evm --machine ewasm --optimize --ewasm-ir diff --git a/test/cmdlineTests/yul_to_wasm_source_location_crash/err b/test/cmdlineTests/yul_to_wasm_source_location_crash/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/yul_to_wasm_source_location_crash/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/yul_to_wasm_source_location_crash/input.yul b/test/cmdlineTests/yul_to_wasm_source_location_crash/input.yul new file mode 100644 index 000000000..89e060931 --- /dev/null +++ b/test/cmdlineTests/yul_to_wasm_source_location_crash/input.yul @@ -0,0 +1,4 @@ +/// @use-src 0:"test.sol" +object "C" { + code { sstore(0,0) } +} diff --git a/test/cmdlineTests/yul_to_wasm_source_location_crash/output b/test/cmdlineTests/yul_to_wasm_source_location_crash/output new file mode 100644 index 000000000..29ff631aa --- /dev/null +++ b/test/cmdlineTests/yul_to_wasm_source_location_crash/output @@ -0,0 +1,34 @@ + +======= yul_to_wasm_source_location_crash/input.yul (Ewasm) ======= + +========================== + +Translated source: +/// @use-src 0:"test.sol" +object "C" { + code { + function main() + { + let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32) + let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32))))) + i64.store(0:i32, y) + i64.store(i32.add(0:i32, 8:i32), y) + i64.store(i32.add(0:i32, 16:i32), y) + i64.store(i32.add(0:i32, 24:i32), y) + i64.store(32:i32, y) + i64.store(i32.add(32:i32, 8:i32), y) + i64.store(i32.add(32:i32, 16:i32), y) + i64.store(i32.add(32:i32, 24:i32), y) + eth.storageStore(0:i32, 32:i32) + } + function bswap16(x:i32) -> y:i32 + { + y := i32.or(i32.and(i32.shl(x, 8:i32), 0xff00:i32), i32.and(i32.shr_u(x, 8:i32), 0xff:i32)) + } + function bswap32(x:i32) -> y:i32 + { + let hi:i32 := i32.shl(bswap16(x), 16:i32) + y := i32.or(hi, bswap16(i32.shr_u(x, 16:i32))) + } + } +} diff --git a/test/externalTests.sh b/test/externalTests.sh index 28af6f835..86f13401e 100755 --- a/test/externalTests.sh +++ b/test/externalTests.sh @@ -28,25 +28,17 @@ set -e -if [ ! -f "$1" ] -then - echo "Usage: $0 " - exit 1 -fi - -SOLJSON="$1" REPO_ROOT="$(dirname "$0")" source scripts/common.sh source test/externalTests/common.sh +verify_input "$@" + printTask "Running external tests..." -"$REPO_ROOT/externalTests/zeppelin.sh" "$SOLJSON" -"$REPO_ROOT/externalTests/gnosis.sh" "$SOLJSON" -"$REPO_ROOT/externalTests/gnosis-v2.sh" "$SOLJSON" -"$REPO_ROOT/externalTests/colony.sh" "$SOLJSON" -"$REPO_ROOT/externalTests/ens.sh" "$SOLJSON" - -# Disabled temporarily as it needs to be updated to latest Truffle first. -#test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050 +"$REPO_ROOT/externalTests/zeppelin.sh" "$@" +"$REPO_ROOT/externalTests/gnosis.sh" "$@" +"$REPO_ROOT/externalTests/gnosis-v2.sh" "$@" +"$REPO_ROOT/externalTests/colony.sh" "$@" +"$REPO_ROOT/externalTests/ens.sh" "$@" diff --git a/test/externalTests/colony.sh b/test/externalTests/colony.sh index e32385af6..dff745d68 100755 --- a/test/externalTests/colony.sh +++ b/test/externalTests/colony.sh @@ -24,8 +24,9 @@ set -e source scripts/common.sh source test/externalTests/common.sh -verify_input "$1" -SOLJSON="$1" +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$2" function compile_fn { yarn run provision:token:contracts; } function test_fn { yarn run test:contracts; } @@ -38,11 +39,16 @@ function colony_test local min_optimizer_level=3 local max_optimizer_level=3 - setup_solcjs "$DIR" "$SOLJSON" + local selected_optimizer_levels + selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")") + print_optimizer_levels_or_exit "$selected_optimizer_levels" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$branch" "$DIR" + [[ $BINARY_TYPE == native ]] && replace_global_solc "$BINARY_PATH" neutralize_package_json_hooks - force_truffle_compiler_settings "$config_file" "${DIR}/solc" "$min_optimizer_level" + force_truffle_compiler_settings "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$min_optimizer_level" yarn git submodule update --init @@ -52,10 +58,10 @@ function colony_test cd .. replace_version_pragmas - force_solc_modules "${DIR}/solc" + [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc" - for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do - truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn + for level in $selected_optimizer_levels; do + truffle_run_test "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$level" compile_fn test_fn done } diff --git a/test/externalTests/common.sh b/test/externalTests/common.sh index dbda3c3f4..b36861d07 100644 --- a/test/externalTests/common.sh +++ b/test/externalTests/common.sh @@ -24,59 +24,64 @@ set -e CURRENT_EVM_VERSION=london +function print_optimizer_levels_or_exit +{ + local selected_levels="$1" + + [[ $selected_levels != "" ]] || { printWarning "No steps to run. Exiting."; exit 0; } + + printLog "Selected optimizer levels: ${selected_levels}" +} + function verify_input { - if [ ! -f "$1" ]; then - printError "Usage: $0 " - exit 1 + local binary_type="$1" + local binary_path="$2" + + (( $# == 2 )) || fail "Usage: $0 native|solcjs " + [[ $binary_type == native || $binary_type == solcjs ]] || fail "Invalid binary type: '${binary_type}'. Must be either 'native' or 'solcjs'." + [[ -f "$binary_path" ]] || fail "The compiler binary does not exist at '${binary_path}'" +} + +function setup_solc +{ + local test_dir="$1" + local binary_type="$2" + local binary_path="$3" + local solcjs_branch="${4:-master}" + local install_dir="${5:-solc/}" + + [[ $binary_type == native || $binary_type == solcjs ]] || assertFail + + cd "$test_dir" + + if [[ $binary_type == solcjs ]] + then + printLog "Setting up solc-js..." + git clone --depth 1 -b "$solcjs_branch" https://github.com/ethereum/solc-js.git "$install_dir" + + pushd "$install_dir" + npm install + cp "$binary_path" soljson.js + SOLCVERSION=$(./solcjs --version) + popd + else + printLog "Setting up solc..." + SOLCVERSION=$("$binary_path" --version | tail -n 1 | sed -n -E 's/^Version: (.*)$/\1/p') fi -} -function verify_version_input -{ - if [ -z "$1" ] || [ ! -f "$1" ] || [ -z "$2" ]; then - printError "Usage: $0 " - exit 1 - fi -} - -function setup -{ - local soljson="$1" - local branch="$2" - - setup_solcjs "$DIR" "$soljson" "$branch" "solc" - cd solc -} - -function setup_solcjs -{ - local dir="$1" - local soljson="$2" - local branch="${3:-master}" - local path="${4:-solc/}" - - cd "$dir" - printLog "Setting up solc-js..." - git clone --depth 1 -b "$branch" https://github.com/ethereum/solc-js.git "$path" - - cd "$path" - - npm install - cp "$soljson" soljson.js - SOLCVERSION=$(./solcjs --version) - printLog "Using solcjs version $SOLCVERSION" - cd .. + SOLCVERSION_SHORT=$(echo "$SOLCVERSION" | sed -En 's/^([0-9.]+).*\+commit\.[0-9a-f]+.*$/\1/p') + printLog "Using compiler version $SOLCVERSION" } function download_project { local repo="$1" - local branch="$2" - local dir="$3" + local solcjs_branch="$2" + local test_dir="$3" - printLog "Cloning $branch of $repo..." - git clone --depth 1 "$repo" -b "$branch" "$dir/ext" + printLog "Cloning $solcjs_branch of $repo..." + git clone --depth 1 "$repo" -b "$solcjs_branch" "$test_dir/ext" cd ext echo "Current commit hash: $(git rev-parse HEAD)" } @@ -134,13 +139,19 @@ function force_solc_modules function force_truffle_compiler_settings { local config_file="$1" - local solc_path="$2" - local level="$3" - local evm_version="${4:-"$CURRENT_EVM_VERSION"}" + local binary_type="$2" + local solc_path="$3" + local level="$4" + local evm_version="${5:-"$CURRENT_EVM_VERSION"}" + + [[ $binary_type == native || $binary_type == solcjs ]] || assertFail + + [[ $binary_type == native ]] && local solc_path="native" printLog "Forcing Truffle compiler settings..." echo "-------------------------------------" echo "Config file: $config_file" + echo "Binary type: $binary_type" echo "Compiler path: $solc_path" echo "Optimization level: $level" echo "Optimizer settings: $(optimizer_settings_for_level "$level")" @@ -152,6 +163,42 @@ function force_truffle_compiler_settings echo "module.exports['compilers'] = $(truffle_compiler_settings "$solc_path" "$level" "$evm_version");" >> "$config_file" } +function force_hardhat_compiler_binary +{ + local config_file="$1" + local binary_type="$2" + local solc_path="$3" + + printLog "Configuring Hardhat..." + echo "-------------------------------------" + echo "Config file: ${config_file}" + echo "Binary type: ${binary_type}" + echo "Compiler path: ${solc_path}" + hardhat_solc_build_subtask "$SOLCVERSION_SHORT" "$SOLCVERSION" "$binary_type" "$solc_path" >> "$config_file" +} + +function force_hardhat_compiler_settings +{ + local config_file="$1" + local level="$2" + local evm_version="${3:-"$CURRENT_EVM_VERSION"}" + + printLog "Configuring Hardhat..." + echo "-------------------------------------" + echo "Config file: ${config_file}" + echo "Optimization level: ${level}" + echo "Optimizer settings: $(optimizer_settings_for_level "$level")" + echo "EVM version: ${evm_version}" + echo "Compiler version: ${SOLCVERSION_SHORT}" + echo "Compiler version (full): ${SOLCVERSION}" + echo "-------------------------------------" + + { + echo -n 'module.exports["solidity"] = ' + hardhat_compiler_settings "$SOLCVERSION_SHORT" "$level" "$evm_version" + } >> "$config_file" +} + function truffle_verify_compiler_version { local solc_version="$1" @@ -161,11 +208,26 @@ function truffle_verify_compiler_version grep "$full_solc_version" --with-filename --recursive build/contracts || fail "Wrong compiler version detected." } +function hardhat_verify_compiler_version +{ + local solc_version="$1" + local full_solc_version="$2" + + printLog "Verify that the correct version (${solc_version}/${full_solc_version}) of the compiler was used to compile the contracts..." + grep '"solcVersion": "'"${solc_version}"'"' --with-filename artifacts/build-info/*.json || fail "Wrong compiler version detected." + grep '"solcLongVersion": "'"${full_solc_version}"'"' --with-filename artifacts/build-info/*.json || fail "Wrong compiler version detected." +} + function truffle_clean { rm -rf build/ } +function hardhat_clean +{ + rm -rf artifacts/ cache/ +} + function run_test { local compile_fn="$1" @@ -189,12 +251,21 @@ function optimizer_settings_for_level 2) echo "{enabled: true}" ;; 3) echo "{enabled: true, details: {yul: true}}" ;; *) - printError "Optimizer level not found. Please define OPTIMIZER_LEVEL=[1, 2, 3]" - exit 1 + fail "Optimizer level not found. Please define OPTIMIZER_LEVEL=[1, 2, 3]" ;; esac } +function replace_global_solc +{ + local solc_path="$1" + + [[ ! -e solc ]] || fail "A file named 'solc' already exists in '${PWD}'." + + ln -s "$solc_path" solc + export PATH="$PWD:$PATH" +} + function truffle_compiler_settings { local solc_path="$1" @@ -212,6 +283,45 @@ function truffle_compiler_settings echo "}" } +function hardhat_solc_build_subtask { + local solc_version="$1" + local full_solc_version="$2" + local binary_type="$3" + local solc_path="$4" + + [[ $binary_type == native || $binary_type == solcjs ]] || assertFail + + [[ $binary_type == native ]] && local is_solcjs=false + [[ $binary_type == solcjs ]] && local is_solcjs=true + + echo "const {TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD} = require('hardhat/builtin-tasks/task-names');" + echo "const assert = require('assert');" + echo + echo "subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, async (args, hre, runSuper) => {" + echo " assert(args.solcVersion == '${solc_version}', 'Unexpected solc version: ' + args.solcVersion)" + echo " return {" + echo " compilerPath: '$(realpath "$solc_path")'," + echo " isSolcJs: ${is_solcjs}," + echo " version: args.solcVersion," + echo " longVersion: '${full_solc_version}'" + echo " }" + echo "})" +} + +function hardhat_compiler_settings { + local solc_version="$1" + local level="$2" + local evm_version="$3" + + echo "{" + echo " version: '${solc_version}'," + echo " settings: {" + echo " optimizer: $(optimizer_settings_for_level "$level")," + echo " evmVersion: '${evm_version}'" + echo " }" + echo "}" +} + function compile_and_run_test { local compile_fn="$1" @@ -233,16 +343,29 @@ function compile_and_run_test function truffle_run_test { local config_file="$1" - local solc_path="$2" - local optimizer_level="$3" - local compile_fn="$4" - local test_fn="$5" + local binary_type="$2" + local solc_path="$3" + local optimizer_level="$4" + local compile_fn="$5" + local test_fn="$6" truffle_clean - force_truffle_compiler_settings "$config_file" "$solc_path" "$optimizer_level" + force_truffle_compiler_settings "$config_file" "$binary_type" "$solc_path" "$optimizer_level" compile_and_run_test compile_fn test_fn truffle_verify_compiler_version } +function hardhat_run_test +{ + local config_file="$1" + local optimizer_level="$2" + local compile_fn="$3" + local test_fn="$4" + + hardhat_clean + force_hardhat_compiler_settings "$config_file" "$optimizer_level" + compile_and_run_test compile_fn test_fn hardhat_verify_compiler_version +} + function external_test { local name="$1" @@ -252,10 +375,7 @@ function external_test echo "===========================" DIR=$(mktemp -d -t "ext-test-${name}-XXXXXX") ( - if [ -z "$main_fn" ]; then - printError "Test main function not defined." - exit 1 - fi + [[ "$main_fn" != "" ]] || fail "Test main function not defined." $main_fn ) rm -rf "$DIR" diff --git a/test/externalTests/ens.sh b/test/externalTests/ens.sh index bbdc573e2..5c7d58270 100755 --- a/test/externalTests/ens.sh +++ b/test/externalTests/ens.sh @@ -24,8 +24,9 @@ set -e source scripts/common.sh source test/externalTests/common.sh -verify_input "$1" -export SOLJSON="$1" +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$2" function compile_fn { npx truffle compile; } function test_fn { npm run test; } @@ -38,22 +39,27 @@ function ens_test local min_optimizer_level=1 local max_optimizer_level=3 - setup_solcjs "$DIR" "$SOLJSON" + local selected_optimizer_levels + selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")") + print_optimizer_levels_or_exit "$selected_optimizer_levels" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$branch" "$DIR" + [[ $BINARY_TYPE == native ]] && replace_global_solc "$BINARY_PATH" # Use latest Truffle. Older versions crash on the output from 0.8.0. force_truffle_version ^5.1.55 neutralize_package_lock neutralize_package_json_hooks - force_truffle_compiler_settings "$config_file" "${DIR}/solc" "$min_optimizer_level" + force_truffle_compiler_settings "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$min_optimizer_level" npm install replace_version_pragmas - force_solc_modules "${DIR}/solc" + [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc" - for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do - truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn + for level in $selected_optimizer_levels; do + truffle_run_test "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$level" compile_fn test_fn done } diff --git a/test/externalTests/gnosis-v2.sh b/test/externalTests/gnosis-v2.sh index d92bcc186..b2f6c4a83 100755 --- a/test/externalTests/gnosis-v2.sh +++ b/test/externalTests/gnosis-v2.sh @@ -24,10 +24,10 @@ set -e source scripts/common.sh source test/externalTests/common.sh -verify_input "$1" -SOLJSON="$1" +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$2" -function install_fn { npm install --package-lock; } function compile_fn { npx truffle compile; } function test_fn { npm test; } @@ -39,22 +39,27 @@ function gnosis_safe_test local min_optimizer_level=2 local max_optimizer_level=3 - setup_solcjs "$DIR" "$SOLJSON" + local selected_optimizer_levels + selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")") + print_optimizer_levels_or_exit "$selected_optimizer_levels" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$branch" "$DIR" + [[ $BINARY_TYPE == native ]] && replace_global_solc "$BINARY_PATH" sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json sed -i -E 's|"@gnosis.pm/util-contracts": "[^"]+"|"@gnosis.pm/util-contracts": "github:solidity-external-tests/util-contracts#solc-7_080"|g' package.json neutralize_package_lock neutralize_package_json_hooks - force_truffle_compiler_settings "$config_file" "${DIR}/solc" "$min_optimizer_level" + force_truffle_compiler_settings "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$min_optimizer_level" npm install --package-lock replace_version_pragmas - force_solc_modules "${DIR}/solc" + [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc" - for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do - truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn + for level in $selected_optimizer_levels; do + truffle_run_test "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$level" compile_fn test_fn done } diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index b6d9ab0bc..69d068474 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -24,8 +24,9 @@ set -e source scripts/common.sh source test/externalTests/common.sh -verify_input "$1" -SOLJSON="$1" +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$2" function compile_fn { npx truffle compile; } function test_fn { npm test; } @@ -38,21 +39,26 @@ function gnosis_safe_test local min_optimizer_level=2 local max_optimizer_level=3 - setup_solcjs "$DIR" "$SOLJSON" + local selected_optimizer_levels + selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")") + print_optimizer_levels_or_exit "$selected_optimizer_levels" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$branch" "$DIR" + [[ $BINARY_TYPE == native ]] && replace_global_solc "$BINARY_PATH" sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json neutralize_package_lock neutralize_package_json_hooks - force_truffle_compiler_settings "$config_file" "${DIR}/solc" "$min_optimizer_level" + force_truffle_compiler_settings "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$min_optimizer_level" npm install --package-lock replace_version_pragmas - force_solc_modules "${DIR}/solc" + [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc" - for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do - truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn + for level in $selected_optimizer_levels; do + truffle_run_test "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$level" compile_fn test_fn done } diff --git a/test/externalTests/solc-js/solc-js.sh b/test/externalTests/solc-js/solc-js.sh index a3b24db9e..33b43e643 100755 --- a/test/externalTests/solc-js/solc-js.sh +++ b/test/externalTests/solc-js/solc-js.sh @@ -24,10 +24,11 @@ set -e source scripts/common.sh source test/externalTests/common.sh -verify_version_input "$1" "$2" SOLJSON="$1" VERSION="$2" +[[ $SOLJSON != "" && -f "$SOLJSON" && $VERSION != "" ]] || fail "Usage: $0 " + function compile_fn { echo "Nothing to compile."; } function test_fn { npm test; } @@ -37,7 +38,8 @@ function solcjs_test SOLCJS_INPUT_DIR="$TEST_DIR"/test/externalTests/solc-js # set up solc-js on the branch specified - setup "$SOLJSON" master + setup_solc "$DIR" solcjs "$SOLJSON" master solc/ + cd solc/ printLog "Updating index.js file..." echo "require('./determinism.js');" >> test/index.js diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index 1e23bb7ae..0759a3aec 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -24,32 +24,37 @@ set -e source scripts/common.sh source test/externalTests/common.sh -verify_input "$1" -SOLJSON="$1" +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$2" -function compile_fn { npx truffle compile; } -function test_fn { npm run test; } +function compile_fn { npm run compile; } +function test_fn { npm test; } function zeppelin_test { local repo="https://github.com/OpenZeppelin/openzeppelin-contracts.git" local branch=master - local config_file="truffle-config.js" + local config_file="hardhat.config.js" local min_optimizer_level=1 local max_optimizer_level=3 - setup_solcjs "$DIR" "$SOLJSON" + local selected_optimizer_levels + selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")") + print_optimizer_levels_or_exit "$selected_optimizer_levels" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$branch" "$DIR" neutralize_package_json_hooks - force_truffle_compiler_settings "$config_file" "${DIR}/solc" "$min_optimizer_level" + force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" + force_hardhat_compiler_settings "$config_file" "$min_optimizer_level" npm install replace_version_pragmas - force_solc_modules "${DIR}/solc" - for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do - truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn + for level in $selected_optimizer_levels; do + hardhat_run_test "$config_file" "$level" compile_fn test_fn done } diff --git a/test/liblangutil/CharStream.cpp b/test/liblangutil/CharStream.cpp index 9321b14e0..766a70098 100644 --- a/test/liblangutil/CharStream.cpp +++ b/test/liblangutil/CharStream.cpp @@ -28,6 +28,33 @@ #include +using namespace std; +using namespace solidity::test; + +namespace boost::test_tools::tt_detail +{ + +template<> +struct print_log_value> +{ + void operator()(std::ostream& _out, std::optional const& _value) const + { + _out << (_value ? to_string(*_value) : "[nullopt]"); + } +}; + +template<> +struct print_log_value +{ + void operator()(std::ostream& _out, nullopt_t const&) const + { + _out << "[nullopt]"; + } +}; + +} // namespace boost::test_tools::tt_detail + + namespace solidity::langutil::test { @@ -48,6 +75,62 @@ BOOST_AUTO_TEST_CASE(test_fail) ); } +namespace +{ +std::optional toPosition(int _line, int _column, string const& _text) +{ + return CharStream{_text, "source"}.translateLineColumnToPosition( + LineColumn{_line, _column} + ); +} + +} + +BOOST_AUTO_TEST_CASE(translateLineColumnToPosition) +{ + BOOST_CHECK_EQUAL(toPosition(-1, 0, "ABC"), nullopt); + BOOST_CHECK_EQUAL(toPosition(0, -1, "ABC"), nullopt); + + BOOST_CHECK_EQUAL(toPosition(0, 0, ""), 0); + BOOST_CHECK_EQUAL(toPosition(1, 0, ""), nullopt); + BOOST_CHECK_EQUAL(toPosition(0, 1, ""), nullopt); + + // With last line containing no LF + BOOST_CHECK_EQUAL(toPosition(0, 0, "ABC"), 0); + BOOST_CHECK_EQUAL(toPosition(0, 1, "ABC"), 1); + BOOST_CHECK_EQUAL(toPosition(0, 2, "ABC"), 2); + BOOST_CHECK_EQUAL(toPosition(0, 3, "ABC"), 3); + BOOST_CHECK_EQUAL(toPosition(0, 4, "ABC"), nullopt); + BOOST_CHECK_EQUAL(toPosition(1, 0, "ABC"), nullopt); + + BOOST_CHECK_EQUAL(toPosition(0, 3, "ABC\nDEF"), 3); + BOOST_CHECK_EQUAL(toPosition(0, 4, "ABC\nDEF"), nullopt); + BOOST_CHECK_EQUAL(toPosition(1, 0, "ABC\nDEF"), 4); + BOOST_CHECK_EQUAL(toPosition(1, 1, "ABC\nDEF"), 5); + BOOST_CHECK_EQUAL(toPosition(1, 2, "ABC\nDEF"), 6); + BOOST_CHECK_EQUAL(toPosition(1, 3, "ABC\nDEF"), 7); + BOOST_CHECK_EQUAL(toPosition(1, 4, "ABC\nDEF"), nullopt); + BOOST_CHECK_EQUAL(toPosition(2, 0, "ABC\nDEF"), nullopt); + BOOST_CHECK_EQUAL(toPosition(2, 1, "ABC\nDEF"), nullopt); + + // With last line containing LF + BOOST_CHECK_EQUAL(toPosition(0, 0, "ABC\nDEF\n"), 0); + BOOST_CHECK_EQUAL(toPosition(0, 1, "ABC\nDEF\n"), 1); + BOOST_CHECK_EQUAL(toPosition(0, 2, "ABC\nDEF\n"), 2); + + BOOST_CHECK_EQUAL(toPosition(1, 0, "ABC\nDEF\n"), 4); + BOOST_CHECK_EQUAL(toPosition(1, 1, "ABC\nDEF\n"), 5); + BOOST_CHECK_EQUAL(toPosition(1, 2, "ABC\nDEF\n"), 6); + BOOST_CHECK_EQUAL(toPosition(1, 3, "ABC\nDEF\n"), 7); + BOOST_CHECK_EQUAL(toPosition(1, 4, "ABC\nDEF\n"), nullopt); + BOOST_CHECK_EQUAL(toPosition(2, 0, "ABC\nDEF\n"), 8); + BOOST_CHECK_EQUAL(toPosition(2, 1, "ABC\nDEF\n"), nullopt); + + BOOST_CHECK_EQUAL(toPosition(2, 0, "ABC\nDEF\nGHI\n"), 8); + BOOST_CHECK_EQUAL(toPosition(2, 1, "ABC\nDEF\nGHI\n"), 9); + BOOST_CHECK_EQUAL(toPosition(2, 2, "ABC\nDEF\nGHI\n"), 10); +} + BOOST_AUTO_TEST_SUITE_END() -} // end namespaces +} diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index 8579e9ea4..82c6e7e18 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -16,17 +16,20 @@ */ // SPDX-License-Identifier: GPL-3.0 -#include -#include -#include -#include #include #include -#include +#include +#include + +#include +#include + #include #include -#include +#include #include +#include + #include #include #include @@ -72,8 +75,13 @@ ASTJSONTest::ASTJSONTest(string const& _filename) if (!boost::algorithm::ends_with(_filename, ".sol")) BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\".")); - m_astFilename = _filename.substr(0, _filename.size() - 4) + ".json"; - m_astParseOnlyFilename = _filename.substr(0, _filename.size() - 4) + "_parseOnly.json"; + string_view baseName = _filename; + baseName.remove_suffix(4); + + m_variants = { + TestVariant(baseName, CompilerStack::State::Parsed), + TestVariant(baseName, CompilerStack::State::AnalysisPerformed), + }; ifstream file(_filename); if (!file) @@ -102,26 +110,13 @@ ASTJSONTest::ASTJSONTest(string const& _filename) } m_sources.emplace_back(sourceName.empty() ? "a" : sourceName, source); - file.close(); - file.open(m_astFilename); - if (file) + + for (TestVariant& variant: m_variants) { - string line; - while (getline(file, line)) - m_expectation += line + "\n"; + variant.expectation = readFileAsString(variant.astFilename()); + boost::replace_all(variant.expectation, "\r\n", "\n"); } - - file.close(); - file.open(m_astParseOnlyFilename); - if (file) - { - string line; - while (getline(file, line)) - m_expectationParseOnly += line + "\n"; - } - - file.close(); } TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted) @@ -135,97 +130,76 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi sources[m_sources[i].first] = m_sources[i].second; sourceIndices[m_sources[i].first] = static_cast(i + 1); } - c.setSources(sources); - c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + bool resultsMatch = true; - if (!c.compile(CompilerStack::State::Parsed)) + for (TestVariant& variant: m_variants) { - SourceReferenceFormatter formatter(_stream, c, _formatted, false); - formatter.printErrorInformation(c.errors()); - return TestResult::FatalError; + c.reset(); + c.setSources(sources); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + + if (!c.parseAndAnalyze(variant.stopAfter)) + { + // Ignore non-fatal analysis errors, we only want to export. + if (c.state() > CompilerStack::State::Parsed) + continue; + + SourceReferenceFormatter formatter(_stream, c, _formatted, false); + formatter.printErrorInformation(c.errors()); + return TestResult::FatalError; + } + + resultsMatch = resultsMatch && runTest( + variant, + sourceIndices, + c, + _stream, + _linePrefix, + _formatted + ); } - bool resultsMatch = runTest( - m_expectationParseOnly, - m_resultParseOnly, - sourceIndices, - c, - "parseOnly", - _stream, - _linePrefix, - _formatted - ); - - c.reset(); - c.setSources(sources); - c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); - if (!c.parse()) - { - // Empty Expectations means we expect failure - if (m_expectation.empty()) - return resultsMatch ? TestResult::Success : TestResult::Failure; - - SourceReferenceFormatter{_stream, c, _formatted, false} - .printErrorInformation(c.errors()); - return TestResult::FatalError; - } - - c.analyze(); - - resultsMatch = runTest( - m_expectation, - m_result, - sourceIndices, - c, - "", - _stream, - _linePrefix, - _formatted - ) && resultsMatch; - return resultsMatch ? TestResult::Success : TestResult::Failure; } bool ASTJSONTest::runTest( - string& _expectation, - string& _result, + TestVariant& _variant, map const& _sourceIndices, CompilerStack& _compiler, - string const& _variation, ostream& _stream, string const& _linePrefix, bool const _formatted ) { if (m_sources.size() > 1) - _result += "[\n"; + _variant.result += "[\n"; for (size_t i = 0; i < m_sources.size(); i++) { ostringstream result; ASTJsonConverter(_compiler.state(), _sourceIndices).print(result, _compiler.ast(m_sources[i].first)); - _result += result.str(); + _variant.result += result.str(); if (i != m_sources.size() - 1) - _result += ","; - _result += "\n"; + _variant.result += ","; + _variant.result += "\n"; } if (m_sources.size() > 1) - _result += "]\n"; + _variant.result += "]\n"; - replaceTagWithVersion(_expectation); + replaceTagWithVersion(_variant.expectation); - if (_expectation != _result) + if (_variant.expectation != _variant.result) { string nextIndentLevel = _linePrefix + " "; AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result" << - (!_variation.empty() ? " (" + _variation + "):" : ":") << + (!_variant.name().empty() ? " (" + _variant.name() + "):" : ":") << endl; { - istringstream stream(_expectation); + istringstream stream(_variant.expectation); string line; while (getline(stream, line)) _stream << nextIndentLevel << line << endl; @@ -235,10 +209,10 @@ bool ASTJSONTest::runTest( AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result" << - (!_variation.empty() ? " (" + _variation + "):" : ":") << + (!_variant.name().empty() ? " (" + _variant.name() + "):" : ":") << endl; { - istringstream stream(_result); + istringstream stream(_variant.result); string line; while (getline(stream, line)) _stream << nextIndentLevel << line << endl; @@ -266,14 +240,18 @@ void ASTJSONTest::printSource(ostream& _stream, string const& _linePrefix, bool void ASTJSONTest::printUpdatedExpectations(std::ostream&, std::string const&) const { - updateExpectation(m_astFilename, m_result, ""); - updateExpectation(m_astParseOnlyFilename, m_resultParseOnly, "parseOnly "); + for (TestVariant const& variant: m_variants) + updateExpectation( + variant.astFilename(), + variant.result, + variant.name().empty() ? "" : variant.name() + " " + ); } -void ASTJSONTest::updateExpectation(string const& _filename, string const& _expectation, string const& _variation) const +void ASTJSONTest::updateExpectation(string const& _filename, string const& _expectation, string const& _variant) const { ofstream file(_filename.c_str()); - if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write " + _variation + "AST expectation to \"" + _filename + "\".")); + if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write " + _variant + "AST expectation to \"" + _filename + "\".")); file.exceptions(ios::badbit); string replacedResult = _expectation; diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h index ac57277ac..3365de589 100644 --- a/test/libsolidity/ASTJSONTest.h +++ b/test/libsolidity/ASTJSONTest.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include @@ -37,6 +38,32 @@ namespace solidity::frontend::test class ASTJSONTest: public TestCase { public: + struct TestVariant + { + TestVariant(std::string_view _baseName, CompilerStack::State _stopAfter): + baseName(_baseName), + stopAfter(_stopAfter) + {} + + std::string name() const + { + return stopAfter == CompilerStack::State::Parsed ? "parseOnly" : ""; + } + + std::string astFilename() const + { + return std::string(baseName) + + (name().empty() ? "" : "_") + + name() + + ".json"; + } + + std::string baseName; + CompilerStack::State stopAfter; + std::string result; + std::string expectation; + }; + static std::unique_ptr create(Config const& _config) { return std::make_unique(_config.filename); @@ -49,11 +76,9 @@ public: void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override; private: bool runTest( - std::string& _expectation, - std::string& _result, + TestVariant& _testVariant, std::map const& _sourceIndices, CompilerStack& _compiler, - std::string const& _variation, std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false @@ -61,15 +86,12 @@ private: void updateExpectation( std::string const& _filename, std::string const& _expectation, - std::string const& _variation + std::string const& _variant ) const; + std::vector m_variants; + std::vector> m_sources; - std::string m_expectationParseOnly; - std::string m_astFilename; - std::string m_astParseOnlyFilename; - std::string m_result; - std::string m_resultParseOnly; }; } diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 84c7a5e0b..5dce2211f 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -100,7 +100,7 @@ ErrorList AnalysisFramework::filterErrors(ErrorList const& _errorList, bool _inc for (auto const& messagePrefix: m_messagesToCut) if (currentError->comment()->find(messagePrefix) == 0) { - SourceLocation const* location = boost::get_error_info(*currentError); + SourceLocation const* location = currentError->sourceLocation(); // sufficient for now, but in future we might clone the error completely, including the secondary location newError = make_shared( currentError->errorId(), diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index c5ee04044..4fbb16614 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -407,7 +407,10 @@ TestCase::TestResult SemanticTest::runTest( if (m_transactionSuccessful == test.call().expectations.failure) success = false; if (success && !checkGasCostExpectation(test, _isYulRun)) + { + success = false; m_gasCostFailure = true; + } test.setFailure(!m_transactionSuccessful); test.setRawBytes(bytes()); @@ -562,14 +565,14 @@ bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _comp // We don't check gas if enforce gas cost is not active // or test is run with abi encoder v1 only // or gas used less than threshold for enforcing feature + // or the test has used up all available gas (test will fail anyway) // or setting is "ir" and it's not included in expectations // or if the called function is an isoltest builtin e.g. `smokeTest` or `storageEmpty` if ( !m_enforceGasCost || - ( - (setting == "ir" || m_gasUsed < m_enforceGasCostMinValue || m_gasUsed >= m_gas) && - io_test.call().expectations.gasUsed.count(setting) == 0 - ) || + m_gasUsed < m_enforceGasCostMinValue || + m_gasUsed >= InitialGas || + (setting == "ir" && io_test.call().expectations.gasUsed.count(setting) == 0) || io_test.call().kind == FunctionCall::Kind::Builtin ) return true; diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index e5a6b8cf7..473114961 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1607,30 +1607,6 @@ BOOST_AUTO_TEST_CASE(library_call_protection) ) } -BOOST_AUTO_TEST_CASE(library_staticcall_delegatecall) -{ - char const* sourceCode = R"( - library Lib { - function x() public view returns (uint) { - return 1; - } - } - contract Test { - uint t; - function f() public returns (uint) { - t = 2; - return this.g(); - } - function g() public view returns (uint) { - return Lib.x(); - } - } - )"; - compileAndRun(sourceCode, 0, "Lib"); - compileAndRun(sourceCode, 0, "Test", bytes(), map{{":Lib", m_contractAddress}}); - ABI_CHECK(callContractFunction("f()"), encodeArgs(1)); -} - BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) { char const* sourceCode = R"( @@ -1786,49 +1762,6 @@ BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data) ); } -BOOST_AUTO_TEST_CASE(storing_invalid_boolean) -{ - char const* sourceCode = R"( - contract C { - event Ev(bool); - bool public perm; - function set() public returns(uint) { - bool tmp; - assembly { - tmp := 5 - } - perm = tmp; - return 1; - } - function ret() public returns(bool) { - bool tmp; - assembly { - tmp := 5 - } - return tmp; - } - function ev() public returns(uint) { - bool tmp; - assembly { - tmp := 5 - } - emit Ev(tmp); - return 1; - } - } - )"; - compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("set()"), encodeArgs(1)); - ABI_CHECK(callContractFunction("perm()"), encodeArgs(1)); - ABI_CHECK(callContractFunction("ret()"), encodeArgs(1)); - ABI_CHECK(callContractFunction("ev()"), encodeArgs(1)); - BOOST_REQUIRE_EQUAL(numLogs(), 1); - BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); - BOOST_CHECK(logData(0) == encodeArgs(1)); - BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Ev(bool)"))); -} - BOOST_AUTO_TEST_CASE(struct_referencing) { static char const* sourceCode = R"( @@ -2059,70 +1992,6 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi) // ABI_CHECK(callContractFunction("f()"), encodeArgs(5)); //} -BOOST_AUTO_TEST_CASE(packed_storage_structs_delete) -{ - char const* sourceCode = R"( - contract C { - struct str { uint8 a; uint16 b; uint8 c; } - uint8 x; - uint16 y; - str data; - function test() public returns (uint) { - x = 1; - y = 2; - data.a = 2; - data.b = 0xabcd; - data.c = 0xfa; - if (x != 1 || y != 2 || data.a != 2 || data.b != 0xabcd || data.c != 0xfa) - return 2; - delete y; - delete data.b; - if (x != 1 || y != 0 || data.a != 2 || data.b != 0 || data.c != 0xfa) - return 3; - delete x; - delete data; - return 1; - } - } - )"; - compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("test()"), encodeArgs(1)); - BOOST_CHECK(storageEmpty(m_contractAddress)); -} - -BOOST_AUTO_TEST_CASE(invalid_enum_logged) -{ - char const* sourceCode = R"( - contract C { - enum X { A, B } - event Log(X); - - function test_log() public returns (uint) { - X garbled = X.A; - assembly { - garbled := 5 - } - emit Log(garbled); - return 1; - } - function test_log_ok() public returns (uint) { - X x = X.A; - emit Log(x); - return 1; - } - } - )"; - compileAndRun(sourceCode, 0, "C"); - ABI_CHECK(callContractFunction("test_log_ok()"), encodeArgs(u256(1))); - BOOST_REQUIRE_EQUAL(numLogs(), 1); - BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); - BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_REQUIRE_EQUAL(logTopic(0, 0), util::keccak256(string("Log(uint8)"))); - BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(0))); - - ABI_CHECK(callContractFunction("test_log()"), panicData(PanicCode::EnumConversionError)); -} - BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) { char const* sourceCode = R"( @@ -2164,31 +2033,6 @@ BOOST_AUTO_TEST_CASE(failing_send) BOOST_REQUIRE(callContractFunction("callHelper(address)", c_helperAddress) == encodeArgs(true, 20)); } -BOOST_AUTO_TEST_CASE(return_string) -{ - char const* sourceCode = R"( - contract Main { - string public s; - function set(string calldata _s) external { - s = _s; - } - function get1() public returns (string memory r) { - return s; - } - function get2() public returns (string memory r) { - r = s; - } - } - )"; - compileAndRun(sourceCode, 0, "Main"); - string s("Julia"); - bytes args = encodeArgs(u256(0x20), u256(s.length()), s); - BOOST_REQUIRE(callContractFunction("set(string)", asString(args)) == encodeArgs()); - ABI_CHECK(callContractFunction("get1()"), args); - ABI_CHECK(callContractFunction("get2()"), args); - ABI_CHECK(callContractFunction("s()"), args); -} - BOOST_AUTO_TEST_CASE(return_multiple_strings_of_various_sizes) { char const* sourceCode = R"( @@ -2343,28 +2187,6 @@ BOOST_AUTO_TEST_CASE(return_bytes_internal) } } -BOOST_AUTO_TEST_CASE(memory_types_initialisation) -{ - char const* sourceCode = R"( - contract Test { - mapping(uint=>uint) data; - function stat() public returns (uint[5] memory) - { - data[2] = 3; // make sure to use some memory - } - function dyn() public returns (uint[] memory) { stat(); } - function nested() public returns (uint[3][] memory) { stat(); } - function nestedStat() public returns (uint[3][7] memory) { stat(); } - } - )"; - compileAndRun(sourceCode, 0, "Test"); - - ABI_CHECK(callContractFunction("stat()"), encodeArgs(vector(5))); - ABI_CHECK(callContractFunction("dyn()"), encodeArgs(u256(0x20), u256(0))); - ABI_CHECK(callContractFunction("nested()"), encodeArgs(u256(0x20), u256(0))); - ABI_CHECK(callContractFunction("nestedStat()"), encodeArgs(vector(3 * 7))); -} - BOOST_AUTO_TEST_CASE(calldata_struct_short) { char const* sourceCode = R"( @@ -2718,38 +2540,6 @@ BOOST_AUTO_TEST_CASE(nested_mixed_string_as_public_mapping_key) ), encodeArgs(u256(i - 3))); } -BOOST_AUTO_TEST_CASE(constant_string_literal) -{ - char const* sourceCode = R"( - contract Test { - bytes32 constant public b = "abcdefghijklmnopq"; - string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; - - constructor() { - string memory xx = x; - bytes32 bb = b; - } - function getB() public returns (bytes32) { return b; } - function getX() public returns (string memory) { return x; } - function getX2() public returns (string memory r) { r = x; } - function unused() public returns (uint) { - "unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused"; - return 2; - } - } - )"; - - compileAndRun(sourceCode); - string longStr = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; - string shortStr = "abcdefghijklmnopq"; - ABI_CHECK(callContractFunction("b()"), encodeArgs(shortStr)); - ABI_CHECK(callContractFunction("x()"), encodeDyn(longStr)); - ABI_CHECK(callContractFunction("getB()"), encodeArgs(shortStr)); - ABI_CHECK(callContractFunction("getX()"), encodeDyn(longStr)); - ABI_CHECK(callContractFunction("getX2()"), encodeDyn(longStr)); - ABI_CHECK(callContractFunction("unused()"), encodeArgs(2)); -} - BOOST_AUTO_TEST_CASE(library_call) { char const* sourceCode = R"( diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index 4998b628b..d3e512450 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -118,9 +118,10 @@ void SyntaxTest::filterObtainedErrors() { for (auto const& currentError: filterErrors(compiler().errors(), true)) { - int locationStart = -1, locationEnd = -1; + int locationStart = -1; + int locationEnd = -1; string sourceName; - if (auto location = boost::get_error_info(*currentError)) + if (SourceLocation const* location = currentError->sourceLocation()) { solAssert(location->sourceName, ""); sourceName = *location->sourceName; diff --git a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol index c696002ad..945de3cfe 100644 --- a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol +++ b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol @@ -11,6 +11,9 @@ contract C { // compileViaYul: also // ---- // constructor(): 1, 2, 3 -> +// gas irOptimized: 143598 +// gas legacy: 183490 +// gas legacyOptimized: 151938 // a(uint256): 0 -> 1 // a(uint256): 1 -> 2 // a(uint256): 2 -> 3 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol index c6e46a7fa..ddead0503 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol @@ -11,5 +11,8 @@ contract Creator { // compileViaYul: also // ---- // constructor(): 1, 2, 3, 4 -> +// gas irOptimized: 132278 +// gas legacy: 176789 +// gas legacyOptimized: 129585 // r() -> 4 // ch() -> 3 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol index e81755ff9..1a93f53b3 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol @@ -10,5 +10,8 @@ contract Test { // compileViaYul: also // ---- // constructor(): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> +// gas irOptimized: 291443 +// gas legacy: 309842 +// gas legacyOptimized: 260801 // m_x() -> 7 // m_s() -> 0x20, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" diff --git a/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol b/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol index bb271ec17..6ee258bd6 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol @@ -19,5 +19,8 @@ contract Main { // compileViaYul: also // ---- // constructor(): "abc", true +// gas irOptimized: 112563 +// gas legacy: 145838 +// gas legacyOptimized: 104017 // getFlag() -> true // getName() -> "abc" diff --git a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol index 099202c95..ab90a0bb9 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol @@ -12,6 +12,9 @@ contract C { // compileViaYul: also // ---- // constructor(): 1, 2, 3, 4 -> +// gas irOptimized: 180731 +// gas legacy: 221377 +// gas legacyOptimized: 177671 // a() -> 1 // b(uint256): 0 -> 2 // b(uint256): 1 -> 3 diff --git a/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol b/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol index 757a5481f..41a050fc4 100644 --- a/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol +++ b/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol @@ -15,4 +15,5 @@ contract B is A { // compileViaYul: true // ---- // constructor() -> +// gas irOptimized: 122233 // y() -> 42 diff --git a/test/libsolidity/semanticTests/constructor_ihneritance_init_order_2.sol b/test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol similarity index 75% rename from test/libsolidity/semanticTests/constructor_ihneritance_init_order_2.sol rename to test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol index 44a7fb2f3..db58499ea 100644 --- a/test/libsolidity/semanticTests/constructor_ihneritance_init_order_2.sol +++ b/test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol @@ -12,4 +12,7 @@ contract B is A { // compileViaYul: also // ---- // constructor() -> +// gas irOptimized: 122233 +// gas legacy: 135046 +// gas legacyOptimized: 116176 // y() -> 42 diff --git a/test/libsolidity/semanticTests/constructor_with_params.sol b/test/libsolidity/semanticTests/constructor_with_params.sol index e3ac5b386..cb6192774 100644 --- a/test/libsolidity/semanticTests/constructor_with_params.sol +++ b/test/libsolidity/semanticTests/constructor_with_params.sol @@ -11,5 +11,7 @@ contract C { // compileViaYul: also // ---- // constructor(): 2, 0 -> +// gas irOptimized: 104227 +// gas legacy: 117158 // i() -> 2 // k() -> 0 diff --git a/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol b/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol index 89cb202c6..fe3c95b54 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol @@ -23,6 +23,9 @@ contract D is B, C { // compileViaYul: also // ---- // constructor(): 2, 0 -> +// gas irOptimized: 159542 +// gas legacy: 170665 +// gas legacyOptimized: 145396 // i() -> 2 // j() -> 2 // k() -> 1 diff --git a/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol b/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol index d477bbc0d..3d90783f8 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol @@ -14,5 +14,8 @@ contract D is C { // compileViaYul: also // ---- // constructor(): 2, 0 -> +// gas irOptimized: 124844 +// gas legacy: 139250 +// gas legacyOptimized: 119367 // i() -> 2 // k() -> 1 diff --git a/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol b/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol new file mode 100644 index 000000000..33cec7482 --- /dev/null +++ b/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol @@ -0,0 +1,24 @@ +contract C { + enum X { A, B } + event Log(X); + + function test_log() public returns (uint) { + X garbled = X.A; + assembly { + garbled := 5 + } + emit Log(garbled); + return 1; + } + function test_log_ok() public returns (uint) { + X x = X.A; + emit Log(x); + return 1; + } +} +// ==== +// compileViaYul: also +// ---- +// test_log_ok() -> 1 +// ~ emit Log(uint8): 0x00 +// test_log() -> FAILURE, hex"4e487b71", 0x21 diff --git a/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol b/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol index 128cf00ea..690f555dc 100644 --- a/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol +++ b/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol @@ -17,6 +17,8 @@ contract C { // compileViaYul: also // ---- // constructor() -> -// gas legacy: 249112 +// gas irOptimized: 177344 +// gas legacy: 250376 +// gas legacyOptimized: 174522 // deposit(bytes32), 18 wei: 0x1234 -> // ~ emit Deposit(address,bytes32,uint256) from 0xf01f7809444bd9a93a854361c6fae3f23d9e23db: #0x0fdd67305928fcac8d213d1e47bfa6165cd0b87b, #0x1234, 0x00 diff --git a/test/libsolidity/semanticTests/events/event_signature_in_library.sol b/test/libsolidity/semanticTests/events/event_signature_in_library.sol index e43fc4c64..b301ebfd5 100644 --- a/test/libsolidity/semanticTests/events/event_signature_in_library.sol +++ b/test/libsolidity/semanticTests/events/event_signature_in_library.sol @@ -20,4 +20,4 @@ contract C { // ---- // constructor() // ~ emit E((uint8,int16),(uint8,int16)): #0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5, 0x00, 0x00 -// gas legacy: 150662 +// gas legacy: 150602 diff --git a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol index 9205de434..fc0b416fd 100644 --- a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol +++ b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol @@ -76,7 +76,7 @@ contract FixedFeeRegistrar is Registrar { // compileViaYul: also // ---- // constructor() -// gas irOptimized: 425623 +// gas irOptimized: 426283 // gas legacy: 936897 // gas legacyOptimized: 490983 // reserve(string), 69 ether: 0x20, 3, "abc" -> diff --git a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol index f054497e9..ed9a07f7f 100644 --- a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol +++ b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol @@ -178,9 +178,9 @@ contract DepositContract is IDepositContract, ERC165 { // compileViaYul: also // ---- // constructor() -// gas irOptimized: 1558013 -// gas legacy: 2580394 -// gas legacyOptimized: 1775403 +// gas irOptimized: 1558001 +// gas legacy: 2436584 +// gas legacyOptimized: 1776483 // supportsInterface(bytes4): 0x0 -> 0 // supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 # // supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id # diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol index 01d2403a6..9de7a30d8 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol @@ -50,8 +50,8 @@ contract test { // compileViaYul: also // ---- // constructor() -// gas irOptimized: 1924584 -// gas legacy: 2602700 +// gas irOptimized: 1924392 +// gas legacy: 2480887 // gas legacyOptimized: 1874490 // div(int256,int256): 3141592653589793238, 88714123 -> 35412542528203691288251815328 // gas irOptimized: 22137 diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol index c31664c85..11001fffa 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol @@ -51,7 +51,7 @@ contract test { // ---- // constructor() // gas irOptimized: 1778342 -// gas legacy: 2356230 +// gas legacy: 2250130 // gas legacyOptimized: 1746528 // div(uint256,uint256): 3141592653589793238, 88714123 -> 35412542528203691288251815328 // gas irOptimized: 22004 diff --git a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol index 1fc85adff..763a8acda 100644 --- a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol +++ b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol @@ -36,7 +36,7 @@ contract test { // ---- // constructor() // gas irOptimized: 465357 -// gas legacy: 733634 +// gas legacy: 672749 // gas legacyOptimized: 479606 // prb_pi() -> 3141592656369545286 // gas irOptimized: 57478 diff --git a/test/libsolidity/semanticTests/externalContracts/strings.sol b/test/libsolidity/semanticTests/externalContracts/strings.sol index 238ed2184..7c4028bb9 100644 --- a/test/libsolidity/semanticTests/externalContracts/strings.sol +++ b/test/libsolidity/semanticTests/externalContracts/strings.sol @@ -52,7 +52,7 @@ contract test { // ---- // constructor() // gas irOptimized: 702619 -// gas legacy: 1188228 +// gas legacy: 1130761 // gas legacyOptimized: 750416 // toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0 // gas irOptimized: 22660 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol index 56e458110..2da7c2dd6 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol @@ -17,4 +17,7 @@ contract D { // compileViaYul: also // ---- // constructor(): 2 -> +// gas irOptimized: 200295 +// gas legacy: 245842 +// gas legacyOptimized: 195676 // f() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol index 725a54b54..0b0633c6d 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol @@ -18,4 +18,7 @@ contract D { // compileViaYul: also // ---- // constructor(): 2 -> +// gas irOptimized: 200458 +// gas legacy: 246202 +// gas legacyOptimized: 195914 // f() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol index 9546f1098..942faa048 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol @@ -25,8 +25,9 @@ contract C { // compileViaYul: also // ---- // constructor(), 1 ether -> +// gas irOptimized: 308423 // gas legacy: 465314 -// gas legacyOptimized: 510004 +// gas legacyOptimized: 304481 // f(uint256): 0 -> FAILURE // f(uint256): 1 -> FAILURE // f(uint256): 2 -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol index f426e628e..26faf248f 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol @@ -27,6 +27,8 @@ contract C { // revertStrings: debug // ---- // constructor(), 1 ether -> +// gas irOptimized: 448383 +// gas legacy: 834272 // gas legacyOptimized: 510004 // f(uint256): 0 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" // f(uint256): 1 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol index 5ca46b4e1..b1d9299d8 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol @@ -41,6 +41,9 @@ contract test { // compileViaYul: also // ---- // constructor(), 20 wei -> +// gas irOptimized: 285350 +// gas legacy: 402654 +// gas legacyOptimized: 274470 // sendAmount(uint256): 5 -> 5 // outOfGas() -> FAILURE # call to helper should not succeed but amount should be transferred anyway # // checkState() -> false, 15 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol index 3da540807..9e2491ac1 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol @@ -40,6 +40,9 @@ contract test { // compileViaYul: also // ---- // constructor(), 20 wei -> +// gas irOptimized: 285350 +// gas legacy: 402654 +// gas legacyOptimized: 274470 // sendAmount(uint256): 5 -> 5 // outOfGas() -> FAILURE # call to helper should not succeed but amount should be transferred anyway # // checkState() -> false, 15 diff --git a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol index 5f821ff3d..617a6dec2 100644 --- a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol +++ b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol @@ -19,4 +19,7 @@ contract Main { // compileViaYul: also // ---- // constructor(), 20 wei -> +// gas irOptimized: 102862 +// gas legacy: 116691 +// gas legacyOptimized: 100361 // s() -> true diff --git a/test/libsolidity/semanticTests/immutable/use_scratch.sol b/test/libsolidity/semanticTests/immutable/use_scratch.sol index 71381fc9b..4fb3bf245 100644 --- a/test/libsolidity/semanticTests/immutable/use_scratch.sol +++ b/test/libsolidity/semanticTests/immutable/use_scratch.sol @@ -17,5 +17,8 @@ contract C { // compileViaYul: also // ---- // constructor(): 3 -> +// gas irOptimized: 137184 +// gas legacy: 209361 +// gas legacyOptimized: 139324 // f() -> 84, 23 // m(uint256): 3 -> 7 diff --git a/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol b/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol index 057b3b8e4..b2f0f8a6b 100644 --- a/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol +++ b/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol @@ -42,6 +42,9 @@ contract Main { // compileViaYul: also // ---- // constructor(), 22 wei -> +// gas irOptimized: 288778 +// gas legacy: 402045 +// gas legacyOptimized: 266772 // getFlag() -> true // getName() -> "abc" // getBalances() -> 12, 10 diff --git a/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol b/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol index 59ad2cd84..5af1e5cdc 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol @@ -18,9 +18,9 @@ contract ClientReceipt { // compileViaYul: also // ---- // constructor(), 2000 wei -> -// gas irOptimized: 191881 -// gas legacy: 235167 -// gas legacyOptimized: 180756 +// gas irOptimized: 184076 +// gas legacy: 235195 +// gas legacyOptimized: 176766 // balance -> 1500 // gas irOptimized: 191881 // gas legacy: 235167 diff --git a/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol b/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol new file mode 100644 index 000000000..205a4ae3d --- /dev/null +++ b/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol @@ -0,0 +1,12 @@ +contract C { + function f(string memory s) external pure returns (string memory) { + return s; + } +} +// NOTE: The test is here to illustrate the problem with formatting control chars in strings in +// test expectations but unfortunately it can only be triggered manually. It does not test anything +// unless you introduce a difference in expectations to force isoltest to reformat them. +// ==== +// compileViaYul: also +// ---- +// f(string): 0x20, 16, "\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83" -> 0x20, 16, "\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83" # Input/Output: "😃😃😃😃" # diff --git a/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol b/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol new file mode 100644 index 000000000..d566f7180 --- /dev/null +++ b/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol @@ -0,0 +1,20 @@ +library Lib { + function x() public view returns (uint) { + return 1; + } +} +contract Test { + uint t; + function f() public returns (uint) { + t = 2; + return this.g(); + } + function g() public view returns (uint) { + return Lib.x(); + } +} +// ==== +// compileViaYul: also +// ---- +// library: Lib +// f() -> 1 diff --git a/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol b/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol new file mode 100644 index 000000000..7ad6b6167 --- /dev/null +++ b/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol @@ -0,0 +1,17 @@ +contract Test { + mapping(uint=>uint) data; + function stat() public returns (uint[5] memory) + { + data[2] = 3; // make sure to use some memory + } + function dyn() public returns (uint[] memory) { stat(); } + function nested() public returns (uint[3][] memory) { stat(); } + function nestedStat() public returns (uint[3][7] memory) { stat(); } +} +// ==== +// compileViaYul: also +// ---- +// stat() -> 0, 0, 0, 0, 0 +// dyn() -> 0x20, 0 +// nested() -> 0x20, 0 +// nestedStat() -> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 diff --git a/test/libsolidity/semanticTests/smoke/constructor.sol b/test/libsolidity/semanticTests/smoke/constructor.sol index 3837fe071..7667c2443 100644 --- a/test/libsolidity/semanticTests/smoke/constructor.sol +++ b/test/libsolidity/semanticTests/smoke/constructor.sol @@ -14,7 +14,9 @@ contract C { // compileViaYul: also // ---- // constructor(), 2 wei: 3 -> -// gas legacy: 148000 +// gas irOptimized: 111723 +// gas legacy: 151416 +// gas legacyOptimized: 108388 // state() -> 3 // balance() -> 2 // balance -> 2 diff --git a/test/libsolidity/semanticTests/state/blockhash_basic.sol b/test/libsolidity/semanticTests/state/blockhash_basic.sol index 528c8aea6..d4dbffcb8 100644 --- a/test/libsolidity/semanticTests/state/blockhash_basic.sol +++ b/test/libsolidity/semanticTests/state/blockhash_basic.sol @@ -14,6 +14,9 @@ contract C { // compileViaYul: also // ---- // constructor() +// gas irOptimized: 119839 +// gas legacy: 155081 +// gas legacyOptimized: 107997 // genesisHash() -> 0x3737373737373737373737373737373737373737373737373737373737373737 // currentHash() -> 0 // f(uint256): 0 -> 0x3737373737373737373737373737373737373737373737373737373737373737 diff --git a/test/libsolidity/semanticTests/strings/constant_string_literal.sol b/test/libsolidity/semanticTests/strings/constant_string_literal.sol new file mode 100644 index 000000000..9c112c1fa --- /dev/null +++ b/test/libsolidity/semanticTests/strings/constant_string_literal.sol @@ -0,0 +1,25 @@ +contract Test { + bytes32 constant public b = "abcdefghijklmnopq"; + string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; + + constructor() { + string memory xx = x; + bytes32 bb = b; + } + function getB() public returns (bytes32) { return b; } + function getX() public returns (string memory) { return x; } + function getX2() public returns (string memory r) { r = x; } + function unused() public returns (uint) { + "unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused"; + return 2; + } +} +// ==== +// compileViaYul: also +// ---- +// b() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000 +// x() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 +// getB() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000 +// getX() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 +// getX2() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 +// unused() -> 2 diff --git a/test/libsolidity/semanticTests/strings/return_string.sol b/test/libsolidity/semanticTests/strings/return_string.sol new file mode 100644 index 000000000..f221a5e15 --- /dev/null +++ b/test/libsolidity/semanticTests/strings/return_string.sol @@ -0,0 +1,20 @@ +contract Main { + string public s; + function set(string calldata _s) external { + s = _s; + } + function get1() public returns (string memory r) { + return s; + } + function get2() public returns (string memory r) { + r = s; + } +} +// ==== +// compileToEwasm: also +// compileViaYul: also +// ---- +// set(string): 0x20, 5, "Julia" -> +// get1() -> 0x20, 5, "Julia" +// get2() -> 0x20, 5, "Julia" +// s() -> 0x20, 5, "Julia" diff --git a/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol b/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol new file mode 100644 index 000000000..8d4931554 --- /dev/null +++ b/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol @@ -0,0 +1,27 @@ +contract C { + struct str { uint8 a; uint16 b; uint8 c; } + uint8 x; + uint16 y; + str data; + function test() public returns (uint) { + x = 1; + y = 2; + data.a = 2; + data.b = 0xabcd; + data.c = 0xfa; + if (x != 1 || y != 2 || data.a != 2 || data.b != 0xabcd || data.c != 0xfa) + return 2; + delete y; + delete data.b; + if (x != 1 || y != 0 || data.a != 2 || data.b != 0 || data.c != 0xfa) + return 3; + delete x; + delete data; + return 1; + } +} +// ==== +// compileViaYul: also +// ---- +// test() -> 1 +// storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol index 4db14ff73..efe2ee114 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol @@ -116,7 +116,7 @@ contract ERC20 { // constructor() // ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14 // gas irOptimized: 442239 -// gas legacy: 861547 +// gas legacy: 861559 // gas legacyOptimized: 420959 // totalSupply() -> 20 // gas irOptimized: 23415 diff --git a/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol b/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol new file mode 100644 index 000000000..930ded40b --- /dev/null +++ b/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol @@ -0,0 +1,35 @@ +contract C { + event Ev(bool); + bool public perm; + function set() public returns(uint) { + bool tmp; + assembly { + tmp := 5 + } + perm = tmp; + return 1; + } + function ret() public returns(bool) { + bool tmp; + assembly { + tmp := 5 + } + return tmp; + } + function ev() public returns(uint) { + bool tmp; + assembly { + tmp := 5 + } + emit Ev(tmp); + return 1; + } +} +// ==== +// compileViaYul: also +// ---- +// set() -> 1 +// perm() -> true +// ret() -> true +// ev() -> 1 +// ~ emit Ev(bool): true diff --git a/test/libsolidity/semanticTests/various/address_code.sol b/test/libsolidity/semanticTests/various/address_code.sol index 8e840fd01..6072d5ac3 100644 --- a/test/libsolidity/semanticTests/various/address_code.sol +++ b/test/libsolidity/semanticTests/various/address_code.sol @@ -13,10 +13,13 @@ contract C { function h() public view returns (uint) { return address(1).code.length; } } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // constructor() -> +// gas irOptimized: 199687 +// gas legacy: 241124 +// gas legacyOptimized: 155549 // initCode() -> 0x20, 0 // f() -> true // g() -> 0 diff --git a/test/libsolidity/semanticTests/various/code_length.sol b/test/libsolidity/semanticTests/various/code_length.sol index 53b3534b2..ad4b6f874 100644 --- a/test/libsolidity/semanticTests/various/code_length.sol +++ b/test/libsolidity/semanticTests/various/code_length.sol @@ -58,8 +58,9 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // constructor() +// gas legacy: 126455 // f(): true, true -> true, true diff --git a/test/libsolidity/semanticTests/various/codebalance_assembly.sol b/test/libsolidity/semanticTests/various/codebalance_assembly.sol index 2df9c5b4f..98f4e2969 100644 --- a/test/libsolidity/semanticTests/various/codebalance_assembly.sol +++ b/test/libsolidity/semanticTests/various/codebalance_assembly.sol @@ -23,6 +23,7 @@ contract C { // compileViaYul: also // ---- // constructor(), 23 wei -> +// gas legacy: 100517 // f() -> 0 // g() -> 1 // h() -> 23 diff --git a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol index 5303cdd52..57942979a 100644 --- a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol +++ b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol @@ -21,3 +21,4 @@ contract C { // compileViaYul: also // ---- // constructor() -> +// gas irOptimized: 104337 diff --git a/test/libsolidity/semanticTests/various/negative_stack_height.sol b/test/libsolidity/semanticTests/various/negative_stack_height.sol index ba1bebc18..52fce16f5 100644 --- a/test/libsolidity/semanticTests/various/negative_stack_height.sol +++ b/test/libsolidity/semanticTests/various/negative_stack_height.sol @@ -65,3 +65,5 @@ contract C { // compileViaYul: false // ---- // constructor() -> +// gas legacy: 588138 +// gas legacyOptimized: 349636 diff --git a/test/libsolidity/semanticTests/various/senders_balance.sol b/test/libsolidity/semanticTests/various/senders_balance.sol index 08b83401c..600e72e3e 100644 --- a/test/libsolidity/semanticTests/various/senders_balance.sol +++ b/test/libsolidity/semanticTests/various/senders_balance.sol @@ -19,4 +19,7 @@ contract D { // compileViaYul: also // ---- // constructor(), 27 wei -> +// gas irOptimized: 175261 +// gas legacy: 222977 +// gas legacyOptimized: 169779 // f() -> 27 diff --git a/test/libsolidity/semanticTests/various/value_complex.sol b/test/libsolidity/semanticTests/various/value_complex.sol index 8d091ec98..bebf7557f 100644 --- a/test/libsolidity/semanticTests/various/value_complex.sol +++ b/test/libsolidity/semanticTests/various/value_complex.sol @@ -22,4 +22,7 @@ contract test { // compileViaYul: also // ---- // constructor(), 20 wei -> +// gas irOptimized: 185891 +// gas legacy: 265006 +// gas legacyOptimized: 182842 // sendAmount(uint256): 5 -> 8 diff --git a/test/libsolidity/semanticTests/various/value_insane.sol b/test/libsolidity/semanticTests/various/value_insane.sol index c81570626..9edd8061a 100644 --- a/test/libsolidity/semanticTests/various/value_insane.sol +++ b/test/libsolidity/semanticTests/various/value_insane.sol @@ -21,4 +21,7 @@ contract test { // compileViaYul: also // ---- // constructor(), 20 wei -> +// gas irOptimized: 187835 +// gas legacy: 266728 +// gas legacyOptimized: 184762 // sendAmount(uint256): 5 -> 8 diff --git a/test/libsolidity/smtCheckerTests/abi/abi_decode_array.sol b/test/libsolidity/smtCheckerTests/abi/abi_decode_array.sol index 3c88329a3..e2c089493 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_decode_array.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_decode_array.sol @@ -32,9 +32,6 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 1218: (1009-1037): CHC: Error trying to invoke SMT solver. -// Warning 1218: (1056-1084): CHC: Error trying to invoke SMT solver. -// Warning 1218: (1103-1131): CHC: Error trying to invoke SMT solver. // Warning 6328: (182-210): CHC: Assertion violation happens here. // Warning 6328: (335-363): CHC: Assertion violation happens here. // Warning 6328: (414-442): CHC: Assertion violation happens here. @@ -42,9 +39,6 @@ contract C { // Warning 6328: (607-635): CHC: Assertion violation happens here. // Warning 6328: (654-682): CHC: Assertion violation happens here. // Warning 6328: (879-916): CHC: Assertion violation happens here. -// Warning 6328: (1009-1037): CHC: Assertion violation might happen here. -// Warning 6328: (1056-1084): CHC: Assertion violation might happen here. -// Warning 6328: (1103-1131): CHC: Assertion violation might happen here. -// Warning 4661: (1009-1037): BMC: Assertion violation happens here. -// Warning 4661: (1056-1084): BMC: Assertion violation happens here. -// Warning 4661: (1103-1131): BMC: Assertion violation happens here. +// Warning 6328: (1009-1037): CHC: Assertion violation happens here. +// Warning 6328: (1056-1084): CHC: Assertion violation happens here. +// Warning 6328: (1103-1131): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol index dbf423741..61e755d82 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol @@ -13,9 +13,7 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 1218: (337-375): CHC: Error trying to invoke SMT solver. // Warning 1218: (394-432): CHC: Error trying to invoke SMT solver. -// Warning 6328: (337-375): CHC: Assertion violation might happen here. +// Warning 6328: (337-375): CHC: Assertion violation happens here. // Warning 6328: (394-432): CHC: Assertion violation might happen here. -// Warning 4661: (337-375): BMC: Assertion violation happens here. // Warning 4661: (394-432): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/array_members/length_1d_struct_array_2d_1.sol b/test/libsolidity/smtCheckerTests/array_members/length_1d_struct_array_2d_1.sol index 71571d944..ddda215df 100644 --- a/test/libsolidity/smtCheckerTests/array_members/length_1d_struct_array_2d_1.sol +++ b/test/libsolidity/smtCheckerTests/array_members/length_1d_struct_array_2d_1.sol @@ -20,5 +20,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Info 1180: Contract invariant(s) for :C:\n!(s1.arr.length <= 0)\n!(s2.arr.length <= 0)\n(((s2.arr[0].length + ((- 1) * s1.arr[0].length)) <= 0) && ((s1.arr[0].length + ((- 1) * s2.arr[0].length)) <= 0))\n diff --git a/test/libsolidity/smtCheckerTests/array_members/length_same_after_assignment_3_fail.sol b/test/libsolidity/smtCheckerTests/array_members/length_same_after_assignment_3_fail.sol index 062b668c3..7a7db383b 100644 --- a/test/libsolidity/smtCheckerTests/array_members/length_same_after_assignment_3_fail.sol +++ b/test/libsolidity/smtCheckerTests/array_members/length_same_after_assignment_3_fail.sol @@ -31,4 +31,4 @@ contract C { // Warning 6328: (349-375): CHC: Assertion violation happens here.\nCounterexample:\narr = [[], [], [], [], [], [], [], [], []]\nx = 0\ny = 0\nz = 9\nt = 0\n\nTransaction trace:\nC.constructor()\nState: arr = [[], [], [], [], [], [], [], [], []]\nC.f() // Warning 6328: (379-402): CHC: Assertion violation happens here.\nCounterexample:\narr = [[], [], [], [], [], [], [], [], []]\nx = 0\ny = 0\nz = 9\nt = 0\n\nTransaction trace:\nC.constructor()\nState: arr = [[], [], [], [], [], [], [], [], []]\nC.f() // Warning 6328: (406-432): CHC: Assertion violation happens here.\nCounterexample:\narr = [[], [], [], [], [], [], [], [], []]\nx = 0\ny = 0\nz = 9\nt = 0\n\nTransaction trace:\nC.constructor()\nState: arr = [[], [], [], [], [], [], [], [], []]\nC.f() -// Info 1180: Contract invariant(s) for :C:\n!(arr.length <= 3)\n!(arr.length <= 5)\n!(arr.length <= 7)\n!(arr.length <= 8)\n +// Info 1180: Contract invariant(s) for :C:\n!(arr.length <= 7)\n!(arr.length <= 8)\n diff --git a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_1d.sol b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_1d.sol index 30f194eb7..0d16306b7 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_1d.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_1d.sol @@ -17,5 +17,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- -// Warning 6328: (199-229): CHC: Assertion violation happens here. +// Warning 6328: (199-229): CHC: Assertion violation happens here.\nCounterexample:\nb = [1]\n\nTransaction trace:\nC.constructor()\nState: b = []\nC.g() diff --git a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_1d.sol b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_1d.sol index ad3ba7823..66776ed49 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_1d.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_1d.sol @@ -14,4 +14,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (204-230): CHC: Assertion violation happens here.\nCounterexample:\nb = [0, 0]\nlength = 2\n\nTransaction trace:\nC.constructor()\nState: b = []\nC.f() +// Warning 6328: (204-230): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/array_members/push_overflow_2_safe_no_overflow_assumption.sol b/test/libsolidity/smtCheckerTests/array_members/push_overflow_2_safe_no_overflow_assumption.sol index 60b11c91a..046cf59a1 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_overflow_2_safe_no_overflow_assumption.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_overflow_2_safe_no_overflow_assumption.sol @@ -13,4 +13,3 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Info 1180: Contract invariant(s) for :C:\n(x.length >= 0)\n 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 index dcda253ce..42313dee9 100644 --- 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 @@ -13,5 +13,5 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 6328: (90-116): CHC: Assertion violation happens here.\nCounterexample:\narray2d = [[[0]]]\nlast = 0\n\nTransaction trace:\nC.constructor()\nState: array2d = []\nC.l() -// Warning 6328: (170-186): CHC: Assertion violation happens here. -// Warning 6328: (190-246): CHC: Assertion violation happens here. +// Warning 6328: (170-186): CHC: Assertion violation happens here.\nCounterexample:\narray2d = [[[0]]]\nlast = 1\n\nTransaction trace:\nC.constructor()\nState: array2d = []\nC.l() +// Warning 6328: (190-246): CHC: Assertion violation happens here.\nCounterexample:\narray2d = [[[0]]]\nlast = 1\n\nTransaction trace:\nC.constructor()\nState: array2d = []\nC.l() diff --git a/test/libsolidity/smtCheckerTests/array_members/push_storage_ref_unsafe_aliasing.sol b/test/libsolidity/smtCheckerTests/array_members/push_storage_ref_unsafe_aliasing.sol index 87b9d92bf..a8669fb60 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_storage_ref_unsafe_aliasing.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_storage_ref_unsafe_aliasing.sol @@ -13,7 +13,8 @@ contract C { // ==== // SMTEngine: all // SMTIgnoreOS: macos +// SMTIgnoreCex: yes // ---- -// Warning 6368: (188-192): CHC: Out of bounds access happens here.\nCounterexample:\na = []\nb = [32]\n\nTransaction trace:\nC.constructor()\nState: a = []\nC.f() -// Warning 6368: (188-195): CHC: Out of bounds access happens here.\nCounterexample:\n\nb = [32]\n\nTransaction trace:\nC.constructor()\nState: a = []\nC.f() -// Warning 6328: (181-202): CHC: Assertion violation happens here.\nCounterexample:\n\nb = [32]\n\nTransaction trace:\nC.constructor()\nState: a = []\nC.f() +// Warning 6368: (188-192): CHC: Out of bounds access happens here. +// Warning 6368: (188-195): CHC: Out of bounds access happens here. +// Warning 6328: (181-202): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_4.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_4.sol index e8f750d07..4fa420ff1 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_4.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_4.sol @@ -11,11 +11,12 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 4984: (82-85): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here. // Warning 4984: (154-160): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here. // Warning 4984: (212-218): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here. -// Warning 6328: (180-219): CHC: Assertion violation happens here. +// Warning 6328: (180-219): CHC: Assertion violation happens here.\nCounterexample:\nc = 1\n\nTransaction trace:\nC.constructor()\nState: c = 0\nC.f(){ msg.value: 11 }\nState: c = 1\nC.inv() // Info 1180: Contract invariant(s) for :C:\n(((11 * c) + ((- 1) * (:var 1).balances[address(this)])) <= 0)\n // Warning 2661: (82-85): BMC: Overflow (resulting value larger than 2**256 - 1) happens here. // Warning 2661: (154-160): BMC: Overflow (resulting value larger than 2**256 - 1) happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls.sol index e46dfda34..96223b7e9 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls.sol @@ -12,8 +12,9 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 1218: (131-165): CHC: Error trying to invoke SMT solver. // Warning 6328: (131-165): CHC: Assertion violation might happen here. -// Info 1180: Reentrancy property(ies) for :C:\n(!( >= 2) && (((:var 0).balances[address(this)] + ((- 1) * (:var 1).balances[address(this)])) >= 0))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this).balance == x)\n = 2 -> Assertion failed at assert(address(this).balance >= x)\n +// Info 1180: Reentrancy property(ies) for :C:\n(!( >= 2) && (((:var 1).balances[address(this)] + ((- 1) * (:var 0).balances[address(this)])) <= 0))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this).balance == x)\n = 2 -> Assertion failed at assert(address(this).balance >= x)\n // Warning 4661: (131-165): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_2.sol index 28c4734bd..c53f156d6 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_2.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_2.sol @@ -12,4 +12,4 @@ contract C { // ---- // Warning 9302: (82-93): Return value of low-level calls not used. // Warning 6328: (97-131): CHC: Assertion violation happens here. -// Info 1180: Reentrancy property(ies) for :C:\n((((:var 1).balances[address(this)] + ((- 1) * (:var 0).balances[address(this)])) <= 0) && !( >= 2))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this).balance == x)\n = 2 -> Assertion failed at assert(address(this).balance >= x)\n +// Info 1180: Reentrancy property(ies) for :C:\n(!( >= 2) && (((:var 1).balances[address(this)] + ((- 1) * (:var 0).balances[address(this)])) <= 0))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this).balance == x)\n = 2 -> Assertion failed at assert(address(this).balance >= x)\n diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_mutex.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_mutex.sol index 559f67e19..76443dfd0 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_mutex.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_receive_ext_calls_mutex.sol @@ -22,4 +22,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (277-310): CHC: Assertion violation happens here. -// Info 1180: Reentrancy property(ies) for :C:\n((!lock || (((:var 3).balances[address(this)] + ((- 1) * (:var 1).balances[address(this)])) <= 0)) && !( = 1) && (lock' || !lock) && (!lock || (((:var 3).balances[address(this)] + ((- 1) * (:var 1).balances[address(this)])) >= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this).balance == x)\n = 2 -> Assertion failed at assert(address(this).balance < x)\n +// Info 1180: Reentrancy property(ies) for :C:\n((lock' || !lock) && !( = 1) && (!lock || (((:var 3).balances[address(this)] + ((- 1) * (:var 1).balances[address(this)])) >= 0)) && (!lock || (((:var 3).balances[address(this)] + ((- 1) * (:var 1).balances[address(this)])) <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this).balance == x)\n = 2 -> Assertion failed at assert(address(this).balance < x)\n diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol index 1e4ec7a32..bd30b77d1 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol @@ -19,5 +19,5 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (280-314): CHC: Assertion violation happens here. -// Info 1180: Contract invariant(s) for :C:\n((!(c <= 1) || !((:var 1).balances[address(this)] <= 91)) && !((:var 1).balances[address(this)] <= 82) && (!(c <= 0) || !((:var 1).balances[address(this)] <= 100)))\n +// Info 1180: Contract invariant(s) for :C:\n((!(c <= 1) || !((:var 1).balances[address(this)] <= 90)) && !((:var 1).balances[address(this)] <= 81) && (!(c <= 0) || !((:var 1).balances[address(this)] <= 100)))\n // Warning 1236: (175-190): BMC: Insufficient funds happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol index 0b3a432e8..5df0b9995 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol @@ -16,7 +16,6 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 1218: (193-226): CHC: Error trying to invoke SMT solver. // Warning 6328: (193-226): CHC: Assertion violation might happen here. // Warning 6328: (245-279): CHC: Assertion violation happens here. // Warning 6328: (298-332): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/this_does_not_change_external_call.sol b/test/libsolidity/smtCheckerTests/blockchain_state/this_does_not_change_external_call.sol index 0b5136dca..f16964501 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/this_does_not_change_external_call.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/this_does_not_change_external_call.sol @@ -18,4 +18,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Info 1180: Contract invariant(s) for :C:\n(((address(this) + ((- 1) * t)) <= 0) && ((address(this) + ((- 1) * t)) >= 0))\nReentrancy property(ies) for :C:\n((!( >= 2) || !((t + ((- 1) * address(this))) = 0)) && (!((t + ((- 1) * address(this))) <= 0) || ((t' + ((- 1) * address(this))) <= 0)) && (!((t + ((- 1) * address(this))) >= 0) || ((address(this) + ((- 1) * t')) <= 0)))\n((( <= 0) || !((t + ((- 1) * address(this))) = 0)) && (!((t + ((- 1) * address(this))) <= 0) || ((t' + ((- 1) * address(this))) <= 0)) && (!((t + ((- 1) * address(this))) >= 0) || ((address(this) + ((- 1) * t')) <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this) == t)\n = 2 -> Assertion failed at assert(a == t)\n +// Info 1180: Contract invariant(s) for :C:\n(((address(this) + ((- 1) * t)) <= 0) && ((address(this) + ((- 1) * t)) >= 0))\nReentrancy property(ies) for :C:\n((!((t + ((- 1) * address(this))) = 0) || ( <= 0)) && (!((t + ((- 1) * address(this))) <= 0) || ((t' + ((- 1) * address(this))) <= 0)) && (!((t + ((- 1) * address(this))) >= 0) || ((address(this) + ((- 1) * t')) <= 0)))\n((!( >= 2) || !((t + ((- 1) * address(this))) = 0)) && (!((t + ((- 1) * address(this))) <= 0) || ((t' + ((- 1) * address(this))) <= 0)) && (!((t + ((- 1) * address(this))) >= 0) || ((address(this) + ((- 1) * t')) <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(address(this) == t)\n = 2 -> Assertion failed at assert(a == t)\n diff --git a/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/branches_in_modifiers_2.sol b/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/branches_in_modifiers_2.sol index 9765fc1f9..f08a26bf7 100644 --- a/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/branches_in_modifiers_2.sol +++ b/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/branches_in_modifiers_2.sol @@ -42,7 +42,8 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (255-269): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0\nC.test()\n C.reset_if_overflow() -- internal call -// Warning 6328: (502-519): CHC: Assertion violation happens here. +// Warning 6328: (502-519): CHC: Assertion violation happens here.\nCounterexample:\nx = 2\noldx = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0\nC.set(1)\nState: x = 1\nC.test()\n C.reset_if_overflow() -- internal call // Warning 6328: (615-629): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0\nC.set(10)\nState: x = 10\nC.test()\n C.reset_if_overflow() -- internal call diff --git a/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/triple_nested_if.sol b/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/triple_nested_if.sol index 09ee2b2b2..472ef8785 100644 --- a/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/triple_nested_if.sol +++ b/test/libsolidity/smtCheckerTests/control_flow/branches_with_return/triple_nested_if.sol @@ -17,5 +17,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Info 1180: Contract invariant(s) for :C:\n((c <= 0) && (a <= 0) && (b <= 0))\n diff --git a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_compare_hashes.sol b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_compare_hashes.sol index a49aeac09..79b30a123 100644 --- a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_compare_hashes.sol +++ b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_compare_hashes.sol @@ -12,6 +12,12 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 6328: (150-164): CHC: Assertion violation happens here. -// Warning 6328: (168-182): CHC: Assertion violation happens here. -// Warning 6328: (186-200): CHC: Assertion violation happens here. +// Warning 1218: (150-164): CHC: Error trying to invoke SMT solver. +// Warning 1218: (168-182): CHC: Error trying to invoke SMT solver. +// Warning 1218: (186-200): CHC: Error trying to invoke SMT solver. +// Warning 6328: (150-164): CHC: Assertion violation might happen here. +// Warning 6328: (168-182): CHC: Assertion violation might happen here. +// Warning 6328: (186-200): CHC: Assertion violation might happen here. +// Warning 4661: (150-164): BMC: Assertion violation happens here. +// Warning 4661: (168-182): BMC: Assertion violation happens here. +// Warning 4661: (186-200): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_not_same.sol b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_not_same.sol index a8c6199d0..59a011f24 100644 --- a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_not_same.sol +++ b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_not_same.sol @@ -12,4 +12,6 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 6328: (196-210): CHC: Assertion violation happens here. +// Warning 1218: (196-210): CHC: Error trying to invoke SMT solver. +// Warning 6328: (196-210): CHC: Assertion violation might happen here. +// Warning 4661: (196-210): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_input_over_state_same_output.sol b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_input_over_state_same_output.sol index 228f9d580..94eedd599 100644 --- a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_input_over_state_same_output.sol +++ b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_input_over_state_same_output.sol @@ -37,4 +37,15 @@ contract C { // ==== // SMTEngine: all // ---- -// Info 1180: Contract invariant(s) for :C:\n(((erc + ((- 1) * ecrecover(tuple_constructor(h, v, r, s)))) <= 0) && ((erc + ((- 1) * ecrecover(tuple_constructor(h, v, r, s)))) >= 0))\n(((kec + ((- 1) * keccak256(data))) >= 0) && ((kec + ((- 1) * keccak256(data))) <= 0))\n(((rip + ((- 1) * ripemd160(data))) <= 0) && ((rip + ((- 1) * ripemd160(data))) >= 0))\n(((sha + ((- 1) * sha256(data))) <= 0) && ((sha + ((- 1) * sha256(data))) >= 0))\n +// Warning 1218: (544-563): CHC: Error trying to invoke SMT solver. +// Warning 1218: (567-586): CHC: Error trying to invoke SMT solver. +// Warning 1218: (590-609): CHC: Error trying to invoke SMT solver. +// Warning 1218: (613-632): CHC: Error trying to invoke SMT solver. +// Warning 6328: (544-563): CHC: Assertion violation might happen here. +// Warning 6328: (567-586): CHC: Assertion violation might happen here. +// Warning 6328: (590-609): CHC: Assertion violation might happen here. +// Warning 6328: (613-632): CHC: Assertion violation might happen here. +// Warning 4661: (544-563): BMC: Assertion violation happens here. +// Warning 4661: (567-586): BMC: Assertion violation happens here. +// Warning 4661: (590-609): BMC: Assertion violation happens here. +// Warning 4661: (613-632): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_mutex.sol b/test/libsolidity/smtCheckerTests/external_calls/call_mutex.sol index a31093924..e85eb00aa 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_mutex.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_mutex.sol @@ -23,4 +23,4 @@ contract C { // SMTEngine: all // ---- // Warning 9302: (218-234): Return value of low-level calls not used. -// Info 1180: Reentrancy property(ies) for :C:\n((!lock || ((x' + ((- 1) * x)) = 0)) && ( <= 0) && (lock' || !lock))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(y == x)\n +// Info 1180: Reentrancy property(ies) for :C:\n((lock' || !lock) && ( <= 0) && (!lock || ((x' + ((- 1) * x)) = 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(y == x)\n diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_reentrancy_view.sol b/test/libsolidity/smtCheckerTests/external_calls/call_reentrancy_view.sol index f0f844fff..87a9e2261 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_reentrancy_view.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_reentrancy_view.sol @@ -15,4 +15,4 @@ contract C { // Warning 2519: (106-112): This declaration shadows an existing declaration. // Warning 2072: (106-112): Unused local variable. // Warning 2072: (114-131): Unused local variable. -// Info 1180: Contract invariant(s) for :C:\n(x <= 0)\nReentrancy property(ies) for :C:\n((!(x <= 0) || (x' <= 0)) && (( <= 0) || !(x <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 0)\n +// Info 1180: Contract invariant(s) for :C:\n(x <= 0)\nReentrancy property(ies) for :C:\n((!(x <= 0) || (x' <= 0)) && (!(x <= 0) || ( <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 0)\n diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_safe.sol b/test/libsolidity/smtCheckerTests/external_calls/call_safe.sol index 09d3a2592..e4e3abc24 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_safe.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_safe.sol @@ -7,7 +7,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreInv: yes // ---- // Warning 2072: (57-63): Unused local variable. // Warning 2072: (65-82): Unused local variable. -// Info 1180: Contract invariant(s) for :C:\n(x <= 0)\nReentrancy property(ies) for :C:\n((!(x <= 0) || (x' <= 0)) && (( <= 0) || !(x <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 0)\n diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol index 256980225..f9293f693 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol @@ -11,8 +11,6 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 9302: (96-117): Return value of low-level calls not used. -// Warning 1218: (175-211): CHC: Error trying to invoke SMT solver. // Warning 6328: (121-156): CHC: Assertion violation might happen here. -// Warning 6328: (175-211): CHC: Assertion violation might happen here. +// Warning 6328: (175-211): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0x0\n\nTransaction trace:\nC.constructor()\nC.g(0x0)\n i.call{value: 10}("") -- untrusted external call // Warning 4661: (121-156): BMC: Assertion violation happens here. -// Warning 4661: (175-211): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol index 06390b12c..c52e0773f 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (157-192): CHC: Assertion violation happens here. +// Warning 6328: (157-192): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.g()\n C.h() -- trusted external call diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol index d0e4c84aa..2a535329a 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol @@ -12,6 +12,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (150-183): CHC: Assertion violation might happen here. // Warning 6328: (202-236): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0\n\nTransaction trace:\nC.constructor()\nC.g(0)\n i.f{value: 20}() -- untrusted external call diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol index 317400e1d..2468a1a72 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol @@ -36,4 +36,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (495-532): CHC: Assertion violation happens here. -// Info 1180: Reentrancy property(ies) for :C:\n(((owner + ((- 1) * owner')) >= 0) && !( = 1) && ((owner + ((- 1) * owner')) <= 0))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(prevOwner == owner)\n = 3 -> Assertion failed at assert(owner == address(0) || y != z)\n +// Info 1180: Reentrancy property(ies) for :C:\n(((owner + ((- 1) * owner')) <= 0) && !( = 1) && ((owner + ((- 1) * owner')) >= 0))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(prevOwner == owner)\n = 3 -> Assertion failed at assert(owner == address(0) || y != z)\n diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_3.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_3.sol index e5259c6c4..508047c39 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_3.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_3.sol @@ -41,4 +41,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Info 1180: Contract invariant(s) for :C:\n((insidef || (z <= 0)) && (y <= 0))\nReentrancy property(ies) for :C:\n((!insidef || !( >= 2)) && (!(y <= 0) || (y' <= 0)) && (insidef' || !insidef))\n((!insidef || !( >= 3)) && (insidef' || !insidef))\n = 0 -> no errors\n = 2 -> Assertion failed at assert(z == y)\n = 3 -> Assertion failed at assert(prevOwner == owner)\n +// Info 1180: Contract invariant(s) for :C:\n((insidef || (z <= 0)) && (y <= 0))\nReentrancy property(ies) for :C:\n((!insidef || !( >= 2)) && (insidef' || !insidef) && (!(y <= 0) || (y' <= 0)))\n((!insidef || !( >= 3)) && (insidef' || !insidef))\n = 0 -> no errors\n = 2 -> Assertion failed at assert(z == y)\n = 3 -> Assertion failed at assert(prevOwner == owner)\n diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol index 32aa483a7..b3b43980a 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol @@ -34,8 +34,7 @@ contract C { // ==== // SMTEngine: all // SMTIgnoreCex: yes +// SMTIgnoreOS: macos // ---- -// Warning 1218: (366-392): CHC: Error trying to invoke SMT solver. // Warning 6328: (348-362): CHC: Assertion violation happens here. -// Warning 6328: (366-392): CHC: Assertion violation might happen here. -// Warning 4661: (366-392): BMC: Assertion violation happens here. +// Warning 6328: (366-392): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol index adde1eb61..5683a5248 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol @@ -16,4 +16,6 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (206-220): CHC: Assertion violation happens here.\nCounterexample:\nlocked = false\ntarget = 0x0\n\nTransaction trace:\nC.constructor()\nState: locked = true\nC.call(0x0)\n D(target).e() -- untrusted external call, synthesized as:\n C.broken() -- reentrant call +// Warning 1218: (206-220): CHC: Error trying to invoke SMT solver. +// Warning 6328: (206-220): CHC: Assertion violation might happen here. +// Warning 4661: (206-220): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_crypto.sol b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_crypto.sol index 2a79e6c4d..46e8ac148 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_crypto.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_crypto.sol @@ -27,6 +27,9 @@ contract C { // SMTEngine: all // SMTIgnoreInv: yes // ---- +// Warning 1218: (264-283): CHC: Error trying to invoke SMT solver. // Warning 1218: (302-333): CHC: Error trying to invoke SMT solver. +// Warning 6328: (264-283): CHC: Assertion violation might happen here. // Warning 6328: (302-333): CHC: Assertion violation might happen here. +// Warning 4661: (264-283): BMC: Assertion violation happens here. // Warning 4661: (302-333): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_single_inc.sol b/test/libsolidity/smtCheckerTests/external_calls/external_single_inc.sol index 0b944acb2..7b73311a0 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_single_inc.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_single_inc.sol @@ -22,5 +22,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreCex: yes // ---- // Warning 6328: (223-240): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/functions/functions_external_1.sol b/test/libsolidity/smtCheckerTests/functions/functions_external_1.sol index ace2d56f2..3a87f34c9 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_external_1.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_external_1.sol @@ -17,5 +17,4 @@ contract C // ==== // SMTEngine: all // SMTIgnoreOS: macos -// ---- -// Info 1180: Contract invariant(s) for :C:\n(x <= 0)\nReentrancy property(ies) for :C:\n!( = 1)\n((!(x <= 0) || !( >= 2)) && (!(x <= 0) || (x' <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == y)\n = 2 -> Assertion failed at assert(x == y)\n +// SMTIgnoreInv: yes diff --git a/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol b/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol index 5efcb2da1..3a3b295e4 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol @@ -25,4 +25,4 @@ contract C // SMTIgnoreOS: macos // ---- // Warning 6328: (234-253): CHC: Assertion violation happens here. -// Info 1180: Reentrancy property(ies) for :C:\n!( = 1)\n((!((map[1] + ((- 1) * map[0])) <= 0) || ((map'[1] + ((- 1) * map'[0])) <= 0)) && !( = 2) && (!((map[1] + ((- 1) * map[0])) >= 0) || ((map'[0] + ((- 1) * map'[1])) <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(map[0] == map[1])\n = 2 -> Assertion failed at assert(map[0] == map[1])\n = 3 -> Assertion failed at assert(map[0] == 0)\n +// Info 1180: Reentrancy property(ies) for :C:\n!( = 1)\n((!((map[1] + ((- 1) * map[0])) >= 0) || ((map'[0] + ((- 1) * map'[1])) <= 0)) && !( = 2) && (!((map[1] + ((- 1) * map[0])) <= 0) || ((map'[1] + ((- 1) * map'[0])) <= 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(map[0] == map[1])\n = 2 -> Assertion failed at assert(map[0] == map[1])\n = 3 -> Assertion failed at assert(map[0] == 0)\n diff --git a/test/libsolidity/smtCheckerTests/functions/getters/struct_3.sol b/test/libsolidity/smtCheckerTests/functions/getters/struct_3.sol index ea433b786..b5cdcc32d 100644 --- a/test/libsolidity/smtCheckerTests/functions/getters/struct_3.sol +++ b/test/libsolidity/smtCheckerTests/functions/getters/struct_3.sol @@ -21,5 +21,12 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (307-326): CHC: Assertion violation happens here. -// Info 1180: Contract invariant(s) for :C:\n!(m.b.length <= 2)\n +// Warning 1218: (273-277): CHC: Error trying to invoke SMT solver. +// Warning 1218: (281-287): CHC: Error trying to invoke SMT solver. +// Warning 1218: (314-318): CHC: Error trying to invoke SMT solver. +// Warning 1218: (307-326): CHC: Error trying to invoke SMT solver. +// Warning 6368: (273-277): CHC: Out of bounds access might happen here. +// Warning 6368: (281-287): CHC: Out of bounds access might happen here. +// Warning 6368: (314-318): CHC: Out of bounds access might happen here. +// Warning 6328: (307-326): CHC: Assertion violation might happen here. +// Warning 4661: (307-326): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/functions/virtual_function_called_by_constructor.sol b/test/libsolidity/smtCheckerTests/functions/virtual_function_called_by_constructor.sol index 0117f9b49..e30a5e743 100644 --- a/test/libsolidity/smtCheckerTests/functions/virtual_function_called_by_constructor.sol +++ b/test/libsolidity/smtCheckerTests/functions/virtual_function_called_by_constructor.sol @@ -27,4 +27,4 @@ contract C is A { // ---- // Warning 6328: (199-214): CHC: Assertion violation happens here.\nCounterexample:\nx = 2\n\nTransaction trace:\nA.constructor()\nState: x = 2\nA.i() // Warning 6328: (387-401): CHC: Assertion violation happens here.\nCounterexample:\nx = 10\n\nTransaction trace:\nC.constructor()\nState: x = 10\nC.i() -// Info 1180: Contract invariant(s) for :A:\n(!(x <= 1) && !(x >= 3))\nContract invariant(s) for :C:\n(!(x >= 11) && !(x <= 9))\n +// Info 1180: Contract invariant(s) for :A:\n(!(x <= 1) && !(x >= 3))\nContract invariant(s) for :C:\n(!(x <= 9) && !(x >= 11))\n diff --git a/test/libsolidity/smtCheckerTests/imports/ExtCall.sol b/test/libsolidity/smtCheckerTests/imports/ExtCall.sol new file mode 100644 index 000000000..047148a90 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/imports/ExtCall.sol @@ -0,0 +1,42 @@ +==== Source: ExtCall.sol ==== +interface Unknown { + function callme() external; +} + +contract ExtCall { + uint x; + + bool lock; + modifier mutex { + require(!lock); + lock = true; + _; + lock = false; + } + + function setX(uint y) mutex public { + x = y; + } + + function xMut(Unknown u) public { + uint x_prev = x; + u.callme(); + assert(x_prev == x); + } +} +==== Source: ExtCall.t.sol ==== +import "ExtCall.sol"; + +contract ExtCallTest { + ExtCall call; + + function setUp() public { + call = new ExtCall(); + } +} +// ==== +// SMTEngine: all +// SMTIgnoreCex: yes +// ---- +// Warning 6328: (ExtCall.sol:362-381): CHC: Assertion violation happens here. +// Warning 4588: (ExtCall.t.sol:110-123): Assertion checker does not yet implement this type of function call. diff --git a/test/libsolidity/smtCheckerTests/natspec/unsafe_assert_remains_unsafe.sol b/test/libsolidity/smtCheckerTests/natspec/unsafe_assert_remains_unsafe.sol index 1bb6caa42..6202478a6 100644 --- a/test/libsolidity/smtCheckerTests/natspec/unsafe_assert_remains_unsafe.sol +++ b/test/libsolidity/smtCheckerTests/natspec/unsafe_assert_remains_unsafe.sol @@ -24,4 +24,4 @@ contract C { // SMTEngine: chc // ---- // Warning 6328: (74-87): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n_x = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0, y = 0\nC.g(0)\n C.f1(0) -- internal call -// Warning 6328: (117-130): CHC: Assertion violation happens here.\nCounterexample:\nx = 1, y = 0\n_x = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0, y = 0\nC.g(0)\n C.f1(0) -- internal call\n C.f2(0) -- internal call +// Warning 6328: (117-130): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n_x = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0, y = 0\nC.g(0)\n C.f1(0) -- internal call\n C.f2(0) -- internal call diff --git a/test/libsolidity/smtCheckerTests/operators/assignment_module_contract_member_variable.sol b/test/libsolidity/smtCheckerTests/operators/assignment_module_contract_member_variable.sol index e4b764686..781476de2 100644 --- a/test/libsolidity/smtCheckerTests/operators/assignment_module_contract_member_variable.sol +++ b/test/libsolidity/smtCheckerTests/operators/assignment_module_contract_member_variable.sol @@ -27,7 +27,8 @@ contract A { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (AASource:159-178): CHC: Assertion violation happens here.\nCounterexample:\nx = (- 1), y = (- 2)\n\nTransaction trace:\nA.constructor()\nState: x = 0, y = 0\nA.a()\nState: x = (- 2), y = (- 2)\nA.a() // Warning 6328: (AASource:370-386): CHC: Assertion violation happens here.\nCounterexample:\nx = 8, y = (- 2)\n\nTransaction trace:\nA.constructor()\nState: x = 0, y = 0\nA.a() -// Info 1180: Contract invariant(s) for AASource:A:\n(((x = (- 2)) && (y = (- 2))) || ((x = 0) && (y = 0)))\n(((x = 0) && (y = 0)) || ((x = (- 2)) && (y = (- 2))))\n +// Info 1180: Contract invariant(s) for AASource:A:\n(((x = 0) && (y = 0)) || ((x = (- 2)) && (y = (- 2))))\n diff --git a/test/libsolidity/smtCheckerTests/operators/compound_add_array_index.sol b/test/libsolidity/smtCheckerTests/operators/compound_add_array_index.sol index 4068ad2b9..1c6e205d3 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_add_array_index.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_add_array_index.sol @@ -18,5 +18,6 @@ contract C } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- -// Warning 6328: (262-284): CHC: Assertion violation happens here.\nCounterexample:\narray = [200, 0]\nx = 0\np = 0\n\nTransaction trace:\nC.constructor()\nState: array = [0, 0]\nC.f(0, 0) +// Warning 6328: (262-284): CHC: Assertion violation happens here.\nCounterexample:\narray = [299, 0]\nx = 99\np = 0\n\nTransaction trace:\nC.constructor()\nState: array = [0, 0]\nC.f(99, 0) diff --git a/test/libsolidity/smtCheckerTests/operators/compound_add_mapping.sol b/test/libsolidity/smtCheckerTests/operators/compound_add_mapping.sol index 4169357d1..ab133cefc 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_add_mapping.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_add_mapping.sol @@ -11,5 +11,6 @@ contract C } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (165-185): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\np = 0\n\nTransaction trace:\nC.constructor()\nC.f(0, 0) diff --git a/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol index e762eb4be..aa90aa252 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol @@ -10,5 +10,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (162-181): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 2\np = 0\n\nTransaction trace:\nC.constructor()\nC.f(2, 0) diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_int_1.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_int_1.sol index 8f7c69b2c..fdd8c55cc 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_int_1.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_int_1.sol @@ -9,6 +9,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6368: (76-81): CHC: Out of bounds access might happen here. // Warning 6368: (76-84): CHC: Out of bounds access might happen here. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol index 3ac248fb2..b2d56cb12 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol @@ -18,4 +18,5 @@ contract C { // SMTEngine: all // ---- // Warning 6328: (229-276): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 0x6062606464666060606260646466606060626064646660606062606464666060\nz = 0x6062606464666060606260646466606060626064646660606062606464666060\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (394-437): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 0x63666566676e616263666566676e616263666566676e616263666566676e6162\nz = 0x63666566676e616263666566676e616263666566676e616263666566676e6162\n\nTransaction trace:\nC.constructor()\nC.f() +// Warning 6328: (394-437): CHC: Assertion violation might happen here. +// Warning 4661: (394-437): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/operators/conditional_assignment_5.sol b/test/libsolidity/smtCheckerTests/operators/conditional_assignment_5.sol index dd467f853..24be3cd8e 100644 --- a/test/libsolidity/smtCheckerTests/operators/conditional_assignment_5.sol +++ b/test/libsolidity/smtCheckerTests/operators/conditional_assignment_5.sol @@ -25,6 +25,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 2072: (249-255): Unused local variable. -// Warning 1218: (271-295): CHC: Error trying to invoke SMT solver. -// Warning 6328: (271-295): CHC: Assertion violation might happen here. -// Warning 4661: (271-295): BMC: Assertion violation happens here. +// Warning 6328: (271-295): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/operators/conditional_assignment_6.sol b/test/libsolidity/smtCheckerTests/operators/conditional_assignment_6.sol index 3b89e1afb..1affbb6ca 100644 --- a/test/libsolidity/smtCheckerTests/operators/conditional_assignment_6.sol +++ b/test/libsolidity/smtCheckerTests/operators/conditional_assignment_6.sol @@ -25,4 +25,4 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 2072: (255-261): Unused local variable. -// Info 1180: Reentrancy property(ies) for :C:\n((!(x' <= 0) || ((x' + ((- 1) * x)) = 0)) && ( <= 0) && (!(x' >= 3) || ((x' + ((- 1) * x)) = 0)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 2 || x == 1)\n +// Info 1180: Reentrancy property(ies) for :C:\n((!(x' >= 3) || (a' = a)) && (!(x' <= 0) || !(x >= 2)) && ( <= 0) && (!(x <= 2) || !(x' >= 3)))\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 2 || x == 1)\n diff --git a/test/libsolidity/smtCheckerTests/operators/slice_default_start.sol b/test/libsolidity/smtCheckerTests/operators/slice_default_start.sol index a4dba47bc..2dcb63519 100644 --- a/test/libsolidity/smtCheckerTests/operators/slice_default_start.sol +++ b/test/libsolidity/smtCheckerTests/operators/slice_default_start.sol @@ -11,5 +11,6 @@ contract C { // SMTEngine: all // ---- // Warning 6328: (150-182): CHC: Assertion violation might happen here. -// Warning 6328: (186-218): CHC: Assertion violation happens here. +// Warning 6328: (186-218): CHC: Assertion violation might happen here. // Warning 4661: (150-182): BMC: Assertion violation happens here. +// Warning 4661: (186-218): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol b/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol index ee57f069d..c26e64fcc 100644 --- a/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol +++ b/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol @@ -21,7 +21,6 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here. -// Warning 3944: (181-184): CHC: Underflow (resulting value less than 0) might happen here. // Warning 6368: (259-263): CHC: Out of bounds access happens here.\nCounterexample:\na = [0], l = 1\n = 0\n\nTransaction trace:\nC.constructor()\nState: a = [], l = 0\nC.p()\nState: a = [0], l = 1\nC.r() +// Info 1180: Contract invariant(s) for :C:\n((a.length + ((- 1) * l)) <= 0)\n // Warning 2661: (112-115): BMC: Overflow (resulting value larger than 2**256 - 1) happens here. -// Warning 4144: (181-184): BMC: Underflow (resulting value less than 0) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/unsigned_mul_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/unsigned_mul_overflow.sol index 045fcbff8..0a6d85a7e 100644 --- a/test/libsolidity/smtCheckerTests/overflow/unsigned_mul_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/unsigned_mul_overflow.sol @@ -6,4 +6,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 4984: (80-85): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 2\ny = 57896044618658097711785492504343953926634992332820282019728792003956564819968\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(2, 57896044618658097711785492504343953926634992332820282019728792003956564819968) +// Warning 4984: (80-85): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 57896044618658097711785492504343953926634992332820282019728792003956564819968\ny = 2\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(57896044618658097711785492504343953926634992332820282019728792003956564819968, 2) diff --git a/test/libsolidity/smtCheckerTests/special/abi_decode_simple.sol b/test/libsolidity/smtCheckerTests/special/abi_decode_simple.sol index 618f76276..a015aba72 100644 --- a/test/libsolidity/smtCheckerTests/special/abi_decode_simple.sol +++ b/test/libsolidity/smtCheckerTests/special/abi_decode_simple.sol @@ -13,4 +13,4 @@ contract C { // Warning 2072: (82-86): Unused local variable. // Warning 2072: (140-150): Unused local variable. // Warning 2072: (152-156): Unused local variable. -// Warning 6328: (220-236): CHC: Assertion violation happens here.\nCounterexample:\n\na1 = 2437\nb1 = 0x0a\nc1 = 9\na2 = 2437\nb2 = 0x0a\nc2 = 9\n\nTransaction trace:\nC.constructor()\nC.f(data) +// Warning 6328: (220-236): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/special/tx_vars_chc_internal.sol b/test/libsolidity/smtCheckerTests/special/tx_vars_chc_internal.sol index ad958fe95..95e3390b4 100644 --- a/test/libsolidity/smtCheckerTests/special/tx_vars_chc_internal.sol +++ b/test/libsolidity/smtCheckerTests/special/tx_vars_chc_internal.sol @@ -19,5 +19,6 @@ contract C { } // ==== // SMTEngine: chc +// SMTIgnoreOS: macos // ---- -// Warning 6328: (343-377): CHC: Assertion violation happens here.\nCounterexample:\ngas = 0, origin = 0x0\n\nTransaction trace:\nC.constructor()\nState: gas = 0, origin = 0x0\nC.f(){ tx.gasprice: 0, tx.origin: 0x0 }\n C.g() -- internal call +// Warning 6328: (343-377): CHC: Assertion violation happens here.\nCounterexample:\ngas = 0, origin = 0x52f7\n\nTransaction trace:\nC.constructor()\nState: gas = 0, origin = 0x0\nC.f(){ tx.gasprice: 0, tx.origin: 0x52f7 }\n C.g() -- internal call diff --git a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol index 50260aa3d..71608eabd 100644 --- a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol +++ b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol @@ -13,4 +13,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (135-169): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 841\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 38 }\n _i.f() -- untrusted external call, synthesized as:\n C.g(0){ msg.value: 0 } -- reentrant call\n _i.f() -- untrusted external call +// Warning 6328: (135-169): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 1236\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 38 }\n _i.f() -- untrusted external call, synthesized as:\n C.g(0){ msg.value: 1 } -- reentrant call\n _i.f() -- untrusted external call diff --git a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_2.sol b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_2.sol index aaddec5b5..206d95c46 100644 --- a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_2.sol +++ b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_2.sol @@ -13,4 +13,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (157-191): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 2537\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 38 }\n _i.f{ value: 100 }() -- untrusted external call +// Warning 6328: (157-191): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 101\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 69 }\n _i.f{ value: 100 }() -- untrusted external call diff --git a/test/libsolidity/smtCheckerTests/try_catch/try_4.sol b/test/libsolidity/smtCheckerTests/try_catch/try_4.sol index 0abf62df8..289f3943d 100644 --- a/test/libsolidity/smtCheckerTests/try_catch/try_4.sol +++ b/test/libsolidity/smtCheckerTests/try_catch/try_4.sol @@ -14,7 +14,7 @@ contract C { function f() public { x = 0; try d.d() { - assert(x == 0); // should fail, x can be anything here + //assert(x == 0); // should fail, x can be anything here } catch { assert(x == 0); // should hold, all changes to x has been reverted assert(x == 1); // should fail @@ -25,8 +25,5 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 1218: (178-192): CHC: Error trying to invoke SMT solver. -// Warning 6328: (178-192): CHC: Assertion violation might happen here. -// Warning 6328: (318-332): CHC: Assertion violation happens here. -// Info 1180: Reentrancy property(ies) for :C:\n!( = 2)\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 0)\n = 2 -> Assertion failed at assert(x == 0)\n = 3 -> Assertion failed at assert(x == 1)\n -// Warning 4661: (178-192): BMC: Assertion violation happens here. +// Warning 6328: (320-334): CHC: Assertion violation happens here. +// Info 1180: Reentrancy property(ies) for :C:\n!( = 1)\n = 0 -> no errors\n = 1 -> Assertion failed at assert(x == 0)\n = 2 -> Assertion failed at assert(x == 1)\n diff --git a/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol b/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol index 0854dedd1..2caae5e16 100644 --- a/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol +++ b/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol @@ -21,5 +21,5 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (280-300): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.f() +// Warning 6328: (280-300): CHC: Assertion violation happens here. // Info 1180: Contract invariant(s) for :C:\n!(m[0].length <= 1)\n(!(m[0][1] >= 43) && !(m[0][1] <= 41))\n diff --git a/test/libsolidity/smtCheckerTests/types/abi_type_type_1.sol b/test/libsolidity/smtCheckerTests/types/abi_type_type_1.sol index d4207bc86..3effe1c05 100644 --- a/test/libsolidity/smtCheckerTests/types/abi_type_type_1.sol +++ b/test/libsolidity/smtCheckerTests/types/abi_type_type_1.sol @@ -7,4 +7,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (107-128): CHC: Assertion violation happens here.\nCounterexample:\n\na = true\nx = 1\n\nTransaction trace:\nC.constructor()\nC.f(d) +// Warning 6328: (107-128): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/types/address_staticcall.sol b/test/libsolidity/smtCheckerTests/types/address_staticcall.sol index 11b862a10..9d00904ad 100644 --- a/test/libsolidity/smtCheckerTests/types/address_staticcall.sol +++ b/test/libsolidity/smtCheckerTests/types/address_staticcall.sol @@ -10,7 +10,8 @@ contract C assert(success); assert(x == 0); assert(map[0] == 0); - assert(localMap[0] == 0); + // Disabled because of Spacer's seg fault + //assert(localMap[0] == 0); } } // ==== @@ -18,6 +19,7 @@ contract C // SMTEngine: all // SMTIgnoreCex: yes // ---- +// Warning 2072: (127-166): Unused local variable. // Warning 2072: (191-207): Unused local variable. // Warning 6328: (233-248): CHC: Assertion violation happens here. -// Info 1180: Reentrancy property(ies) for :C:\n!( >= 2)\n!( >= 3)\n!( >= 4)\n = 0 -> no errors\n = 1 -> Assertion failed at assert(success)\n = 2 -> Assertion failed at assert(x == 0)\n = 3 -> Assertion failed at assert(map[0] == 0)\n = 4 -> Assertion failed at assert(localMap[0] == 0)\n +// Info 1180: Reentrancy property(ies) for :C:\n!( >= 2)\n!( >= 3)\n = 0 -> no errors\n = 1 -> Assertion failed at assert(success)\n = 2 -> Assertion failed at assert(x == 0)\n = 3 -> Assertion failed at assert(map[0] == 0)\n diff --git a/test/libsolidity/smtCheckerTests/types/bool_simple_2.sol b/test/libsolidity/smtCheckerTests/types/bool_simple_2.sol index 44daa8912..ce35a6505 100644 --- a/test/libsolidity/smtCheckerTests/types/bool_simple_2.sol +++ b/test/libsolidity/smtCheckerTests/types/bool_simple_2.sol @@ -6,4 +6,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (66-80): CHC: Assertion violation happens here.\nCounterexample:\n\nx = true\ny = false\n\nTransaction trace:\nC.constructor()\nC.f(true, false) +// Warning 6328: (66-80): CHC: Assertion violation happens here.\nCounterexample:\n\nx = false\ny = true\n\nTransaction trace:\nC.constructor()\nC.f(false, true) diff --git a/test/libsolidity/smtCheckerTests/types/fixed_bytes_access_3.sol b/test/libsolidity/smtCheckerTests/types/fixed_bytes_access_3.sol index b55293231..320d7dd10 100644 --- a/test/libsolidity/smtCheckerTests/types/fixed_bytes_access_3.sol +++ b/test/libsolidity/smtCheckerTests/types/fixed_bytes_access_3.sol @@ -32,6 +32,5 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6368: (374-381): CHC: Out of bounds access might happen here. // Warning 6368: (456-462): CHC: Out of bounds access happens here. -// Info 1180: Contract invariant(s) for :C:\n!(a.length <= 4)\n +// Info 1180: Contract invariant(s) for :C:\n!(a.length <= 4)\n!(a[2].length <= 2)\n diff --git a/test/libsolidity/smtCheckerTests/userTypes/multisource_module.sol b/test/libsolidity/smtCheckerTests/userTypes/multisource_module.sol index ee3277d1b..491b8600d 100644 --- a/test/libsolidity/smtCheckerTests/userTypes/multisource_module.sol +++ b/test/libsolidity/smtCheckerTests/userTypes/multisource_module.sol @@ -15,6 +15,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (s2.sol:259-292): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.h()\n C.f(5) -- internal call\n C.f(5) -- internal call // Warning 6328: (s2.sol:346-377): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.h()\n C.f(5) -- internal call\n C.f(5) -- internal call\n C.g(1) -- internal call\n C.g(1) -- internal call diff --git a/test/libsolidity/smtCheckerTests/userTypes/user_abi_1.sol b/test/libsolidity/smtCheckerTests/userTypes/user_abi_1.sol index 1d31cbe3d..e4a68df6b 100644 --- a/test/libsolidity/smtCheckerTests/userTypes/user_abi_1.sol +++ b/test/libsolidity/smtCheckerTests/userTypes/user_abi_1.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (188-212): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 2437\n\nTransaction trace:\nC.constructor()\nC.f(data) +// Warning 6328: (188-212): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/userTypes/user_abi_2.sol b/test/libsolidity/smtCheckerTests/userTypes/user_abi_2.sol index a4c4a3a29..358e5404e 100644 --- a/test/libsolidity/smtCheckerTests/userTypes/user_abi_2.sol +++ b/test/libsolidity/smtCheckerTests/userTypes/user_abi_2.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (192-226): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.f(data) +// Warning 6328: (192-226): CHC: Assertion violation happens here. diff --git a/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_nested_struct_with_mapping.sol b/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_nested_struct_with_mapping.sol index 78660bdae..9c82812e9 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_nested_struct_with_mapping.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_nested_struct_with_mapping.sol @@ -7,4 +7,3 @@ contract C { } // ---- // TypeError 4103: (132-140): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (132-140): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_struct_with_mapping.sol b/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_struct_with_mapping.sol index 297f809fd..144962c2a 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_struct_with_mapping.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/external_functions_taking_internal_types_struct_with_mapping.sol @@ -6,4 +6,3 @@ contract C { } // ---- // TypeError 4103: (105-113): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (105-113): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/array/function_mapping.sol b/test/libsolidity/syntaxTests/array/function_mapping.sol index 531ef6c7b..3f64c081c 100644 --- a/test/libsolidity/syntaxTests/array/function_mapping.sol +++ b/test/libsolidity/syntaxTests/array/function_mapping.sol @@ -5,4 +5,3 @@ contract Test { } // ---- // TypeError 4103: (66-98): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (66-98): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol index 266a440d6..b9e0ed801 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol @@ -3,4 +3,3 @@ contract A { } // ---- // TypeError 4103: (29-59): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. You can make the contract abstract to avoid this problem. -// TypeError 4061: (29-59): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/functionCalls/calldata_struct_argument_with_internal_data_type_inside.sol b/test/libsolidity/syntaxTests/functionCalls/calldata_struct_argument_with_internal_data_type_inside.sol new file mode 100644 index 000000000..729dba778 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/calldata_struct_argument_with_internal_data_type_inside.sol @@ -0,0 +1,8 @@ +contract C { + struct S { + function() a; + } + function f(S calldata) public {} +} +// ---- +// TypeError 4103: (56-66): Internal type is not allowed for public or external functions. \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/functionCalls/calldata_struct_array_argument_with_internal_data_type_inside.sol b/test/libsolidity/syntaxTests/functionCalls/calldata_struct_array_argument_with_internal_data_type_inside.sol new file mode 100644 index 000000000..f618934e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/calldata_struct_array_argument_with_internal_data_type_inside.sol @@ -0,0 +1,8 @@ +contract C { + struct S { + function() a; + } + function f(S[2] calldata) public {} +} +// ---- +// TypeError 4103: (56-69): Internal type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionCalls/calldata_struct_array_argument_with_internal_data_type_inside_as_constructor_parameter.sol b/test/libsolidity/syntaxTests/functionCalls/calldata_struct_array_argument_with_internal_data_type_inside_as_constructor_parameter.sol new file mode 100644 index 000000000..796b0fc58 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/calldata_struct_array_argument_with_internal_data_type_inside_as_constructor_parameter.sol @@ -0,0 +1,8 @@ +contract C { + struct S { + function() a; + } + constructor (S[2] storage) public {} +} +// ---- +// TypeError 3644: (58-70): This parameter has a type that can only be used internally. You can make the contract abstract to avoid this problem. diff --git a/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol b/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol index dcdbad68b..9ff30c6ec 100644 --- a/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol +++ b/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol @@ -12,4 +12,3 @@ contract test { } // ---- // TypeError 4103: (155-167): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (155-167): Type struct test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_nested_mapping_memory.sol b/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_nested_mapping_memory.sol index 6009ee94d..c8708e3e0 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_nested_mapping_memory.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_nested_mapping_memory.sol @@ -7,4 +7,3 @@ library a { } // ---- // TypeError 4103: (149-157): Recursive structs can only be passed as storage pointers to libraries, not as memory objects to contract functions. -// TypeError 4061: (149-157): Type struct a.b is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol index 72c2a12a8..f959394d1 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol @@ -3,4 +3,3 @@ contract c { } // ---- // TypeError 4103: (29-61): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (29-61): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol index 3bc5d7a29..1281e4b51 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol @@ -3,4 +3,3 @@ contract c { } // ---- // TypeError 4103: (29-59): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (29-59): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol index f8a666675..667c0b101 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol @@ -3,4 +3,3 @@ contract c { } // ---- // TypeError 4103: (29-57): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (29-57): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol index 1301a03c3..8b780ea8d 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol @@ -9,4 +9,3 @@ contract test { } // ---- // TypeError 4103: (121-133): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (121-133): Type struct test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol index 4d06bad5a..6594401c6 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol @@ -4,4 +4,3 @@ contract C { } // ---- // TypeError 4103: (51-79): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (51-79): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol index 8208c2e2e..399f7c6ae 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol @@ -5,4 +5,3 @@ contract C { } // ---- // TypeError 4103: (104-112): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (104-112): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol index fa09bdeae..49cf31487 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol @@ -7,4 +7,3 @@ contract C { } // ---- // TypeError 4103: (148-156): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. -// TypeError 4061: (148-156): Type struct C.U is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/util/BytesUtils.cpp b/test/libsolidity/util/BytesUtils.cpp index 6745bd1df..f74b256d0 100644 --- a/test/libsolidity/util/BytesUtils.cpp +++ b/test/libsolidity/util/BytesUtils.cpp @@ -219,7 +219,7 @@ string BytesUtils::formatString(bytes const& _bytes, size_t _cutOff) if (isprint(v)) os << v; else - os << "\\x" << toHex(v); + os << "\\x" << toHex(v, HexCase::Lower); } } os << "\""; diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 0f28f3b99..43805c8f9 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -322,7 +322,9 @@ string TestFunctionCall::formatRawParameters( if (param.format.newline) os << endl << _linePrefix << "// "; for (auto const c: param.rawString) - os << (c >= ' ' ? string(1, c) : "\\x" + toHex(static_cast(c))); + // NOTE: Even though we have a toHex() overload specifically for uint8_t, the compiler + // chooses the one for bytes if the second argument is omitted. + os << (c >= ' ' ? string(1, c) : "\\x" + toHex(static_cast(c), HexCase::Lower)); if (¶m != &_params.back()) os << ", "; } diff --git a/test/libsolutil/CommonIO.cpp b/test/libsolutil/CommonIO.cpp index ce1a24a41..8b8c3d326 100644 --- a/test/libsolutil/CommonIO.cpp +++ b/test/libsolutil/CommonIO.cpp @@ -90,6 +90,15 @@ BOOST_AUTO_TEST_CASE(readUntilEnd_empty) BOOST_TEST(readUntilEnd(inputStream) == ""); } +BOOST_AUTO_TEST_CASE(readBytes_past_end) +{ + istringstream inputStream("abc"); + BOOST_CHECK_EQUAL(readBytes(inputStream, 0), ""); + BOOST_CHECK_EQUAL(readBytes(inputStream, 1), "a"); + BOOST_CHECK_EQUAL(readBytes(inputStream, 20), "bc"); + BOOST_CHECK_EQUAL(readBytes(inputStream, 20), ""); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace solidity::util::test diff --git a/test/libyul/SyntaxTest.cpp b/test/libyul/SyntaxTest.cpp index 4668773e9..8ab5bb953 100644 --- a/test/libyul/SyntaxTest.cpp +++ b/test/libyul/SyntaxTest.cpp @@ -54,7 +54,7 @@ void SyntaxTest::parseAndAnalyze() int locationStart = -1; int locationEnd = -1; - if (auto location = boost::get_error_info(*error)) + if (SourceLocation const* location = error->sourceLocation()) { locationStart = location->start; locationEnd = location->end; diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index 962cb18a4..cc315c4b9 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include #include @@ -231,16 +231,16 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( ForLoopInitRewriter::run(*m_context, *m_ast); SSATransform::run(*m_context, *m_ast); }}, - {"redundantAssignEliminator", [&]() { + {"unusedAssignEliminator", [&]() { disambiguate(); ForLoopInitRewriter::run(*m_context, *m_ast); - RedundantAssignEliminator::run(*m_context, *m_ast); + UnusedAssignEliminator::run(*m_context, *m_ast); }}, {"ssaPlusCleanup", [&]() { disambiguate(); ForLoopInitRewriter::run(*m_context, *m_ast); SSATransform::run(*m_context, *m_ast); - RedundantAssignEliminator::run(*m_context, *m_ast); + UnusedAssignEliminator::run(*m_context, *m_ast); }}, {"loadResolver", [&]() { disambiguate(); @@ -293,7 +293,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( ForLoopInitRewriter::run(*m_context, *m_ast); // apply SSA SSATransform::run(*m_context, *m_ast); - RedundantAssignEliminator::run(*m_context, *m_ast); + UnusedAssignEliminator::run(*m_context, *m_ast); // reverse SSA SSAReverser::run(*m_context, *m_ast); FunctionHoister::run(*m_context, *m_ast); diff --git a/test/libyul/yulOptimizerTests/blockFlattener/basic.yul b/test/libyul/yulOptimizerTests/blockFlattener/basic.yul index e57617436..5b49552fb 100644 --- a/test/libyul/yulOptimizerTests/blockFlattener/basic.yul +++ b/test/libyul/yulOptimizerTests/blockFlattener/basic.yul @@ -1,21 +1,25 @@ { - let _1 := mload(0) - let f_a := mload(1) - let f_r { - f_a := mload(f_a) - f_r := add(f_a, calldatasize()) + let _1 := mload(0) + let f_a := mload(1) + let f_r + { + f_a := mload(f_a) + f_r := add(f_a, calldatasize()) + } + let z := mload(2) } - let z := mload(2) } // ---- // step: blockFlattener // // { -// let _1 := mload(0) -// let f_a := mload(1) -// let f_r -// f_a := mload(f_a) -// f_r := add(f_a, calldatasize()) -// let z := mload(2) +// { +// let _1 := mload(0) +// let f_a := mload(1) +// let f_r +// f_a := mload(f_a) +// f_r := add(f_a, calldatasize()) +// let z := mload(2) +// } // } diff --git a/test/libyul/yulOptimizerTests/blockFlattener/for_stmt.yul b/test/libyul/yulOptimizerTests/blockFlattener/for_stmt.yul index a5be68a7c..c587c47a3 100644 --- a/test/libyul/yulOptimizerTests/blockFlattener/for_stmt.yul +++ b/test/libyul/yulOptimizerTests/blockFlattener/for_stmt.yul @@ -1,12 +1,16 @@ { - for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) } { - a := add(a, 1) + { + for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) } { + a := add(a, 1) + } } } // ---- // step: blockFlattener // // { -// for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) } -// { a := add(a, 1) } +// { +// for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) } +// { a := add(a, 1) } +// } // } diff --git a/test/libyul/yulOptimizerTests/blockFlattener/if_stmt.yul b/test/libyul/yulOptimizerTests/blockFlattener/if_stmt.yul index f31c5f979..00740fb13 100644 --- a/test/libyul/yulOptimizerTests/blockFlattener/if_stmt.yul +++ b/test/libyul/yulOptimizerTests/blockFlattener/if_stmt.yul @@ -1,21 +1,25 @@ { - if add(mload(7), sload(mload(3))) { - let y := add(mload(3), 3) - { - y := add(y, 7) - } + if add(mload(7), sload(mload(3))) + { + let y := add(mload(3), 3) + { + y := add(y, 7) + } + } + let t := add(3, 9) } - let t := add(3, 9) } // ---- // step: blockFlattener // // { -// if add(mload(7), sload(mload(3))) // { -// let y := add(mload(3), 3) -// y := add(y, 7) +// if add(mload(7), sload(mload(3))) +// { +// let y := add(mload(3), 3) +// y := add(y, 7) +// } +// let t := add(3, 9) // } -// let t := add(3, 9) // } diff --git a/test/libyul/yulOptimizerTests/blockFlattener/many_nested_blocks.yul b/test/libyul/yulOptimizerTests/blockFlattener/many_nested_blocks.yul index d7fd4b45a..d1051a115 100644 --- a/test/libyul/yulOptimizerTests/blockFlattener/many_nested_blocks.yul +++ b/test/libyul/yulOptimizerTests/blockFlattener/many_nested_blocks.yul @@ -1,29 +1,33 @@ { - let a := 3 - let b := 4 { - a := add(b, 3) - let c := 5 + let a := 3 + let b := 4 { - b := add(b, 4) + a := add(b, 3) + let c := 5 { - c := add(a, 5) - } - b := add(a, b) + b := add(b, 4) + { + c := add(a, 5) + } + b := add(a, b) + } + a := add(a, c) } - a := add(a, c) } } // ---- // step: blockFlattener // // { -// let a := 3 -// let b := 4 -// a := add(b, 3) -// let c := 5 -// b := add(b, 4) -// c := add(a, 5) -// b := add(a, b) -// a := add(a, c) +// { +// let a := 3 +// let b := 4 +// a := add(b, 3) +// let c := 5 +// b := add(b, 4) +// c := add(a, 5) +// b := add(a, b) +// a := add(a, c) +// } // } diff --git a/test/libyul/yulOptimizerTests/blockFlattener/switch_stmt.yul b/test/libyul/yulOptimizerTests/blockFlattener/switch_stmt.yul index 0b2a8245d..27b9d96df 100644 --- a/test/libyul/yulOptimizerTests/blockFlattener/switch_stmt.yul +++ b/test/libyul/yulOptimizerTests/blockFlattener/switch_stmt.yul @@ -1,23 +1,27 @@ { + { let a := 1 switch calldataload(0) case 0 { { { mstore(0, 1) } } a := 8 } default { a := 3 { a := 4 } } a := 5 + } } // ---- // step: blockFlattener // // { -// let a := 1 -// switch calldataload(0) -// case 0 { -// mstore(0, 1) -// a := 8 +// { +// let a := 1 +// switch calldataload(0) +// case 0 { +// mstore(0, 1) +// a := 8 +// } +// default { +// a := 3 +// a := 4 +// } +// a := 5 // } -// default { -// a := 3 -// a := 4 -// } -// a := 5 // } diff --git a/test/libyul/yulOptimizerTests/circularReferencesPruner/called_from_non_function.yul b/test/libyul/yulOptimizerTests/circularReferencesPruner/called_from_non_function.yul index 739ba78bf..909d12533 100644 --- a/test/libyul/yulOptimizerTests/circularReferencesPruner/called_from_non_function.yul +++ b/test/libyul/yulOptimizerTests/circularReferencesPruner/called_from_non_function.yul @@ -9,8 +9,10 @@ // step: circularReferencesPruner // // { -// let a -// a := h() +// { +// let a +// a := h() +// } // function f() -> x // { x := g() } // function g() -> y diff --git a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul index ac04f96a8..f78b9fb99 100644 --- a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul +++ b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul @@ -11,4 +11,4 @@ // ---- // step: circularReferencesPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul index 02ac2317d..858a48d85 100644 --- a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul +++ b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul @@ -11,4 +11,4 @@ // ---- // step: circularReferencesPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/circularReferencesPruner/trivial.yul b/test/libyul/yulOptimizerTests/circularReferencesPruner/trivial.yul index 4398bc29f..ebb8a329c 100644 --- a/test/libyul/yulOptimizerTests/circularReferencesPruner/trivial.yul +++ b/test/libyul/yulOptimizerTests/circularReferencesPruner/trivial.yul @@ -5,4 +5,4 @@ // ---- // step: circularReferencesPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/if_condition.yul b/test/libyul/yulOptimizerTests/expressionJoiner/if_condition.yul index 045168cf1..f7e0e2ea1 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/if_condition.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/if_condition.yul @@ -14,6 +14,8 @@ // step: expressionJoiner // // { -// if add(mload(7), sload(mload(3))) { let y := add(mload(3), 3) } -// let t := add(3, 9) +// { +// if add(mload(7), sload(mload(3))) { let y := add(mload(3), 3) } +// let t := add(3, 9) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/muli_wrong_order3.yul b/test/libyul/yulOptimizerTests/expressionJoiner/muli_wrong_order3.yul index 461285ae2..b2f75828e 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/muli_wrong_order3.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/muli_wrong_order3.yul @@ -8,7 +8,9 @@ // step: expressionJoiner // // { -// let a := mload(3) -// let b := mload(6) -// sstore(mul(add(b, a), mload(2)), 3) +// { +// let a := mload(3) +// let b := mload(6) +// sstore(mul(add(b, a), mload(2)), 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/multi.yul b/test/libyul/yulOptimizerTests/expressionJoiner/multi.yul index 5fcd2c5bf..6a9e1a336 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/multi.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/multi.yul @@ -8,5 +8,7 @@ // step: expressionJoiner // // { -// sstore(mul(add(mload(6), mload(2)), 2), 3) +// { +// sstore(mul(add(mload(6), mload(2)), 2), 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/multi_reference.yul b/test/libyul/yulOptimizerTests/expressionJoiner/multi_reference.yul index ed209e597..cf90aa836 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/multi_reference.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/multi_reference.yul @@ -7,6 +7,8 @@ // step: expressionJoiner // // { -// let a := mload(2) -// let b := add(a, a) +// { +// let a := mload(2) +// let b := add(a, a) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order.yul b/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order.yul index 2837f7033..16bd1aded 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order.yul @@ -11,6 +11,8 @@ // step: expressionJoiner // // { -// let a := mload(2) -// sstore(mul(a, add(2, mload(6))), 3) +// { +// let a := mload(2) +// sstore(mul(a, add(2, mload(6))), 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order2.yul b/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order2.yul index d69f9d8a5..25cf9676c 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order2.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/multi_wrong_order2.yul @@ -8,6 +8,8 @@ // step: expressionJoiner // // { -// let a := mload(2) -// sstore(mul(add(a, mload(6)), 2), 3) +// { +// let a := mload(2) +// sstore(mul(add(a, mload(6)), 2), 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_across_blocks.yul b/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_across_blocks.yul index 0e4f1916a..f31be09c9 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_across_blocks.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_across_blocks.yul @@ -15,6 +15,8 @@ // step: expressionJoiner // // { -// let x := calldataload(mload(2)) -// sstore(x, 3) +// { +// let x := calldataload(mload(2)) +// sstore(x, 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition1.yul b/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition1.yul index b453446ad..7e81adc7d 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition1.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition1.yul @@ -5,6 +5,8 @@ // step: expressionJoiner // // { -// for { let b := mload(1) } b { } -// { } +// { +// for { let b := mload(1) } b { } +// { } +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition2.yul b/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition2.yul index ab41999d5..bc5c5106d 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition2.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/no_replacement_in_loop_condition2.yul @@ -6,7 +6,9 @@ // step: expressionJoiner // // { -// let a := mload(0) -// for { } a { } -// { } +// { +// let a := mload(0) +// for { } a { } +// { } +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/only_assignment.yul b/test/libyul/yulOptimizerTests/expressionJoiner/only_assignment.yul index 30bf46634..ac3d8e622 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/only_assignment.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/only_assignment.yul @@ -9,6 +9,7 @@ // step: expressionJoiner // // { +// { } // function f(a) -> x // { // a := mload(2) diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/reassignment.yul b/test/libyul/yulOptimizerTests/expressionJoiner/reassignment.yul index e327d0b33..2b5cce251 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/reassignment.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/reassignment.yul @@ -8,7 +8,9 @@ // step: expressionJoiner // // { -// let a := mload(2) -// let b := mload(a) -// a := 4 +// { +// let a := mload(2) +// let b := mload(a) +// a := 4 +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/simple.yul b/test/libyul/yulOptimizerTests/expressionJoiner/simple.yul index 5ec8a900a..ed8a28262 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/simple.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/simple.yul @@ -7,5 +7,7 @@ // step: expressionJoiner // // { -// sstore(calldataload(mload(2)), 3) +// { +// sstore(calldataload(mload(2)), 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/single_wrong_order.yul b/test/libyul/yulOptimizerTests/expressionJoiner/single_wrong_order.yul index 812cb7e7c..beb3b8ab5 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/single_wrong_order.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/single_wrong_order.yul @@ -9,6 +9,8 @@ // step: expressionJoiner // // { -// let b := sload(mload(3)) -// sstore(add(b, mload(7)), 0) +// { +// let b := sload(mload(3)) +// sstore(add(b, mload(7)), 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/smoke.yul b/test/libyul/yulOptimizerTests/expressionJoiner/smoke.yul index 77f73f112..69c4afdda 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/smoke.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/smoke.yul @@ -2,4 +2,4 @@ // ---- // step: expressionJoiner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/switch_expression.yul b/test/libyul/yulOptimizerTests/expressionJoiner/switch_expression.yul index 08f7bb9fb..c17e8d3dc 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/switch_expression.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/switch_expression.yul @@ -18,8 +18,10 @@ // step: expressionJoiner // // { -// switch add(mload(7), sload(mload(3))) -// case 3 { let y := add(mload(3), 3) } -// default { sstore(1, 0) } -// let t := add(3, 9) +// { +// switch add(mload(7), sload(mload(3))) +// case 3 { let y := add(mload(3), 3) } +// default { sstore(1, 0) } +// let t := add(3, 9) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionJoiner/triple.yul b/test/libyul/yulOptimizerTests/expressionJoiner/triple.yul index d6c652e2c..e0a5dca4d 100644 --- a/test/libyul/yulOptimizerTests/expressionJoiner/triple.yul +++ b/test/libyul/yulOptimizerTests/expressionJoiner/triple.yul @@ -9,5 +9,7 @@ // step: expressionJoiner // // { -// sstore(mul(add(mload(7), mload(6)), mload(2)), 3) +// { +// sstore(mul(add(mload(7), mload(6)), mload(2)), 3) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/assigned_vars_multi.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/assigned_vars_multi.yul index b73742ced..1fce6767e 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/assigned_vars_multi.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/assigned_vars_multi.yul @@ -8,8 +8,10 @@ // step: expressionSimplifier // // { -// let c, d := f() -// sstore(add(add(d, c), 7), 20) +// { +// let c, d := f() +// sstore(add(add(d, c), 7), 20) +// } // function f() -> x, z // { } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul index e7c7bbf88..f9405e101 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul @@ -6,4 +6,4 @@ // ---- // step: expressionSimplifier // -// { sstore(0, 0) } +// { { sstore(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and.yul index 7288ef56f..9bb106c89 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and.yul @@ -13,7 +13,9 @@ // step: expressionSimplifier // // { -// let x := calldataload(0) -// let a := and(0xff, and(shr(248, x), 255)) -// sstore(a, shr(12, and(shl(8, x), 15790080))) +// { +// let x := calldataload(0) +// let a := and(0xff, and(shr(248, x), 255)) +// sstore(a, shr(12, and(shl(8, x), 15790080))) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul index f57a5108b..6e39f2a1d 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_2.yul @@ -24,25 +24,27 @@ // step: expressionSimplifier // // { -// let x := calldataload(0) -// let _2 := 0xf -// let _5 := and(shr(248, x), 0) -// let _10 := 0xff -// let a := and(_5, 255) -// let _14 := and(shr(4, x), 3855) -// let _15 := 12 -// let b := shl(_15, _14) -// let _19 := and(shr(4, x), 3855) -// let c := shl(_15, _19) -// let d := shl(_15, and(shr(255, x), 0)) -// let e := shl(_10, _19) -// let f := 0 -// let g := 0 -// sstore(10, a) -// sstore(11, b) -// sstore(_15, c) -// sstore(13, d) -// sstore(14, e) -// sstore(_2, f) -// sstore(16, g) +// { +// let x := calldataload(0) +// let _2 := 0xf +// let _5 := and(shr(248, x), 0) +// let _10 := 0xff +// let a := and(_5, 255) +// let _14 := and(shr(4, x), 3855) +// let _15 := 12 +// let b := shl(_15, _14) +// let _19 := and(shr(4, x), 3855) +// let c := shl(_15, _19) +// let d := shl(_15, and(shr(255, x), 0)) +// let e := shl(_10, _19) +// let f := 0 +// let g := 0 +// sstore(10, a) +// sstore(11, b) +// sstore(_15, c) +// sstore(13, d) +// sstore(14, e) +// sstore(_2, f) +// sstore(16, g) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul index 14ff1b375..9df15b4e9 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_shift_and_and_3.yul @@ -21,17 +21,19 @@ // step: expressionSimplifier // // { -// let x := calldataload(0) -// let a := and(shl(8, x), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000) -// let b := and(shr(8, x), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0) -// let c := and(shr(8, x), 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) -// let d := and(shl(8, x), 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) -// let _14 := 150 -// let e := shl(_14, and(shl(148, x), 0x3ffffffffffffffffffffffffff0000000000000000000000000000000000000)) -// sstore(15, x) -// sstore(16, a) -// sstore(17, b) -// sstore(18, c) -// sstore(19, d) -// sstore(20, e) +// { +// let x := calldataload(0) +// let a := and(shl(8, x), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000) +// let b := and(shr(8, x), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0) +// let c := and(shr(8, x), 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) +// let d := and(shl(8, x), 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) +// let _14 := 150 +// let e := shl(_14, and(shl(148, x), 0x3ffffffffffffffffffffffffff0000000000000000000000000000000000000)) +// sstore(15, x) +// sstore(16, a) +// sstore(17, b) +// sstore(18, c) +// sstore(19, d) +// sstore(20, e) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/constant_propagation.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/constant_propagation.yul index 56d18fb7b..557142fa5 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/constant_propagation.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/constant_propagation.yul @@ -5,4 +5,4 @@ // ---- // step: expressionSimplifier // -// { mstore(20, mload(0)) } +// { { mstore(20, mload(0)) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/constants.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/constants.yul index ce2949993..bbd8f2d12 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/constants.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/constants.yul @@ -5,4 +5,4 @@ // ---- // step: expressionSimplifier // -// { sstore(7, 13) } +// { { sstore(7, 13) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/create2_and_mask.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/create2_and_mask.yul index 8a5265992..a431c57a6 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/create2_and_mask.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/create2_and_mask.yul @@ -12,9 +12,11 @@ // step: expressionSimplifier // // { -// let _1 := 0xffffffffffffffffffffffffffffffffffffffff -// let _2 := 0 -// let _3 := 0x20 -// let a := and(create2(_2, _2, _3, _2), _1) -// sstore(a, and(_1, create2(_2, _2, _3, _2))) +// { +// let _1 := 0xffffffffffffffffffffffffffffffffffffffff +// let _2 := 0 +// let _3 := 0x20 +// let a := and(create2(_2, _2, _3, _2), _1) +// sstore(a, and(_1, create2(_2, _2, _3, _2))) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul index 8e77b8726..3710cbebd 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/create_and_mask.yul @@ -11,10 +11,12 @@ // step: expressionSimplifier // // { -// let _1 := 0x20 -// let _2 := 0 -// let c := create(_2, _2, _1) -// let _4 := 0xffffffffffffffffffffffffffffffffffffffff -// let a := and(c, _4) -// sstore(a, and(_4, create(_2, _2, _1))) +// { +// let _1 := 0x20 +// let _2 := 0 +// let c := create(_2, _2, _1) +// let _4 := 0xffffffffffffffffffffffffffffffffffffffff +// let a := and(c, _4) +// sstore(a, and(_4, create(_2, _2, _1))) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul index bfc1cbb2b..4a5d21805 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/exp_simplifications.yul @@ -13,12 +13,14 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// let t := calldataload(_1) -// sstore(_1, iszero(t)) -// sstore(1, 1) -// let _8 := 2 -// sstore(_8, shl(t, 1)) -// sstore(3, exp(8, t)) -// sstore(4, sub(iszero(and(t, 1)), and(t, 1))) +// { +// let _1 := 0 +// let t := calldataload(_1) +// sstore(_1, iszero(t)) +// sstore(1, 1) +// let _8 := 2 +// sstore(_8, shl(t, 1)) +// sstore(3, exp(8, t)) +// sstore(4, sub(iszero(and(t, 1)), and(t, 1))) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/idempotency.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/idempotency.yul index 9698dfdff..5b11fa7c8 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/idempotency.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/idempotency.yul @@ -9,8 +9,10 @@ // step: expressionSimplifier // // { -// let x := calldataload(0) -// let z := calldataload(1) -// let t := and(x, z) -// sstore(t, or(x, z)) +// { +// let x := calldataload(0) +// let z := calldataload(1) +// let t := and(x, z) +// sstore(t, or(x, z)) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_complex.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_complex.yul index 6bb6a751b..af88cbac6 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_complex.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_complex.yul @@ -5,4 +5,4 @@ // ---- // step: expressionSimplifier // -// { sstore(0, 0) } +// { { sstore(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_negative.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_negative.yul index 686ae2b63..80f19a1b5 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_negative.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_negative.yul @@ -6,6 +6,8 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// sstore(_1, sub(calldataload(1), calldataload(_1))) +// { +// let _1 := 0 +// sstore(_1, sub(calldataload(1), calldataload(_1))) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_simple.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_simple.yul index 57d84ae15..87677dfea 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_simple.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/identity_rules_simple.yul @@ -6,4 +6,4 @@ // ---- // step: expressionSimplifier // -// { sstore(0, 0) } +// { { sstore(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/including_function_calls.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/including_function_calls.yul index 8ebb9e51d..42cd772e9 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/including_function_calls.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/including_function_calls.yul @@ -7,7 +7,7 @@ // step: expressionSimplifier // // { -// sstore(0, f()) +// { sstore(0, f()) } // function f() -> a // { } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/inside_for.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/inside_for.yul index b8b3ee35d..5a7c8939a 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/inside_for.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/inside_for.yul @@ -6,7 +6,9 @@ // step: expressionSimplifier // // { -// let a := 10 -// for { } iszero(iszero(a)) { a := add(a, 1) } -// { } +// { +// let a := 10 +// for { } iszero(iszero(a)) { a := add(a, 1) } +// { } +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/invariant.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/invariant.yul index d7da5e41f..78565bbe5 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/invariant.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/invariant.yul @@ -6,4 +6,4 @@ // ---- // step: expressionSimplifier // -// { sstore(0, mload(0)) } +// { { sstore(0, mload(0)) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/iszero_sub_to_eq.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/iszero_sub_to_eq.yul index 7efa54b02..3e0f785e9 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/iszero_sub_to_eq.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/iszero_sub_to_eq.yul @@ -10,7 +10,9 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// let a := calldataload(_1) -// if eq(a, calldataload(0x20)) { sstore(_1, 1) } +// { +// let _1 := 0 +// let a := calldataload(_1) +// if eq(a, calldataload(0x20)) { sstore(_1, 1) } +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/large_byte_access.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/large_byte_access.yul index 22bfaf91f..19d65dca4 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/large_byte_access.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/large_byte_access.yul @@ -13,14 +13,16 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// let a := calldataload(_1) -// let b := 0 -// let c := byte(20, a) -// pop(create(_1, _1, 0x20)) -// let d := 0 -// sstore(7, a) -// sstore(8, b) -// sstore(9, c) -// sstore(10, d) +// { +// let _1 := 0 +// let a := calldataload(_1) +// let b := 0 +// let c := byte(20, a) +// pop(create(_1, _1, 0x20)) +// let d := 0 +// sstore(7, a) +// sstore(8, b) +// sstore(9, c) +// sstore(10, d) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul index 696d0b111..88ed926b1 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_1.yul @@ -5,6 +5,8 @@ // step: expressionSimplifier // // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 255)) +// { +// let _4 := 0 +// mstore(_4, and(calldataload(_4), 255)) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul index 81fe7e117..a62c5904c 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/mod_and_2.yul @@ -5,6 +5,8 @@ // step: expressionSimplifier // // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) +// { +// let _4 := 0 +// mstore(_4, and(calldataload(_4), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul index eca9021ea..c42693521 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_arguments.yul @@ -7,9 +7,11 @@ // step: expressionSimplifier // // { -// let _2 := f(1) -// let _3 := 0 -// sstore(_3, sub(f(_3), _2)) +// { +// let _2 := f(1) +// let _3 := 0 +// sstore(_3, sub(f(_3), _2)) +// } // function f(a) -> b // { } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_names.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_names.yul index ed439b62f..524567705 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_names.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_different_names.yul @@ -8,7 +8,7 @@ // step: expressionSimplifier // // { -// sstore(0, sub(f1(), f2())) +// { sstore(0, sub(f1(), f2())) } // function f1() -> a // { } // function f2() -> b diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_equality_not_movable.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_equality_not_movable.yul index bba7cf26e..b0215685d 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_equality_not_movable.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_function_call_equality_not_movable.yul @@ -8,7 +8,7 @@ // step: expressionSimplifier // // { -// sstore(sub(f(), f()), 8) +// { sstore(sub(f(), f()), 8) } // function f() -> a // { mstore(0, 1) } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_removes_non_constant_and_not_movable.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_removes_non_constant_and_not_movable.yul index 37065cd4d..a7be174e3 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_removes_non_constant_and_not_movable.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/not_applied_removes_non_constant_and_not_movable.yul @@ -9,9 +9,11 @@ // step: expressionSimplifier // // { -// let _1 := msize() -// let _2 := 0 -// sstore(_2, _1) -// pop(keccak256(_2, _2)) -// sstore(20, 0) +// { +// let _1 := msize() +// let _2 := 0 +// sstore(_2, _1) +// pop(keccak256(_2, _2)) +// sstore(20, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_call.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_call.yul index af34e76bd..abd1b1743 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_call.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_call.yul @@ -7,7 +7,9 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// pop(call(_1, _1, _1, _1, _1, _1, _1)) -// sstore(_1, 0) +// { +// let _1 := 0 +// pop(call(_1, _1, _1, _1, _1, _1, _1)) +// sstore(_1, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func.yul index e1ec04ad1..6465aa797 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func.yul @@ -8,8 +8,10 @@ // step: expressionSimplifier // // { -// pop(f()) -// mstore(0, 0) +// { +// pop(f()) +// mstore(0, 0) +// } // function f() -> x // { mstore(0, 1337) } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func_trivial.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func_trivial.yul index 448e071d8..b822b402b 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func_trivial.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/pop_byte_shr_func_trivial.yul @@ -7,4 +7,4 @@ // ---- // step: expressionSimplifier // -// { sstore(0, 0) } +// { { sstore(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/reassign.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/reassign.yul index d87b84f59..d0cf0a6ee 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/reassign.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/reassign.yul @@ -7,8 +7,10 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// let x := mload(_1) -// x := _1 -// mstore(_1, 7) +// { +// let _1 := 0 +// let x := mload(_1) +// x := _1 +// mstore(_1, 7) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul index 060a4e13f..a4d3012c3 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul @@ -12,12 +12,14 @@ // step: expressionSimplifier // // { -// let _2 := calldataload(0) -// let _5 := 0xff -// let a := shr(248, _2) -// let b := shr(248, _2) -// let c := and(shr(249, _2), 0xfa) -// let d := and(shr(247, _2), _5) -// sstore(a, b) -// sstore(c, d) +// { +// let _2 := calldataload(0) +// let _5 := 0xff +// let a := shr(248, _2) +// let b := shr(248, _2) +// let c := and(shr(249, _2), 0xfa) +// let d := and(shr(247, _2), _5) +// sstore(a, b) +// sstore(c, d) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul index 88263e98e..85c86f0e4 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul @@ -12,12 +12,14 @@ // step: expressionSimplifier // // { -// let a := 0 -// let b := 0 -// let _8 := calldataload(2) -// let _9 := 255 -// let c := shl(_9, _8) -// let d := shr(_9, calldataload(3)) -// sstore(a, b) -// sstore(c, d) +// { +// let a := 0 +// let b := 0 +// let _8 := calldataload(2) +// let _9 := 255 +// let c := shl(_9, _8) +// let d := shr(_9, calldataload(3)) +// sstore(a, b) +// sstore(c, d) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul index ca31e7613..73a79410d 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul @@ -10,7 +10,7 @@ // step: expressionSimplifier // // { -// let t, v := f() +// { let t, v := f() } // function f() -> c, d // { sstore(0, 7) } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/reversed.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/reversed.yul index 32c877572..b83b77c21 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/reversed.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/reversed.yul @@ -6,6 +6,8 @@ // step: expressionSimplifier // // { -// let _1 := 0 -// sstore(_1, mload(_1)) +// { +// let _1 := 0 +// sstore(_1, mload(_1)) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_not_supported.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_not_supported.yul index 8a9bb7c19..3f30eefd6 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_not_supported.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_not_supported.yul @@ -6,4 +6,6 @@ // ---- // step: expressionSimplifier // -// { sstore(0, balance(address())) } +// { +// { sstore(0, balance(address())) } +// } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_split.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_split.yul index b14098ffe..72562a2fd 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_split.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_split.yul @@ -9,6 +9,8 @@ // step: expressionSimplifier // // { -// let a := address() -// sstore(a, selfbalance()) +// { +// let a := address() +// sstore(a, selfbalance()) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_supported.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_supported.yul index bc3c6c4d7..7ed42b360 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_supported.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/selfbalance_supported.yul @@ -6,4 +6,4 @@ // ---- // step: expressionSimplifier // -// { sstore(0, selfbalance()) } +// { { sstore(0, selfbalance()) } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul index 14d65c4e9..bd567a69a 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul @@ -9,6 +9,8 @@ // step: expressionSimplifier // // { -// for { } div(create(0, 1, 0), shl(msize(), 1)) { } -// { } +// { +// for { } div(create(0, 1, 0), shl(msize(), 1)) { } +// { } +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/smoke.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/smoke.yul index 30a2f5e90..0fae4792f 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/smoke.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/smoke.yul @@ -2,4 +2,4 @@ // ---- // step: expressionSimplifier // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul index b052fe403..a15cca231 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul @@ -8,6 +8,8 @@ // step: expressionSimplifier // // { -// let c, d -// sstore(d, 7) +// { +// let c, d +// sstore(d, 7) +// } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul index 9dd4e3365..b6828cf8c 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul @@ -8,4 +8,4 @@ // ---- // step: expressionSimplifier // -// { sstore(8, 7) } +// { { sstore(8, 7) } } diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul index c1ce89bcf..fbc0ca856 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul @@ -13,6 +13,7 @@ // step: fullInliner // // { +// { } // function f(a) -> b // { b := sload(mload(a)) } // function g() -> x_1 diff --git a/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul b/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul index 968ec4767..a13ad9395 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/constant_propagation.yul @@ -6,6 +6,8 @@ // step: fullSimplify // // { -// let _2 := 0 -// mstore(mload(_2), _2) +// { +// let _2 := 0 +// mstore(mload(_2), _2) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/constants.yul b/test/libyul/yulOptimizerTests/fullSimplify/constants.yul index 0b31d361f..2d2fb7044 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/constants.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/constants.yul @@ -5,4 +5,4 @@ // ---- // step: fullSimplify // -// { mstore(0, 13) } +// { { mstore(0, 13) } } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_complex.yul b/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_complex.yul index 452ceaae6..eb104f633 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_complex.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_complex.yul @@ -5,4 +5,4 @@ // ---- // step: fullSimplify // -// { mstore(0, 0) } +// { { mstore(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_negative.yul b/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_negative.yul index 8c5e4e5df..daf34eed5 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_negative.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_negative.yul @@ -6,6 +6,8 @@ // step: fullSimplify // // { -// let _1 := 0 -// mstore(_1, sub(calldataload(1), calldataload(_1))) +// { +// let _1 := 0 +// mstore(_1, sub(calldataload(1), calldataload(_1))) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_simple.yul b/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_simple.yul index e8efb735c..6f90c583e 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_simple.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/identity_rules_simple.yul @@ -5,4 +5,4 @@ // ---- // step: fullSimplify // -// { mstore(0, 0) } +// { { mstore(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/including_function_calls.yul b/test/libyul/yulOptimizerTests/fullSimplify/including_function_calls.yul index 090b3cde6..08dd01646 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/including_function_calls.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/including_function_calls.yul @@ -7,7 +7,7 @@ // step: fullSimplify // // { -// mstore(f(), 0) +// { mstore(f(), 0) } // function f() -> a // { } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/inside_for.yul b/test/libyul/yulOptimizerTests/fullSimplify/inside_for.yul index 9d4e52dc1..911c66817 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/inside_for.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/inside_for.yul @@ -7,7 +7,9 @@ // step: fullSimplify // // { -// let a := 10 -// for { } iszero(iszero(a)) { a := add(a, 1) } -// { } +// { +// let a := 10 +// for { } iszero(iszero(a)) { a := add(a, 1) } +// { } +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul b/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul index 687491818..0ab5cc6ed 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/invariant.yul @@ -11,8 +11,10 @@ // step: fullSimplify // // { -// let a := calldataload(0) -// let _4 := 0 -// let b := a -// mstore(b, eq(calldataload(_4), a)) +// { +// let a := calldataload(0) +// let _4 := 0 +// let b := a +// mstore(b, eq(calldataload(_4), a)) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul index 1e448c9a4..c10345e4e 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_1.yul @@ -5,6 +5,8 @@ // step: fullSimplify // // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 255)) +// { +// let _4 := 0 +// mstore(_4, and(calldataload(_4), 255)) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul index 0756c1841..fc171337f 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/mod_and_2.yul @@ -5,6 +5,8 @@ // step: fullSimplify // // { -// let _4 := 0 -// mstore(_4, and(calldataload(_4), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) +// { +// let _4 := 0 +// mstore(_4, and(calldataload(_4), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul index 517bbe442..e42b6c098 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_arguments.yul @@ -6,9 +6,11 @@ // step: fullSimplify // // { -// let _2 := f(1) -// let _3 := 0 -// mstore(_3, sub(f(_3), _2)) +// { +// let _2 := f(1) +// let _3 := 0 +// mstore(_3, sub(f(_3), _2)) +// } // function f(a) -> b // { } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_names.yul b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_names.yul index 7f8fddf2e..31490cbc0 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_names.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_different_names.yul @@ -8,7 +8,7 @@ // step: fullSimplify // // { -// mstore(0, sub(f1(), f2())) +// { mstore(0, sub(f1(), f2())) } // function f1() -> a // { } // function f2() -> b diff --git a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_equality_not_movable.yul b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_equality_not_movable.yul index 52030fe88..8162119e8 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_equality_not_movable.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_function_call_equality_not_movable.yul @@ -8,7 +8,7 @@ // step: fullSimplify // // { -// mstore(0, sub(f(), f())) +// { mstore(0, sub(f(), f())) } // function f() -> a // { mstore(1, 2) } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_removes_non_constant_and_not_movable.yul b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_removes_non_constant_and_not_movable.yul index 05fc9447d..0e366e6d4 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/not_applied_removes_non_constant_and_not_movable.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/not_applied_removes_non_constant_and_not_movable.yul @@ -7,7 +7,9 @@ // step: fullSimplify // // { -// let _1 := 0 -// pop(create(_1, _1, _1)) -// mstore(_1, 0) +// { +// let _1 := 0 +// pop(create(_1, _1, _1)) +// mstore(_1, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/operations.yul b/test/libyul/yulOptimizerTests/fullSimplify/operations.yul index 93b424233..a0fb67601 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/operations.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/operations.yul @@ -23,22 +23,24 @@ // step: fullSimplify // // { -// mstore(1, 0) -// mstore(2, 0) -// mstore(3, 0) -// mstore(4, 0) -// mstore(5, 0) -// mstore(6, 0) -// mstore(7, 0) -// mstore(8, 0) -// mstore(9, 0) -// mstore(10, 0) -// mstore(11, 0) -// mstore(12, 0) -// mstore(13, 0) -// mstore(14, 0) -// mstore(15, 0) -// mstore(16, 0) -// mstore(17, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) -// mstore(18, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) +// { +// mstore(1, 0) +// mstore(2, 0) +// mstore(3, 0) +// mstore(4, 0) +// mstore(5, 0) +// mstore(6, 0) +// mstore(7, 0) +// mstore(8, 0) +// mstore(9, 0) +// mstore(10, 0) +// mstore(11, 0) +// mstore(12, 0) +// mstore(13, 0) +// mstore(14, 0) +// mstore(15, 0) +// mstore(16, 0) +// mstore(17, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) +// mstore(18, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/reversed.yul b/test/libyul/yulOptimizerTests/fullSimplify/reversed.yul index 5fe632495..b3b98d061 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/reversed.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/reversed.yul @@ -6,6 +6,8 @@ // step: fullSimplify // // { -// let _1 := 0 -// mstore(_1, mload(_1)) +// { +// let _1 := 0 +// mstore(_1, mload(_1)) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/signextend.yul b/test/libyul/yulOptimizerTests/fullSimplify/signextend.yul index 9ebdf0128..2dd64525f 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/signextend.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/signextend.yul @@ -8,6 +8,8 @@ // step: fullSimplify // // { -// mstore(0, 7) -// mstore(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) +// { +// mstore(0, 7) +// mstore(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSimplify/smoke.yul b/test/libyul/yulOptimizerTests/fullSimplify/smoke.yul index 15ff14a84..a5b71eea8 100644 --- a/test/libyul/yulOptimizerTests/fullSimplify/smoke.yul +++ b/test/libyul/yulOptimizerTests/fullSimplify/smoke.yul @@ -2,4 +2,4 @@ // ---- // step: fullSimplify // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/loadResolver/double_mload.yul b/test/libyul/yulOptimizerTests/loadResolver/double_mload.yul index b75f9c07b..144835476 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/double_mload.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/double_mload.yul @@ -8,6 +8,8 @@ // step: loadResolver // // { -// let a := mload(calldataload(0)) -// sstore(a, a) +// { +// let a := mload(calldataload(0)) +// sstore(a, a) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_other_reassignment.yul b/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_other_reassignment.yul index 19d217423..7ffac34c0 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_other_reassignment.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_other_reassignment.yul @@ -9,8 +9,10 @@ // step: loadResolver // // { -// let x := calldataload(0) -// let a := mload(x) -// x := 7 -// sstore(a, mload(x)) +// { +// let x := calldataload(0) +// let a := mload(x) +// x := 7 +// sstore(a, mload(x)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_reassignment.yul b/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_reassignment.yul index b5c2f1126..7f8514875 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_reassignment.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/double_mload_with_reassignment.yul @@ -9,8 +9,10 @@ // step: loadResolver // // { -// let x := calldataload(0) -// let a := mload(x) -// a := 7 -// sstore(a, mload(x)) +// { +// let x := calldataload(0) +// let a := mload(x) +// a := 7 +// sstore(a, mload(x)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak.yul index 97b468e5f..25b36f5fe 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak.yul @@ -9,8 +9,10 @@ // step: loadResolver // // { -// let _1 := 10 -// let _2 := 0 -// mstore(_2, _1) -// sstore(_2, 89717814153306320011181716697424560163256864414616650038987186496166826726056) +// { +// let _1 := 10 +// let _2 := 0 +// mstore(_2, _1) +// sstore(_2, 89717814153306320011181716697424560163256864414616650038987186496166826726056) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_crash.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_crash.yul index dd6a164eb..18c818d15 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_crash.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_crash.yul @@ -6,8 +6,10 @@ // step: loadResolver // // { -// for { } -// addmod(keccak256(0x0, create(0x0, 0x0, 0x0)), 0x0, 0x0) -// { } -// { } +// { +// for { } +// addmod(keccak256(0x0, create(0x0, 0x0, 0x0)), 0x0, 0x0) +// { } +// { } +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_fail1.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_fail1.yul index e1157f21d..e4fe6484f 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_fail1.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_fail1.yul @@ -10,9 +10,11 @@ // step: loadResolver // // { -// let _1 := 30 -// let _2 := 0 -// mstore(_2, _1) -// if calldataload(_2) { mstore(_2, 20) } -// sstore(_2, keccak256(_2, 32)) +// { +// let _1 := 30 +// let _2 := 0 +// mstore(_2, _1) +// if calldataload(_2) { mstore(_2, 20) } +// sstore(_2, keccak256(_2, 32)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_fail2.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_fail2.yul index 61a2eefb2..5a7d571a4 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_fail2.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_fail2.yul @@ -9,8 +9,10 @@ // step: loadResolver // // { -// let _1 := 10 -// mstore(100, _1) -// mstore(132, 5) -// sstore(0, keccak256(_1, 33)) +// { +// let _1 := 10 +// mstore(100, _1) +// mstore(132, 5) +// sstore(0, keccak256(_1, 33)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul index d1761b7ce..58cb7c264 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_short.yul @@ -19,13 +19,15 @@ // step: loadResolver // // { -// let _1 := 10 -// let _2 := 0 -// mstore(_2, _1) -// sstore(_2, 9948786400348073077032572701554570401043517428989726124163377057770909578447) -// sstore(1, 110945455955148346822663466543669633859020391897956790847617069135813044810108) -// let _13 := 85131057757245807317576516368191972321038229705283732634690444270750521936266 -// let _14 := 2 -// sstore(_14, _13) -// sstore(_14, 89477152217924674838424037953991966239322087453347756267410168184682657981552) +// { +// let _1 := 10 +// let _2 := 0 +// mstore(_2, _1) +// sstore(_2, 9948786400348073077032572701554570401043517428989726124163377057770909578447) +// sstore(1, 110945455955148346822663466543669633859020391897956790847617069135813044810108) +// let _13 := 85131057757245807317576516368191972321038229705283732634690444270750521936266 +// let _14 := 2 +// sstore(_14, _13) +// sstore(_14, 89477152217924674838424037953991966239322087453347756267410168184682657981552) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_string_literal.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_string_literal.yul index 279a23959..261f38cd1 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_string_literal.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_string_literal.yul @@ -12,11 +12,13 @@ // step: loadResolver // // { -// let _1 := 50 -// let _2 := "abcdefghijklmn" -// mstore(_1, _2) -// let _3 := 51246744213555520563123611275127692828770413530219146609532820042079541949502 -// let _4 := 0 -// sstore(_4, _3) -// sstore(_4, add(_2, 1)) +// { +// let _1 := 50 +// let _2 := "abcdefghijklmn" +// mstore(_1, _2) +// let _3 := 51246744213555520563123611275127692828770413530219146609532820042079541949502 +// let _4 := 0 +// sstore(_4, _3) +// sstore(_4, add(_2, 1)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_symbolic_memory.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_symbolic_memory.yul index c18af0c8d..46466a062 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_symbolic_memory.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_symbolic_memory.yul @@ -15,8 +15,10 @@ // step: loadResolver // // { -// let _1 := 0 -// mstore(calldataload(_1), 500) -// sstore(_1, 92647596584187651892918913434663110448935397770592030057655219009846081465370) -// sstore(1, 110620294328144418057589324861608220015688365608948720310623173341503153578932) +// { +// let _1 := 0 +// mstore(calldataload(_1), 500) +// sstore(_1, 92647596584187651892918913434663110448935397770592030057655219009846081465370) +// sstore(1, 110620294328144418057589324861608220015688365608948720310623173341503153578932) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/keccak_with_msize.yul b/test/libyul/yulOptimizerTests/loadResolver/keccak_with_msize.yul index fdc1e8836..5e1c7d419 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/keccak_with_msize.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/keccak_with_msize.yul @@ -11,9 +11,11 @@ // step: loadResolver // // { -// let _1 := msize() -// let _2 := 0 -// sstore(_2, _1) -// mstore(_2, 10) -// sstore(1, keccak256(_2, 32)) +// { +// let _1 := msize() +// let _2 := 0 +// sstore(_2, _1) +// mstore(_2, 10) +// sstore(1, keccak256(_2, 32)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/loop.yul b/test/libyul/yulOptimizerTests/loadResolver/loop.yul index 3606891ee..458767160 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/loop.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/loop.yul @@ -8,11 +8,13 @@ // step: loadResolver // // { -// let _1 := 123213 -// let _2 := 0 -// sstore(_2, _1) -// let x := _2 -// let y -// for { } lt(x, _1) { x := add(x, 1) } -// { y := add(x, y) } +// { +// let _1 := 123213 +// let _2 := 0 +// sstore(_2, _1) +// let x := _2 +// let y +// for { } lt(x, _1) { x := add(x, 1) } +// { y := add(x, y) } +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/memory_with_different_kinds_of_invalidation.yul b/test/libyul/yulOptimizerTests/loadResolver/memory_with_different_kinds_of_invalidation.yul index 77fc5aef0..840f19005 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/memory_with_different_kinds_of_invalidation.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/memory_with_different_kinds_of_invalidation.yul @@ -18,18 +18,20 @@ // step: loadResolver // // { -// let _1 := 9 -// let _2 := 2 -// mstore(_2, _1) -// let _4 := _1 -// let _5 := 0 -// sstore(_5, _4) -// pop(call(_5, _5, _5, _5, _5, _5, _5)) -// sstore(_5, mload(_2)) -// let _17 := 10 -// mstore(_2, _17) -// mstore8(calldataload(_5), 4) -// sstore(_5, mload(_2)) -// mstore(_2, _17) -// sstore(_5, _17) +// { +// let _1 := 9 +// let _2 := 2 +// mstore(_2, _1) +// let _4 := _1 +// let _5 := 0 +// sstore(_5, _4) +// pop(call(_5, _5, _5, _5, _5, _5, _5)) +// sstore(_5, mload(_2)) +// let _17 := 10 +// mstore(_2, _17) +// mstore8(calldataload(_5), 4) +// sstore(_5, mload(_2)) +// mstore(_2, _17) +// sstore(_5, _17) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul b/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul index 199fb1f6c..f54053bb1 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/memory_with_msize.yul @@ -9,9 +9,11 @@ // step: loadResolver // // { -// let _1 := msize() -// let _3 := calldataload(0) -// mstore(_3, _1) -// let t := mload(calldataload(10)) -// sstore(t, mload(_3)) +// { +// let _1 := msize() +// let _3 := calldataload(0) +// mstore(_3, _1) +// let t := mload(calldataload(10)) +// sstore(t, mload(_3)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul index e9ced5f4c..acb96c07b 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write.yul @@ -11,12 +11,14 @@ // step: loadResolver // // { -// let _2 := calldataload(10) -// let _3 := 0 -// let _4 := calldataload(_3) -// mstore(_4, _2) -// let _5 := 1 -// if calldataload(_5) { mstore(_4, _5) } -// let t := mload(_3) -// sstore(t, mload(_4)) +// { +// let _2 := calldataload(10) +// let _3 := 0 +// let _4 := calldataload(_3) +// mstore(_4, _2) +// let _5 := 1 +// if calldataload(_5) { mstore(_4, _5) } +// let t := mload(_3) +// sstore(t, mload(_4)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul index 8ce9fba00..1659949a3 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_known_write_with_distance.yul @@ -11,10 +11,12 @@ // step: loadResolver // // { -// let _2 := calldataload(10) -// let _4 := calldataload(0) -// mstore(_4, _2) -// let _5 := 1 -// if calldataload(_5) { mstore(add(_4, 0x20), _5) } -// sstore(mload(add(_4, 0x20)), _2) +// { +// let _2 := calldataload(10) +// let _4 := calldataload(0) +// mstore(_4, _2) +// let _5 := 1 +// if calldataload(_5) { mstore(add(_4, 0x20), _5) } +// sstore(mload(add(_4, 0x20)), _2) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul index cde3ec0e6..18740c049 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_known_distance.yul @@ -11,9 +11,11 @@ // step: loadResolver // // { -// let _2 := calldataload(0) -// let x := mload(_2) -// let _3 := 1 -// if calldataload(_3) { mstore(add(_2, 0x20), _3) } -// sstore(mload(add(_2, 0x20)), x) +// { +// let _2 := calldataload(0) +// let x := mload(_2) +// let _3 := 1 +// if calldataload(_3) { mstore(add(_2, 0x20), _3) } +// sstore(mload(add(_2, 0x20)), x) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_rewrite.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_rewrite.yul index 5c09b9b43..00bb85c4c 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_rewrite.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_with_rewrite.yul @@ -11,12 +11,14 @@ // step: loadResolver // // { -// let _1 := 2 -// let b := mload(_1) -// if calldataload(1) // { -// mstore(_1, 7) -// mstore(_1, b) +// let _1 := 2 +// let b := mload(_1) +// if calldataload(1) +// { +// mstore(_1, 7) +// mstore(_1, b) +// } +// sstore(0, b) // } -// sstore(0, b) // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_without_rewrite.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_without_rewrite.yul index f6d0bdc7d..760641698 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_mload_without_rewrite.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_mload_without_rewrite.yul @@ -10,10 +10,12 @@ // step: loadResolver // // { -// let _1 := 2 -// let b := mload(_1) -// let _2 := 0 -// sstore(_2, b) -// if calldataload(1) { mstore(_1, 7) } -// sstore(_2, mload(_1)) +// { +// let _1 := 2 +// let b := mload(_1) +// let _2 := 0 +// sstore(_2, b) +// if calldataload(1) { mstore(_1, 7) } +// sstore(_2, mload(_1)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul index 225e0f627..e8cc3cf4b 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_unknown_write.yul @@ -11,12 +11,14 @@ // step: loadResolver // // { -// let _2 := calldataload(10) -// let _3 := 0 -// let _4 := calldataload(_3) -// mstore(_4, _2) -// let _5 := 1 -// if calldataload(_5) { mstore(_3, _5) } -// let t := mload(_3) -// sstore(t, mload(_4)) +// { +// let _2 := calldataload(10) +// let _3 := 0 +// let _4 := calldataload(_3) +// mstore(_4, _2) +// let _5 := 1 +// if calldataload(_5) { mstore(_3, _5) } +// let t := mload(_3) +// sstore(t, mload(_4)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/merge_with_rewrite.yul b/test/libyul/yulOptimizerTests/loadResolver/merge_with_rewrite.yul index b4b113e81..c6c76f425 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/merge_with_rewrite.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/merge_with_rewrite.yul @@ -11,13 +11,15 @@ // step: loadResolver // // { -// let _1 := 3 -// let _2 := 2 -// mstore(_2, _1) -// if calldataload(1) // { -// mstore(_2, 7) +// let _1 := 3 +// let _2 := 2 // mstore(_2, _1) +// if calldataload(1) +// { +// mstore(_2, 7) +// mstore(_2, _1) +// } +// sstore(0, _1) // } -// sstore(0, _1) // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul b/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul index a8d9e2af0..b76d071ae 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mload_in_function.yul @@ -10,11 +10,13 @@ // step: loadResolver // // { -// let _1 := 1337 -// let _2 := 0 -// mstore(_2, _1) -// foo(42) -// sstore(_2, mload(_2)) +// { +// let _1 := 1337 +// let _2 := 0 +// mstore(_2, _1) +// foo(42) +// sstore(_2, mload(_2)) +// } // function foo(x) // { // for { } diff --git a/test/libyul/yulOptimizerTests/loadResolver/mload_self.yul b/test/libyul/yulOptimizerTests/loadResolver/mload_self.yul index e299bcbb9..6ad9d36ac 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mload_self.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mload_self.yul @@ -8,8 +8,10 @@ // step: loadResolver // // { -// let _1 := 0 -// let x := calldataload(_1) -// x := mload(x) -// sstore(_1, mload(x)) +// { +// let _1 := 0 +// let x := calldataload(_1) +// x := mload(x) +// sstore(_1, mload(x)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul index 6fcf7a6aa..901ea12ef 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_body.yul @@ -15,11 +15,13 @@ // step: loadResolver // // { -// let _1 := 1337 -// let _2 := 0 -// mstore(_2, _1) -// funcWithLoop(42) -// sstore(_2, mload(_2)) +// { +// let _1 := 1337 +// let _2 := 0 +// mstore(_2, _1) +// funcWithLoop(42) +// sstore(_2, mload(_2)) +// } // function userNot(x) -> y // { y := iszero(x) } // function funcWithLoop(x_1) diff --git a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul index 4794237d6..6fb0fdcba 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/mstore_in_function_loop_init.yul @@ -15,11 +15,13 @@ // step: loadResolver // // { -// let _1 := 1337 -// let _2 := 0 -// mstore(_2, _1) -// funcWithLoop(42) -// sstore(_2, mload(_2)) +// { +// let _1 := 1337 +// let _2 := 0 +// mstore(_2, _1) +// funcWithLoop(42) +// sstore(_2, mload(_2)) +// } // function userNot(x) -> y // { y := iszero(x) } // function funcWithLoop(x_1) diff --git a/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul b/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul index 9aecad529..c367059eb 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/multi_sload_loop.yul @@ -14,17 +14,19 @@ // step: loadResolver // // { -// let _1 := 0 -// let x := calldataload(_1) -// let len := sload(x) -// let sum -// let i := _1 -// for { } lt(i, len) { i := add(i, 1) } // { -// let p := add(add(x, i), 1) -// if gt(p, len) { revert(_1, _1) } -// sum := add(sum, sload(p)) +// let _1 := 0 +// let x := calldataload(_1) +// let len := sload(x) +// let sum +// let i := _1 +// for { } lt(i, len) { i := add(i, 1) } +// { +// let p := add(add(x, i), 1) +// if gt(p, len) { revert(_1, _1) } +// sum := add(sum, sload(p)) +// } +// mstore(_1, sum) +// return(_1, 0x20) // } -// mstore(_1, sum) -// return(_1, 0x20) // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/re_store_memory.yul b/test/libyul/yulOptimizerTests/loadResolver/re_store_memory.yul index 01e29b705..031a5f22a 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/re_store_memory.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/re_store_memory.yul @@ -11,11 +11,13 @@ // step: loadResolver // // { -// let a := 0 -// let b := 1 -// let c := 2 -// mstore(a, b) -// sstore(a, b) -// mstore(a, c) -// sstore(10, c) +// { +// let a := 0 +// let b := 1 +// let c := 2 +// mstore(a, b) +// sstore(a, b) +// mstore(a, c) +// sstore(10, c) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/re_store_storage.yul b/test/libyul/yulOptimizerTests/loadResolver/re_store_storage.yul index 8c33e4f5d..fab562208 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/re_store_storage.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/re_store_storage.yul @@ -11,11 +11,13 @@ // step: loadResolver // // { -// let a := 0 -// let b := 1 -// let c := 2 -// sstore(a, b) -// mstore(a, b) -// sstore(a, c) -// mstore(32, c) +// { +// let a := 0 +// let b := 1 +// let c := 2 +// sstore(a, b) +// mstore(a, b) +// sstore(a, c) +// mstore(32, c) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/reassign.yul b/test/libyul/yulOptimizerTests/loadResolver/reassign.yul index 4687422e9..694b59e26 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/reassign.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/reassign.yul @@ -8,9 +8,11 @@ // step: loadResolver // // { -// let _1 := 0 -// let a := calldataload(_1) -// sstore(a, 6) -// a := calldataload(2) -// mstore(_1, sload(a)) +// { +// let _1 := 0 +// let a := calldataload(_1) +// sstore(a, 6) +// a := calldataload(2) +// mstore(_1, sload(a)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul b/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul index 1b73cecb9..402987acb 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/reassign_value_expression.yul @@ -18,15 +18,17 @@ // step: loadResolver // // { -// let x := calldataload(1) -// let a := add(x, 10) -// let _3 := 7 -// sstore(a, _3) -// x := 9 -// let _4 := 11 -// mstore(_3, _4) -// a := 33 -// mstore(sload(a), _4) -// a := 39 -// mstore(sload(a), _4) +// { +// let x := calldataload(1) +// let a := add(x, 10) +// let _3 := 7 +// sstore(a, _3) +// x := 9 +// let _4 := 11 +// mstore(_3, _4) +// a := 33 +// mstore(sload(a), _4) +// a := 39 +// mstore(sload(a), _4) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul b/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul index 1aa05106c..8f1cf338f 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_mstore_with_delta.yul @@ -13,12 +13,14 @@ // step: loadResolver // // { -// let x := calldataload(1) -// let a := add(x, 10) -// let b := add(x, 42) -// let _4 := 7 -// mstore(a, _4) -// let _5 := 8 -// mstore(b, _5) -// sstore(_4, _5) +// { +// let x := calldataload(1) +// let a := add(x, 10) +// let b := add(x, 42) +// let _4 := 7 +// mstore(a, _4) +// let _5 := 8 +// mstore(b, _5) +// sstore(_4, _5) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_store.yul b/test/libyul/yulOptimizerTests/loadResolver/second_store.yul index f6f8250ce..eb960a9f6 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_store.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_store.yul @@ -10,10 +10,12 @@ // step: loadResolver // // { -// let x := calldataload(1) -// sstore(x, 7) -// let _3 := 6 -// let _4 := 0 -// sstore(calldataload(_4), _3) -// mstore(_4, sload(x)) +// { +// let x := calldataload(1) +// sstore(x, 7) +// let _3 := 6 +// let _4 := 0 +// sstore(calldataload(_4), _3) +// mstore(_4, sload(x)) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul b/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul index a5cb459ad..e13b8aa5f 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_store_same_value.yul @@ -10,10 +10,12 @@ // step: loadResolver // // { -// let x := calldataload(1) -// let _2 := 7 -// sstore(x, _2) -// let _4 := 0 -// sstore(calldataload(_4), _2) -// mstore(_4, _2) +// { +// let x := calldataload(1) +// let _2 := 7 +// sstore(x, _2) +// let _4 := 0 +// sstore(calldataload(_4), _2) +// mstore(_4, _2) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul b/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul index c2e669b7f..f301737ec 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/second_store_with_delta.yul @@ -13,12 +13,14 @@ // step: loadResolver // // { -// let x := calldataload(1) -// let a := add(x, 10) -// let b := add(x, 20) -// let _4 := 7 -// sstore(a, _4) -// let _5 := 8 -// sstore(b, _5) -// mstore(_4, _5) +// { +// let x := calldataload(1) +// let a := add(x, 10) +// let b := add(x, 20) +// let _4 := 7 +// sstore(a, _4) +// let _5 := 8 +// sstore(b, _5) +// mstore(_4, _5) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul b/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul index 684e6b94f..b1eefd089 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/side_effects_of_user_functions.yul @@ -12,15 +12,17 @@ // step: loadResolver // // { -// let _1 := 9 -// let _2 := 2 -// mstore(_2, _1) -// reads() -// let _4 := _1 -// let _5 := 0 -// sstore(_5, _4) -// stores() -// sstore(_5, mload(_2)) +// { +// let _1 := 9 +// let _2 := 2 +// mstore(_2, _1) +// reads() +// let _4 := _1 +// let _5 := 0 +// sstore(_5, _4) +// stores() +// sstore(_5, mload(_2)) +// } // function stores() // { mstore(0, 1) } // function reads() diff --git a/test/libyul/yulOptimizerTests/loadResolver/simple.yul b/test/libyul/yulOptimizerTests/loadResolver/simple.yul index a645f1692..a20025bcd 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/simple.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/simple.yul @@ -8,7 +8,9 @@ // step: loadResolver // // { -// let _2 := calldataload(10) -// sstore(calldataload(0), _2) -// mstore(sload(_2), _2) +// { +// let _2 := calldataload(10) +// sstore(calldataload(0), _2) +// mstore(sload(_2), _2) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul b/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul index 667abe053..3aa1d740f 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/simple_memory.yul @@ -8,7 +8,9 @@ // step: loadResolver // // { -// let _2 := calldataload(10) -// mstore(calldataload(0), _2) -// sstore(mload(_2), _2) +// { +// let _2 := calldataload(10) +// mstore(calldataload(0), _2) +// sstore(mload(_2), _2) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/staticcall.yul b/test/libyul/yulOptimizerTests/loadResolver/staticcall.yul index b24ab0170..2a72eee3e 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/staticcall.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/staticcall.yul @@ -15,14 +15,16 @@ // step: loadResolver // // { -// let a := 0 -// let b := 1 -// sstore(a, b) -// let _1 := 7 -// let _2 := 900 -// mstore(_2, _1) -// let _3 := 200 -// pop(staticcall(10000, 10, a, _3, a, _3)) -// sstore(1, mload(_2)) -// mstore(a, b) +// { +// let a := 0 +// let b := 1 +// sstore(a, b) +// let _1 := 7 +// let _2 := 900 +// mstore(_2, _1) +// let _3 := 200 +// pop(staticcall(10000, 10, a, _3, a, _3)) +// sstore(1, mload(_2)) +// mstore(a, b) +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/verbatim_mload.yul b/test/libyul/yulOptimizerTests/loadResolver/verbatim_mload.yul index 150c0240b..8d417a177 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/verbatim_mload.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/verbatim_mload.yul @@ -8,9 +8,11 @@ // step: loadResolver // // { -// let _1 := 20 -// let _2 := 10 -// mstore(_2, _1) -// sstore(0, mload(_2)) -// verbatim_0i_0o("test") +// { +// let _1 := 20 +// let _2 := 10 +// mstore(_2, _1) +// sstore(0, mload(_2)) +// verbatim_0i_0o("test") +// } // } diff --git a/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul b/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul index ba9cb32d8..81479a509 100644 --- a/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul +++ b/test/libyul/yulOptimizerTests/loadResolver/verbatim_sload.yul @@ -10,12 +10,14 @@ // step: loadResolver // // { -// let _1 := 20 -// let _2 := 10 -// sstore(_2, _1) -// let _4 := _1 -// let _5 := 30 -// sstore(_5, _4) -// verbatim_0i_0o("test") -// sstore(_5, sload(_2)) +// { +// let _1 := 20 +// let _2 := 10 +// sstore(_2, _1) +// let _4 := _1 +// let _5 := 30 +// sstore(_5, _4) +// verbatim_0i_0o("test") +// sstore(_5, sload(_2)) +// } // } diff --git a/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul b/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul index c8b22424c..875bececd 100644 --- a/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul +++ b/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul @@ -10,12 +10,14 @@ // step: splitJoin // // { -// if mul(add(calldataload(0), 2), 3) // { -// for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } +// if mul(add(calldataload(0), 2), 3) // { -// let b := mul(add(a, 2), 4) -// sstore(b, mul(b, 2)) +// for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } +// { +// let b := mul(add(a, 2), 4) +// sstore(b, mul(b, 2)) +// } // } // } // } diff --git a/test/libyul/yulOptimizerTests/splitJoin/functions.yul b/test/libyul/yulOptimizerTests/splitJoin/functions.yul index e2f554dd0..08e741e8e 100644 --- a/test/libyul/yulOptimizerTests/splitJoin/functions.yul +++ b/test/libyul/yulOptimizerTests/splitJoin/functions.yul @@ -12,14 +12,16 @@ // step: splitJoin // // { -// let x := f(0) +// { +// let x := f(0) +// for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } +// { +// let b := mul(add(a, f(a)), 4) +// sstore(b, mul(b, 2)) +// } +// } // function f(y) -> r // { // r := mload(mul(6, add(y, 0x20))) // } -// for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } -// { -// let b := mul(add(a, f(a)), 4) -// sstore(b, mul(b, 2)) -// } // } diff --git a/test/libyul/yulOptimizerTests/splitJoin/smoke.yul b/test/libyul/yulOptimizerTests/splitJoin/smoke.yul index 4aac31ddb..86e53ab14 100644 --- a/test/libyul/yulOptimizerTests/splitJoin/smoke.yul +++ b/test/libyul/yulOptimizerTests/splitJoin/smoke.yul @@ -2,4 +2,4 @@ // ---- // step: splitJoin // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul b/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul index 43b9ade6a..19b3ba44e 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/for_loop.yul @@ -19,12 +19,14 @@ // step: ssaAndBack // // { -// let a := mload(0) -// let b := mload(1) -// for { } lt(mload(a), mload(b)) { a := mload(b) } // { -// let b_4 := mload(a) -// a := mload(b_4) -// b := mload(a) +// let a := mload(0) +// let b := mload(1) +// for { } lt(mload(a), mload(b)) { a := mload(b) } +// { +// let b_4 := mload(a) +// a := mload(b_4) +// b := mload(a) +// } // } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul index 2e818561c..1bfd89cd8 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign.yul @@ -10,6 +10,8 @@ // step: ssaAndBack // // { -// let a_5 := mload(4) -// mstore(a_5, 0) +// { +// let a_5 := mload(4) +// mstore(a_5, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_if.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_if.yul index 4815349d7..c0f3a4242 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_if.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_if.yul @@ -12,7 +12,9 @@ // step: ssaAndBack // // { -// let a := mload(0) -// if mload(1) { a := mload(3) } -// mstore(a, 0) +// { +// let a := mload(0) +// if mload(1) { a := mload(3) } +// mstore(a, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul index a0821ab37..e3a671028 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_if.yul @@ -13,14 +13,16 @@ // step: ssaAndBack // // { -// let a := mload(0) -// let b := mload(1) -// if mload(2) // { -// let a_3 := mload(b) -// let b_4 := mload(a_3) -// a := mload(b_4) -// b := mload(a) +// let a := mload(0) +// let b := mload(1) +// if mload(2) +// { +// let a_3 := mload(b) +// let b_4 := mload(a_3) +// a := mload(b_4) +// b := mload(a) +// } +// mstore(a, b) // } -// mstore(a, b) // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul index 92a0ba825..89f3acaa6 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_multi_var_switch.yul @@ -20,20 +20,22 @@ // step: ssaAndBack // // { -// let a := mload(0) -// let b := mload(1) -// switch mload(2) -// case 0 { -// let a_3 := mload(b) -// let b_4 := mload(a_3) -// a := mload(b_4) -// b := mload(a) +// { +// let a := mload(0) +// let b := mload(1) +// switch mload(2) +// case 0 { +// let a_3 := mload(b) +// let b_4 := mload(a_3) +// a := mload(b_4) +// b := mload(a) +// } +// default { +// let b_7 := mload(a) +// let a_8 := mload(b_7) +// b := mload(a_8) +// a := mload(b) +// } +// mstore(a, b) // } -// default { -// let b_7 := mload(a) -// let a_8 := mload(b_7) -// b := mload(a_8) -// a := mload(b) -// } -// mstore(a, b) // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_switch.yul b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_switch.yul index 63c4f8561..b210c09c0 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_switch.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/multi_assign_switch.yul @@ -17,9 +17,11 @@ // step: ssaAndBack // // { -// let a := mload(0) -// switch mload(1) -// case 0 { a := mload(3) } -// default { a := mload(6) } -// mstore(a, 0) +// { +// let a := mload(0) +// switch mload(1) +// case 0 { a := mload(3) } +// default { a := mload(6) } +// mstore(a, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul b/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul index e2f130507..b2979e76d 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/simple.yul @@ -7,6 +7,8 @@ // step: ssaAndBack // // { -// let a_2 := mload(1) -// mstore(a_2, 0) +// { +// let a_2 := mload(1) +// mstore(a_2, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_if.yul b/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_if.yul index e2516b45b..71823f105 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_if.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_if.yul @@ -10,7 +10,9 @@ // step: ssaAndBack // // { -// let a := mload(0) -// if mload(1) { a := mload(1) } -// mstore(a, 0) +// { +// let a := mload(0) +// if mload(1) { a := mload(1) } +// mstore(a, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_switch.yul b/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_switch.yul index e6e0553c1..8c53bd28a 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_switch.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/single_assign_switch.yul @@ -13,9 +13,11 @@ // step: ssaAndBack // // { -// let a := mload(0) -// switch mload(1) -// case 0 { a := mload(1) } -// default { a := mload(2) } -// mstore(a, 0) +// { +// let a := mload(0) +// switch mload(1) +// case 0 { a := mload(1) } +// default { a := mload(2) } +// mstore(a, 0) +// } // } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/ssaReverse.yul b/test/libyul/yulOptimizerTests/ssaAndBack/ssaReverse.yul index 0ef0ffee3..21dfdf2ce 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/ssaReverse.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/ssaReverse.yul @@ -24,8 +24,10 @@ // step: ssaAndBack // // { -// let a, b := abi_decode_t_bytes_calldata_ptr(mload(0), mload(1)) -// mstore(a, b) +// { +// let a, b := abi_decode_t_bytes_calldata_ptr(mload(0), mload(1)) +// mstore(a, b) +// } // function abi_decode_t_bytes_calldata_ptr(offset_12, end_13) -> arrayPos_14, length_15 // { // if iszero(slt(add(offset_12, 0x1f), end_13)) { revert(0, 0) } diff --git a/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul b/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul index 6053bd9ac..120599356 100644 --- a/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul +++ b/test/libyul/yulOptimizerTests/ssaAndBack/two_vars.yul @@ -11,11 +11,13 @@ // step: ssaAndBack // // { -// let a_1 := mload(0) -// let b_2 := mload(a_1) -// let a_3 := mload(b_2) -// let b_4 := mload(a_3) -// let a_5 := mload(b_4) -// let b_6 := mload(a_5) -// mstore(a_5, b_6) +// { +// let a_1 := mload(0) +// let b_2 := mload(a_1) +// let a_3 := mload(b_2) +// let b_4 := mload(a_3) +// let a_5 := mload(b_4) +// let b_6 := mload(a_5) +// mstore(a_5, b_6) +// } // } diff --git a/test/libyul/yulOptimizerTests/stackCompressor/inlineInBlock.yul b/test/libyul/yulOptimizerTests/stackCompressor/inlineInBlock.yul index 382bd201d..3633b3f36 100644 --- a/test/libyul/yulOptimizerTests/stackCompressor/inlineInBlock.yul +++ b/test/libyul/yulOptimizerTests/stackCompressor/inlineInBlock.yul @@ -9,5 +9,7 @@ // step: stackCompressor // // { -// mstore(calldataload(calldataload(9)), add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(calldataload(calldataload(9)), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)) +// { +// mstore(calldataload(calldataload(9)), add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(calldataload(calldataload(9)), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)) +// } // } diff --git a/test/libyul/yulOptimizerTests/stackCompressor/inlineInFunction.yul b/test/libyul/yulOptimizerTests/stackCompressor/inlineInFunction.yul index ed85fe7b8..35dfa5343 100644 --- a/test/libyul/yulOptimizerTests/stackCompressor/inlineInFunction.yul +++ b/test/libyul/yulOptimizerTests/stackCompressor/inlineInFunction.yul @@ -11,7 +11,7 @@ // step: stackCompressor // // { -// let x := 8 +// { let x := 8 } // function f() // { // mstore(calldataload(calldataload(9)), add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(add(calldataload(calldataload(9)), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)) diff --git a/test/libyul/yulOptimizerTests/stackCompressor/noInline.yul b/test/libyul/yulOptimizerTests/stackCompressor/noInline.yul index b5f3dd872..1a178abf0 100644 --- a/test/libyul/yulOptimizerTests/stackCompressor/noInline.yul +++ b/test/libyul/yulOptimizerTests/stackCompressor/noInline.yul @@ -6,7 +6,7 @@ // step: stackCompressor // // { -// let x := 8 +// { let x := 8 } // function f() // { let y := 9 } // } diff --git a/test/libyul/yulOptimizerTests/stackCompressor/unusedPrunerWithMSize.yul b/test/libyul/yulOptimizerTests/stackCompressor/unusedPrunerWithMSize.yul index dc10737ad..0556a2220 100644 --- a/test/libyul/yulOptimizerTests/stackCompressor/unusedPrunerWithMSize.yul +++ b/test/libyul/yulOptimizerTests/stackCompressor/unusedPrunerWithMSize.yul @@ -24,15 +24,17 @@ // step: stackCompressor // // { -// let _17_72 := msize() -// let _22_75 := msize() -// let _25_76 := msize() -// let _30_80 := msize() -// let _32_81 := msize() -// pop(keccak256(1, 2)) -// let _105 := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -// mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(_105, _32_81), 1), _30_80), lt(or(1, add(_25_76, _105)), 1)), _22_75), 1), 1), gt(not(_17_72), 1)), 1)), 1), 1), 1) -// foo_singlereturn_1() +// { +// let _17_72 := msize() +// let _22_75 := msize() +// let _25_76 := msize() +// let _30_80 := msize() +// let _32_81 := msize() +// pop(keccak256(1, 2)) +// let _105 := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(_105, _32_81), 1), _30_80), lt(or(1, add(_25_76, _105)), 1)), _22_75), 1), 1), gt(not(_17_72), 1)), 1)), 1), 1), 1) +// foo_singlereturn_1() +// } // function foo_singlereturn_1() // { extcodecopy(1, msize(), 1, 1) } // } diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for.yul similarity index 85% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for.yul index 314963368..89de8920c 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for.yul @@ -8,7 +8,7 @@ } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let a := 2 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_branch.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_branch.yul similarity index 91% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_branch.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_branch.yul index 120b43ce8..8700c8d28 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_branch.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_branch.yul @@ -14,7 +14,7 @@ mstore(x, 0) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_break.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_break.yul similarity index 93% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_break.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_break.yul index 1b795ad8c..db55bf758 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_break.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_break.yul @@ -13,7 +13,7 @@ mstore(x, 0x42) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul similarity index 94% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul index 0ee9c551d..d3cfb0d84 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul @@ -16,7 +16,7 @@ x := 3 } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue_2.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue_2.yul similarity index 93% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue_2.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue_2.yul index ee747ae5d..2d5bae46e 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue_2.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue_2.yul @@ -13,7 +13,7 @@ mstore(x, 0x42) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue_3.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue_3.yul similarity index 93% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue_3.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue_3.yul index b70f35d2b..d9980d376 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_continue_3.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue_3.yul @@ -12,7 +12,7 @@ } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_decl_inside_break_continue.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_decl_inside_break_continue.yul similarity index 95% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_decl_inside_break_continue.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_decl_inside_break_continue.yul index f54b21af8..94b100e2a 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_decl_inside_break_continue.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_decl_inside_break_continue.yul @@ -19,7 +19,7 @@ mstore(x, 0x42) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x := 1 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_deep_noremove.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_deep_noremove.yul similarity index 97% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_deep_noremove.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_deep_noremove.yul index 5edd71d58..02a735f9e 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_deep_noremove.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_deep_noremove.yul @@ -26,7 +26,7 @@ x := 13 } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x := 1 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_deep_simple.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_deep_simple.yul similarity index 96% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_deep_simple.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_deep_simple.yul index 5b086bab8..039d856d9 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_deep_simple.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_deep_simple.yul @@ -19,7 +19,7 @@ } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // for { } 1 { } diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_multi_break.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_multi_break.yul similarity index 97% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_multi_break.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_multi_break.yul index ce084b1ce..3b18dcc8d 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_multi_break.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_multi_break.yul @@ -35,7 +35,7 @@ mstore(x, 0x42) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x := 1 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_nested.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_nested.yul similarity index 97% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_nested.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_nested.yul index a83f53666..101101b92 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_nested.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_nested.yul @@ -32,7 +32,7 @@ mstore(x, 0x42) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x := 1 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_rerun.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_rerun.yul similarity index 91% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_rerun.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_rerun.yul index 5d1e60738..08cf63a52 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_rerun.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_rerun.yul @@ -11,7 +11,7 @@ x := 3 } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_stmnts_after_break_continue.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_stmnts_after_break_continue.yul similarity index 96% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/for_stmnts_after_break_continue.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/for_stmnts_after_break_continue.yul index 5e88df968..1a92d3b84 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/for_stmnts_after_break_continue.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_stmnts_after_break_continue.yul @@ -23,7 +23,7 @@ mstore(x, 0x42) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x := 1 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/function.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/function.yul similarity index 90% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/function.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/function.yul index 2a20ca8b6..044a5f418 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/function.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/function.yul @@ -12,7 +12,7 @@ r := 2 } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let r diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/if.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/if.yul similarity index 89% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/if.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/if.yul index 2fab04a36..7c65680ae 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/if.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/if.yul @@ -10,7 +10,7 @@ mstore(0, d) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let c diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/if_overwrite_all_branches.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/if_overwrite_all_branches.yul similarity index 90% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/if_overwrite_all_branches.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/if_overwrite_all_branches.yul index 7585f848a..860050e59 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/if_overwrite_all_branches.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/if_overwrite_all_branches.yul @@ -11,7 +11,7 @@ mstore(0, d) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let c diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/if_used_in_one_branch.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/if_used_in_one_branch.yul similarity index 89% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/if_used_in_one_branch.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/if_used_in_one_branch.yul index 637a32c02..90643f174 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/if_used_in_one_branch.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/if_used_in_one_branch.yul @@ -11,7 +11,7 @@ mstore(0, d) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let c diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/leave.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul similarity index 94% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/leave.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul index 1caee198a..82bf49347 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/leave.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/leave.yul @@ -21,7 +21,7 @@ } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // function f(a, b) -> x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/multi_assign.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/multi_assign.yul similarity index 88% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/multi_assign.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/multi_assign.yul index f0845680f..d4b35e7ee 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/multi_assign.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/multi_assign.yul @@ -9,7 +9,7 @@ y := 4 } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // function f() -> a, b diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/multivar.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/multivar.yul similarity index 81% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/multivar.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/multivar.yul index 2b13ba3c3..d4dda8f90 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/multivar.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/multivar.yul @@ -6,7 +6,7 @@ a := b } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let a := 2 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/non_movable.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/non_movable.yul similarity index 73% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/non_movable.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/non_movable.yul index 343c672de..e131b3549 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/non_movable.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/non_movable.yul @@ -4,7 +4,7 @@ a := mload(0) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let a diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/remove_break.yul similarity index 91% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/remove_break.yul index 035f66d38..76a536c2f 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/remove_break.yul @@ -12,7 +12,7 @@ } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let i := 0 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/remove_continue.yul similarity index 91% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/remove_continue.yul index c4f3b3e43..27083a73c 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/remove_continue.yul @@ -13,7 +13,7 @@ } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let i := 0 diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/scopes.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/scopes.yul similarity index 77% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/scopes.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/scopes.yul index d3c6cb4a6..bc2d4d80f 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/scopes.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/scopes.yul @@ -7,7 +7,7 @@ } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let a diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/simple.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/simple.yul similarity index 63% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/simple.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/simple.yul index 12b9ae6b7..326ce29dc 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/simple.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/simple.yul @@ -4,6 +4,6 @@ a := 2 } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { let a } diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_in_all.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_in_all.yul similarity index 89% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_in_all.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_in_all.yul index a39cdedd7..a6b77f897 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_in_all.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_in_all.yul @@ -8,7 +8,7 @@ mstore(x, 0) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_in_one.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_in_one.yul similarity index 88% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_in_one.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_in_one.yul index 271bb4864..9b0a23cd8 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_in_one.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_in_one.yul @@ -7,7 +7,7 @@ mstore(x, 0) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_use_combination.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_use_combination.yul similarity index 90% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_use_combination.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_use_combination.yul index 8d38dcc16..611123db3 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_overwrite_use_combination.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_overwrite_use_combination.yul @@ -8,7 +8,7 @@ mstore(x, 0) } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_unused.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_unused.yul similarity index 85% rename from test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_unused.yul rename to test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_unused.yul index 94de51b88..c15c88991 100644 --- a/test/libyul/yulOptimizerTests/redundantAssignEliminator/switch_unused.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/switch_unused.yul @@ -6,7 +6,7 @@ case 0 { mstore(0, 1) } } // ---- -// step: redundantAssignEliminator +// step: unusedAssignEliminator // // { // let x diff --git a/test/libyul/yulOptimizerTests/unusedPruner/functions.yul b/test/libyul/yulOptimizerTests/unusedPruner/functions.yul index cceace3bb..cafb399f6 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/functions.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/functions.yul @@ -5,4 +5,4 @@ // ---- // step: unusedPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/intermediate_assignment.yul b/test/libyul/yulOptimizerTests/unusedPruner/intermediate_assignment.yul index 32e96b9f3..00bb145ad 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/intermediate_assignment.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/intermediate_assignment.yul @@ -7,6 +7,8 @@ // step: unusedPruner // // { -// let a := 1 -// a := 4 +// { +// let a := 1 +// a := 4 +// } // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/intermediate_multi_assignment.yul b/test/libyul/yulOptimizerTests/unusedPruner/intermediate_multi_assignment.yul index bc05f09f8..4132a93f8 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/intermediate_multi_assignment.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/intermediate_multi_assignment.yul @@ -8,9 +8,11 @@ // step: unusedPruner // // { -// let a, b +// { +// let a, b +// a := f() +// b := 1 +// } // function f() -> x // { } -// a := f() -// b := 1 // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/keccak.yul b/test/libyul/yulOptimizerTests/unusedPruner/keccak.yul index 6ad93184a..357b3a33c 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/keccak.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/keccak.yul @@ -7,6 +7,8 @@ // step: unusedPruner // // { -// pop(keccak256(1, 1)) -// sstore(0, msize()) +// { +// pop(keccak256(1, 1)) +// sstore(0, msize()) +// } // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/movable_user_defined_function.yul b/test/libyul/yulOptimizerTests/unusedPruner/movable_user_defined_function.yul index 09d366fb2..43a4297cb 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/movable_user_defined_function.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/movable_user_defined_function.yul @@ -10,4 +10,4 @@ // ---- // step: unusedPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/msize.yul b/test/libyul/yulOptimizerTests/unusedPruner/msize.yul index 05ad7b743..633b447cd 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/msize.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/msize.yul @@ -7,6 +7,8 @@ // step: unusedPruner // // { -// pop(mload(10)) -// sstore(0, msize()) +// { +// pop(mload(10)) +// sstore(0, msize()) +// } // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/multi_assign.yul b/test/libyul/yulOptimizerTests/unusedPruner/multi_assign.yul index 47e114373..aac772dcb 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/multi_assign.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/multi_assign.yul @@ -8,9 +8,11 @@ // step: unusedPruner // // { -// let a -// let b +// { +// let a +// let b +// a, b := f() +// } // function f() -> x, y // { } -// a, b := f() // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/multi_assignments.yul b/test/libyul/yulOptimizerTests/unusedPruner/multi_assignments.yul index 86f175d69..a987efe80 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/multi_assignments.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/multi_assignments.yul @@ -7,7 +7,9 @@ // step: unusedPruner // // { -// let x, y -// x := 1 -// y := 2 +// { +// let x, y +// x := 1 +// y := 2 +// } // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/multi_declarations.yul b/test/libyul/yulOptimizerTests/unusedPruner/multi_declarations.yul index f727b0e93..3f70d6638 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/multi_declarations.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/multi_declarations.yul @@ -4,4 +4,4 @@ // ---- // step: unusedPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/multi_declare.yul b/test/libyul/yulOptimizerTests/unusedPruner/multi_declare.yul index aa8ae0ad4..d65b4d5d7 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/multi_declare.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/multi_declare.yul @@ -5,4 +5,4 @@ // ---- // step: unusedPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/multi_partial_assignments.yul b/test/libyul/yulOptimizerTests/unusedPruner/multi_partial_assignments.yul index f54087a7d..d66889a88 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/multi_partial_assignments.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/multi_partial_assignments.yul @@ -6,6 +6,8 @@ // step: unusedPruner // // { -// let x, y -// x := 1 +// { +// let x, y +// x := 1 +// } // } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/no_msize.yul b/test/libyul/yulOptimizerTests/unusedPruner/no_msize.yul index 7bfc4d788..0591c0e2a 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/no_msize.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/no_msize.yul @@ -6,4 +6,4 @@ // ---- // step: unusedPruner // -// { sstore(0, 5) } +// { { sstore(0, 5) } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/pop.yul b/test/libyul/yulOptimizerTests/unusedPruner/pop.yul index 66d16db1e..636552eee 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/pop.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/pop.yul @@ -5,4 +5,4 @@ // ---- // step: unusedPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/smoke.yul b/test/libyul/yulOptimizerTests/unusedPruner/smoke.yul index a2ac495a0..3315ce2c4 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/smoke.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/smoke.yul @@ -2,4 +2,4 @@ // ---- // step: unusedPruner // -// { } +// { { } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/trivial.yul b/test/libyul/yulOptimizerTests/unusedPruner/trivial.yul index 9de594351..8a47d2108 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/trivial.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/trivial.yul @@ -6,4 +6,4 @@ // ---- // step: unusedPruner // -// { mstore(0, 1) } +// { { mstore(0, 1) } } diff --git a/test/libyul/yulOptimizerTests/unusedPruner/verbatim.yul b/test/libyul/yulOptimizerTests/unusedPruner/verbatim.yul index 65b464f7f..7fea85c52 100644 --- a/test/libyul/yulOptimizerTests/unusedPruner/verbatim.yul +++ b/test/libyul/yulOptimizerTests/unusedPruner/verbatim.yul @@ -11,7 +11,9 @@ // step: unusedPruner // // { -// pop(mload(10)) -// pop(keccak256(10, 32)) -// verbatim_0i_0o("test") +// { +// pop(mload(10)) +// pop(keccak256(10, 32)) +// verbatim_0i_0o("test") +// } // } diff --git a/test/solc/CommandLineInterface.cpp b/test/solc/CommandLineInterface.cpp index e502a1c0d..bdc5fceec 100644 --- a/test/solc/CommandLineInterface.cpp +++ b/test/solc/CommandLineInterface.cpp @@ -19,6 +19,7 @@ /// Unit tests for solc/CommandLineInterface.h #include +#include #include @@ -114,7 +115,7 @@ BOOST_AUTO_TEST_SUITE(CommandLineInterfaceTest) BOOST_AUTO_TEST_CASE(help) { - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles({"solc", "--help"}, "", /* _processInput */ true); + OptionsReaderAndMessages result = runCLI({"solc", "--help"}, ""); BOOST_TEST(result.success); BOOST_TEST(boost::starts_with(result.stdoutContent, "solc, the Solidity commandline compiler.")); @@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(help) BOOST_AUTO_TEST_CASE(license) { - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles({"solc", "--license"}, "", /* _processInput */ true); + OptionsReaderAndMessages result = runCLI({"solc", "--license"}, ""); BOOST_TEST(result.success); BOOST_TEST(boost::starts_with(result.stdoutContent, "Most of the code is licensed under GPLv3")); @@ -134,7 +135,7 @@ BOOST_AUTO_TEST_CASE(license) BOOST_AUTO_TEST_CASE(version) { - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles({"solc", "--version"}, "", /* _processInput */ true); + OptionsReaderAndMessages result = runCLI({"solc", "--version"}, ""); BOOST_TEST(result.success); BOOST_TEST(boost::ends_with(result.stdoutContent, "Version: " + solidity::frontend::VersionString + "\n")); @@ -158,17 +159,16 @@ BOOST_AUTO_TEST_CASE(multiple_input_modes) string expectedMessage = "The following options are mutually exclusive: " "--help, --license, --version, --standard-json, --link, --assemble, --strict-assembly, --yul, --import-ast. " - "Select at most one.\n"; + "Select at most one."; for (string const& mode1: inputModeOptions) for (string const& mode2: inputModeOptions) if (mode1 != mode2) - { - vector commandLine = {"solc", mode1, mode2}; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); - } + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({"solc", mode1, mode2}), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(cli_input) @@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(cli_ignore_missing_no_files_exist) "\"" + (tempDir.path() / "input2.sol").string() + "\" is not found. Skipping.\n" "All specified input files either do not exist or are not regular files.\n"; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles({ + OptionsReaderAndMessages result = runCLI({ "solc", (tempDir.path() / "input1.sol").string(), (tempDir.path() / "input2.sol").string(), @@ -265,11 +265,13 @@ BOOST_AUTO_TEST_CASE(cli_not_a_file) { TemporaryDirectory tempDir(TEST_CASE_NAME); - string expectedMessage = "\"" + tempDir.path().string() + "\" is not a valid file.\n"; + string expectedMessage = "\"" + tempDir.path().string() + "\" is not a valid file."; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles({"solc", tempDir.path().string()}); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({"solc", tempDir.path().string()}), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(standard_json_base_path) @@ -334,24 +336,26 @@ BOOST_AUTO_TEST_CASE(standard_json_two_input_files) { string expectedMessage = "Too many input files for --standard-json.\n" - "Please either specify a single file name or provide its content on standard input.\n"; + "Please either specify a single file name or provide its content on standard input."; - vector commandLine = {"solc", "--standard-json", "input1.json", "input2.json"}; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({"solc", "--standard-json", "input1.json", "input2.json"}), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(standard_json_one_input_file_and_stdin) { string expectedMessage = "Too many input files for --standard-json.\n" - "Please either specify a single file name or provide its content on standard input.\n"; + "Please either specify a single file name or provide its content on standard input."; - vector commandLine = {"solc", "--standard-json", "input1.json", "-"}; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({"solc", "--standard-json", "input1.json", "-"}), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(standard_json_ignore_missing) @@ -360,29 +364,31 @@ BOOST_AUTO_TEST_CASE(standard_json_ignore_missing) // This option is pretty much useless Standard JSON mode. string expectedMessage = - "\"" + (tempDir.path() / "input.json").string() + "\" is not found. Skipping.\n" - "All specified input files either do not exist or are not regular files.\n"; + "All specified input files either do not exist or are not regular files."; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles({ - "solc", - "--standard-json", - (tempDir.path() / "input.json").string(), - "--ignore-missing", - }); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({ + "solc", + "--standard-json", + (tempDir.path() / "input.json").string(), + "--ignore-missing", + }), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(standard_json_remapping) { string expectedMessage = "Import remappings are not accepted on the command line in Standard JSON mode.\n" - "Please put them under 'settings.remappings' in the JSON input.\n"; + "Please put them under 'settings.remappings' in the JSON input."; - vector commandLine = {"solc", "--standard-json", "a=b"}; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({"solc", "--standard-json", "a=b"}), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(cli_paths_to_source_unit_names_no_base_path) @@ -995,11 +1001,7 @@ BOOST_AUTO_TEST_CASE(cli_include_paths) canonicalWorkDir / "lib", }; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles( - commandLine, - "", - true /* _processInput */ - ); + OptionsReaderAndMessages result = runCLI(commandLine, ""); BOOST_TEST(result.stderrContent == ""); BOOST_TEST(result.stdoutContent == ""); @@ -1085,11 +1087,7 @@ BOOST_AUTO_TEST_CASE(standard_json_include_paths) FileReader::FileSystemPathSet expectedAllowedDirectories = {}; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles( - commandLine, - standardJsonInput, - true /* _processInput */ - ); + OptionsReaderAndMessages result = runCLI(commandLine, standardJsonInput); Json::Value parsedStdout; string jsonParsingErrors; @@ -1117,18 +1115,19 @@ BOOST_AUTO_TEST_CASE(cli_include_paths_empty_path) TemporaryWorkingDirectory tempWorkDir(tempDir); createFilesWithParentDirs({tempDir.path() / "base/main.sol"}); - string expectedMessage = "Empty values are not allowed in --include-path.\n"; + string expectedMessage = "Empty values are not allowed in --include-path."; - vector commandLine = { - "solc", - "--base-path=base/", - "--include-path", "include/", - "--include-path", "", - "base/main.sol", - }; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({ + "solc", + "--base-path=base/", + "--include-path", "include/", + "--include-path", "", + "base/main.sol", + }), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(cli_include_paths_without_base_path) @@ -1137,12 +1136,13 @@ BOOST_AUTO_TEST_CASE(cli_include_paths_without_base_path) TemporaryWorkingDirectory tempWorkDir(tempDir); createFilesWithParentDirs({tempDir.path() / "contract.sol"}); - string expectedMessage = "--include-path option requires a non-empty base path.\n"; + string expectedMessage = "--include-path option requires a non-empty base path."; - vector commandLine = {"solc", "--include-path", "include/", "contract.sol"}; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(!result.success); - BOOST_TEST(result.stderrContent == expectedMessage); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({"solc", "--include-path", "include/", "contract.sol"}), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } BOOST_AUTO_TEST_CASE(cli_include_paths_should_detect_source_unit_name_collisions) @@ -1171,35 +1171,37 @@ BOOST_AUTO_TEST_CASE(cli_include_paths_should_detect_source_unit_name_collisions { // import "contract1.sol" and import "contract2.sol" would be ambiguous: - vector commandLine = { - "solc", - "--base-path=dir1/", - "--include-path=dir2/", - "dir1/contract1.sol", - "dir2/contract1.sol", - "dir1/contract2.sol", - "dir2/contract2.sol", - }; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(result.stderrContent == expectedMessage); - BOOST_REQUIRE(!result.success); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({ + "solc", + "--base-path=dir1/", + "--include-path=dir2/", + "dir1/contract1.sol", + "dir2/contract1.sol", + "dir1/contract2.sol", + "dir2/contract2.sol", + }), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } { // import "contract1.sol" and import "contract2.sol" would be ambiguous: - vector commandLine = { - "solc", - "--base-path=dir3/", - "--include-path=dir1/", - "--include-path=dir2/", - "dir1/contract1.sol", - "dir2/contract1.sol", - "dir1/contract2.sol", - "dir2/contract2.sol", - }; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles(commandLine); - BOOST_TEST(result.stderrContent == expectedMessage); - BOOST_REQUIRE(!result.success); + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles({ + "solc", + "--base-path=dir3/", + "--include-path=dir1/", + "--include-path=dir2/", + "dir1/contract1.sol", + "dir2/contract1.sol", + "dir1/contract2.sol", + "dir2/contract2.sol", + }), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); } { @@ -1314,12 +1316,7 @@ BOOST_AUTO_TEST_CASE(cli_include_paths_ambiguous_import) "3 | import \"contract.sol\";\n" " | ^^^^^^^^^^^^^^^^^^^^^^\n\n"; - OptionsReaderAndMessages result = parseCommandLineAndReadInputFiles( - commandLine, - mainContractSource, - true /* _processInput */ - ); - + OptionsReaderAndMessages result = runCLI(commandLine, mainContractSource); BOOST_TEST(result.stderrContent == expectedMessage); BOOST_REQUIRE(!result.success); } diff --git a/test/solc/CommandLineInterfaceAllowPaths.cpp b/test/solc/CommandLineInterfaceAllowPaths.cpp index 576ab5c5e..512e288b6 100644 --- a/test/solc/CommandLineInterfaceAllowPaths.cpp +++ b/test/solc/CommandLineInterfaceAllowPaths.cpp @@ -95,11 +95,7 @@ ImportCheck checkImport( "pragma solidity >=0.0;\n" + _import + ";"; - test::OptionsReaderAndMessages cliResult = test::parseCommandLineAndReadInputFiles( - commandLine, - standardInputContent, - true /* processInput */ - ); + test::OptionsReaderAndMessages cliResult = test::runCLI(commandLine, standardInputContent); if (cliResult.success) return ImportCheck::OK(); diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index d0f67d103..410e83baf 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -19,6 +19,7 @@ /// Unit tests for solc/CommandLineParser.h #include +#include #include @@ -46,17 +47,13 @@ using namespace solidity::yul; namespace { -optional parseCommandLine(vector const& _commandLine, ostream& _stderr) +CommandLineOptions parseCommandLine(vector const& _commandLine) { vector argv = test::makeArgv(_commandLine); - CommandLineParser cliParser(_stderr); - bool success = cliParser.parse(static_cast(_commandLine.size()), argv.data()); - - if (!success) - return nullopt; - else - return cliParser.options(); + CommandLineParser cliParser; + cliParser.parse(static_cast(_commandLine.size()), argv.data()); + return cliParser.options(); } } // namespace @@ -75,12 +72,9 @@ BOOST_AUTO_TEST_CASE(no_options) expectedOptions.modelChecker.initialize = true; expectedOptions.modelChecker.settings = {}; - stringstream serr; - optional parsedOptions = parseCommandLine(commandLine, serr); + CommandLineOptions parsedOptions = parseCommandLine(commandLine); - BOOST_TEST(serr.str() == ""); - BOOST_REQUIRE(parsedOptions.has_value()); - BOOST_TEST(parsedOptions.value() == expectedOptions); + BOOST_TEST(parsedOptions == expectedOptions); } BOOST_AUTO_TEST_CASE(help_license_version) @@ -93,15 +87,12 @@ BOOST_AUTO_TEST_CASE(help_license_version) for (auto const& [option, expectedMode]: expectedModePerOption) { - stringstream serr; - optional parsedOptions = parseCommandLine({"solc", option}, serr); + CommandLineOptions parsedOptions = parseCommandLine({"solc", option}); CommandLineOptions expectedOptions; expectedOptions.input.mode = expectedMode; - BOOST_TEST(serr.str() == ""); - BOOST_REQUIRE(parsedOptions.has_value()); - BOOST_TEST(parsedOptions.value() == expectedOptions); + BOOST_TEST(parsedOptions == expectedOptions); } } @@ -226,12 +217,9 @@ BOOST_AUTO_TEST_CASE(cli_mode_options) 5, }; - stringstream serr; - optional parsedOptions = parseCommandLine(commandLine, serr); + CommandLineOptions parsedOptions = parseCommandLine(commandLine); - BOOST_TEST(serr.str() == ""); - BOOST_REQUIRE(parsedOptions.has_value()); - BOOST_TEST(parsedOptions.value() == expectedOptions); + BOOST_TEST(parsedOptions == expectedOptions); } } @@ -352,12 +340,9 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) expectedOptions.optimizer.expectedExecutionsPerDeployment = 1000; } - stringstream serr; - optional parsedOptions = parseCommandLine(commandLine, serr); + CommandLineOptions parsedOptions = parseCommandLine(commandLine); - BOOST_TEST(serr.str() == "Warning: Yul is still experimental. Please use the output with care.\n"); - BOOST_REQUIRE(parsedOptions.has_value()); - BOOST_TEST(parsedOptions.value() == expectedOptions); + BOOST_TEST(parsedOptions == expectedOptions); } } @@ -420,12 +405,9 @@ BOOST_AUTO_TEST_CASE(standard_json_mode_options) expectedOptions.compiler.combinedJsonRequests->abi = true; expectedOptions.compiler.combinedJsonRequests->binary = true; - stringstream serr; - optional parsedOptions = parseCommandLine(commandLine, serr); + CommandLineOptions parsedOptions = parseCommandLine(commandLine); - BOOST_TEST(serr.str() == ""); - BOOST_REQUIRE(parsedOptions.has_value()); - BOOST_TEST(parsedOptions.value() == expectedOptions); + BOOST_TEST(parsedOptions == expectedOptions); } BOOST_AUTO_TEST_CASE(invalid_options_input_modes_combinations) @@ -441,10 +423,11 @@ BOOST_AUTO_TEST_CASE(invalid_options_input_modes_combinations) { stringstream serr; vector commandLine = {"solc", optionName, "file", inputMode}; - optional parsedOptions = parseCommandLine(commandLine, serr); - BOOST_TEST(serr.str() == "The following options are not supported in the current input mode: " + optionName + "\n"); - BOOST_REQUIRE(!parsedOptions.has_value()); + string expectedMessage = "The following options are not supported in the current input mode: " + optionName; + auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedMessage; }; + + BOOST_CHECK_EXCEPTION(parseCommandLine(commandLine), CommandLineValidationError, hasCorrectMessage); } } diff --git a/test/solc/Common.cpp b/test/solc/Common.cpp index 8e40c1af6..ead9b798d 100644 --- a/test/solc/Common.cpp +++ b/test/solc/Common.cpp @@ -41,18 +41,34 @@ vector test::makeArgv(vector const& _commandLine) test::OptionsReaderAndMessages test::parseCommandLineAndReadInputFiles( vector const& _commandLine, - string const& _standardInputContent, - bool _processInput + string const& _standardInputContent ) { vector argv = makeArgv(_commandLine); stringstream sin(_standardInputContent), sout, serr; CommandLineInterface cli(sin, sout, serr); bool success = cli.parseArguments(static_cast(_commandLine.size()), argv.data()); - if (success) - success = cli.readInputFiles(); - if (success && _processInput) - success = cli.processInput(); + cli.readInputFiles(); + + return { + success, + cli.options(), + cli.fileReader(), + cli.standardJsonInput(), + sout.str(), + stripPreReleaseWarning(serr.str()), + }; +} + +test::OptionsReaderAndMessages test::runCLI( + vector const& _commandLine, + string const& _standardInputContent +) +{ + vector argv = makeArgv(_commandLine); + stringstream sin(_standardInputContent), sout, serr; + CommandLineInterface cli(sin, sout, serr); + bool success = cli.run(static_cast(_commandLine.size()), argv.data()); return { success, diff --git a/test/solc/Common.h b/test/solc/Common.h index 958d63054..3575bea74 100644 --- a/test/solc/Common.h +++ b/test/solc/Common.h @@ -44,10 +44,26 @@ struct OptionsReaderAndMessages std::vector makeArgv(std::vector const& _commandLine); +/// Runs only command-line parsing, without compilation, assembling or any other input processing. +/// Lets through any @a CommandLineErrors throw by the CLI. +/// Note: This uses the @a CommandLineInterface class and does not actually spawn a new process. +/// @param _commandLine Arguments in the form of strings that would be specified on the command-line. +/// You must specify the program name as the first item. +/// @param _standardInputContent Content that the CLI will be able to read from its standard input. OptionsReaderAndMessages parseCommandLineAndReadInputFiles( std::vector const& _commandLine, - std::string const& _standardInputContent = "", - bool _processInput = false + std::string const& _standardInputContent = "" +); + +/// Runs all stages of command-line interface processing, including error handling. +/// Never throws @a CommandLineError - validation errors are included in the returned stderr content. +/// Note: This uses the @a CommandLineInterface class and does not actually spawn a new process. +/// @param _commandLine Arguments in the form of strings that would be specified on the command-line. +/// You must specify the program name as the first item. +/// @param _standardInputContent Content that the CLI will be able to read from its standard input. +OptionsReaderAndMessages runCLI( + std::vector const& _commandLine, + std::string const& _standardInputContent = "" ); std::string stripPreReleaseWarning(std::string const& _stderrContent); diff --git a/test/yulPhaser/Chromosome.cpp b/test/yulPhaser/Chromosome.cpp index 55bfd8f24..19616cde0 100644 --- a/test/yulPhaser/Chromosome.cpp +++ b/test/yulPhaser/Chromosome.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ namespace solidity::phaser::test vector const ChrOmOsoMeSteps{ ConditionalSimplifier::name, FunctionHoister::name, - RedundantAssignEliminator::name, + UnusedAssignEliminator::name, ForLoopConditionOutOfBody::name, Rematerialiser::name, ForLoopConditionOutOfBody::name, @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(output_operator_should_create_concise_and_unambiguous_strin BOOST_TEST(chromosome.length() == allSteps.size()); BOOST_TEST(chromosome.optimisationSteps() == allSteps); - BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighFTLMRrmVatpud"); + BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighFTLMRmVatrpud"); } BOOST_AUTO_TEST_CASE(optimisationSteps_should_translate_chromosomes_genes_to_optimisation_step_names) diff --git a/test/yulPhaser/Program.cpp b/test/yulPhaser/Program.cpp index 8aa2479a2..2e91926d0 100644 --- a/test/yulPhaser/Program.cpp +++ b/test/yulPhaser/Program.cpp @@ -337,7 +337,10 @@ BOOST_AUTO_TEST_CASE(optimise) Block const& parentBlockAfter = program.ast(); BOOST_TEST(parentBlockAfter.statements.size() == 1); - BOOST_TEST(holds_alternative(parentBlockAfter.statements[0])); + BOOST_TEST(holds_alternative(parentBlockAfter.statements[0])); + Block const& innerBlock = get(parentBlockAfter.statements[0]); + BOOST_TEST(innerBlock.statements.size() == 1); + BOOST_TEST(holds_alternative(innerBlock.statements[0])); } BOOST_AUTO_TEST_CASE(output_operator)