Pass DebugInfoSelection down to the code handling assembly printing

This commit is contained in:
Kamil Śliwak
2021-10-11 20:34:48 +02:00
parent f7c4ed849d
commit bcfefc79d9
28 changed files with 170 additions and 47 deletions
+19 -3
View File
@@ -28,6 +28,7 @@
#include <libyul/AssemblyStack.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -59,7 +60,12 @@ std::optional<Error> parseAndReturnFirstError(
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
)
{
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none());
AssemblyStack stack(
solidity::test::CommonOptions::get().evmVersion(),
_language,
solidity::frontend::OptimiserSettings::none(),
DebugInfoSelection::None()
);
bool success = false;
try
{
@@ -125,7 +131,12 @@ Error expectError(
void parsePrintCompare(string const& _source, bool _canWarn = false)
{
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
AssemblyStack stack(
solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::Assembly,
OptimiserSettings::none(),
DebugInfoSelection::None()
);
BOOST_REQUIRE(stack.parseAndAnalyze("", _source));
if (_canWarn)
BOOST_REQUIRE(!Error::containsErrors(stack.errors()));
@@ -210,7 +221,12 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode)
{
string source = "{ let x := \"\\u1bac\" }";
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n";
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
AssemblyStack stack(
solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::Assembly,
OptimiserSettings::none(),
DebugInfoSelection::None()
);
BOOST_REQUIRE(stack.parseAndAnalyze("", source));
BOOST_REQUIRE(stack.errors().empty());
BOOST_CHECK_EQUAL(stack.print(), parsed);
@@ -23,6 +23,7 @@
#include <test/libsolidity/SolidityExecutionFramework.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -34,6 +35,7 @@
using namespace solidity;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace solidity::langutil;
using namespace solidity::test;
using namespace std;
@@ -94,8 +96,12 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
else if (forceEnableOptimizer)
optimiserSettings = OptimiserSettings::full();
yul::AssemblyStack
asmStack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, optimiserSettings);
yul::AssemblyStack asmStack(
m_evmVersion,
yul::AssemblyStack::Language::StrictAssembly,
optimiserSettings,
DebugInfoSelection::All()
);
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
+3 -1
View File
@@ -31,6 +31,7 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <libyul/backends/wasm/WasmDialect.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -59,7 +60,8 @@ pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(strin
_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly,
solidity::test::CommonOptions::get().optimize ?
solidity::frontend::OptimiserSettings::standard() :
solidity::frontend::OptimiserSettings::minimal()
solidity::frontend::OptimiserSettings::minimal(),
DebugInfoSelection::All()
);
if (!stack.parseAndAnalyze("", _source) || !stack.errors().empty())
BOOST_FAIL("Invalid source.");
+6 -1
View File
@@ -47,7 +47,12 @@ TestCase::TestResult EVMCodeTransformTest::run(ostream& _stream, string const& _
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
settings.runYulOptimiser = false;
settings.optimizeStackAllocation = m_stackOpt;
AssemblyStack stack(EVMVersion{}, AssemblyStack::Language::StrictAssembly, settings);
AssemblyStack stack(
EVMVersion{},
AssemblyStack::Language::StrictAssembly,
settings,
DebugInfoSelection::All()
);
if (!stack.parseAndAnalyze("", m_source))
{
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
+3 -1
View File
@@ -30,6 +30,7 @@
#include <libyul/AST.h>
#include <libyul/Object.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -82,7 +83,8 @@ bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bo
m_stack = AssemblyStack(
solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none()
solidity::frontend::OptimiserSettings::none(),
DebugInfoSelection::All()
);
if (m_stack.parseAndAnalyze("", m_source))
{
+3 -1
View File
@@ -26,6 +26,7 @@
#include <libevmasm/Instruction.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <boost/algorithm/string.hpp>
@@ -64,7 +65,8 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
AssemblyStack stack(
EVMVersion(),
m_wasm ? AssemblyStack::Language::Ewasm : AssemblyStack::Language::StrictAssembly,
OptimiserSettings::preset(m_optimisationPreset)
OptimiserSettings::preset(m_optimisationPreset),
DebugInfoSelection::All()
);
if (!stack.parseAndAnalyze("source", m_source))
{
+5 -2
View File
@@ -23,6 +23,7 @@
#include <test/libsolidity/ErrorCheck.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/Scanner.h>
#include <libyul/AssemblyStack.h>
@@ -60,7 +61,8 @@ pair<bool, ErrorList> parse(string const& _source)
AssemblyStack asmStack(
solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none()
solidity::frontend::OptimiserSettings::none(),
DebugInfoSelection::All()
);
bool success = asmStack.parseAndAnalyze("source", _source);
return {success, asmStack.errors()};
@@ -181,7 +183,8 @@ BOOST_AUTO_TEST_CASE(to_string)
AssemblyStack asmStack(
solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none()
solidity::frontend::OptimiserSettings::none(),
DebugInfoSelection::All()
);
BOOST_REQUIRE(asmStack.parseAndAnalyze("source", code));
BOOST_CHECK_EQUAL(asmStack.print(), expectation);
+3 -1
View File
@@ -26,6 +26,7 @@
#include <libyul/AssemblyStack.h>
#include <libyul/AsmAnalysisInfo.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -67,7 +68,8 @@ bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool
AssemblyStack stack(
solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none()
solidity::frontend::OptimiserSettings::none(),
DebugInfoSelection::All()
);
if (stack.parseAndAnalyze("", m_source))
{
+4 -1
View File
@@ -23,6 +23,8 @@
#include <libsolidity/interface/OptimiserSettings.h>
#include <liblangutil/DebugInfoSelection.h>
namespace solidity::test::fuzzer
{
class YulAssembler
@@ -36,7 +38,8 @@ public:
m_stack(
_version,
solidity::yul::AssemblyStack::Language::StrictAssembly,
_optSettings
_optSettings,
langutil::DebugInfoSelection::All()
),
m_yulProgram(_yulSource),
m_optimiseYul(_optSettings.runYulOptimiser)
@@ -19,6 +19,7 @@
#include <libyul/AssemblyStack.h>
#include <libyul/backends/evm/EVMCodeTransform.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/EVMVersion.h>
using namespace solidity;
@@ -39,7 +40,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full(),
langutil::DebugInfoSelection::All()
);
if (!stack.parseAndAnalyze("source", input))
@@ -22,6 +22,7 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <libyul/AssemblyStack.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/EVMVersion.h>
@@ -61,7 +62,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full(),
DebugInfoSelection::All()
);
try
{
+5 -1
View File
@@ -17,9 +17,12 @@
// SPDX-License-Identifier: GPL-3.0
#include <libyul/AssemblyStack.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/EVMVersion.h>
using namespace solidity;
using namespace solidity::langutil;
using namespace solidity::util;
using namespace solidity::yul;
using namespace std;
@@ -38,7 +41,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full(),
DebugInfoSelection::All()
);
if (!stack.parseAndAnalyze("source", input))
+3 -1
View File
@@ -30,6 +30,7 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/EVMVersion.h>
#include <src/libfuzzer/libfuzzer_macro.h>
@@ -64,7 +65,8 @@ DEFINE_PROTO_FUZZER(Program const& _input)
AssemblyStack stack(
version,
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full(),
DebugInfoSelection::All()
);
// Parse protobuf mutated YUL code
+3 -1
View File
@@ -30,6 +30,7 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <libyul/Exceptions.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -63,7 +64,8 @@ DEFINE_PROTO_FUZZER(Program const& _input)
AssemblyStack stack(
version,
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full(),
DebugInfoSelection::All()
);
// Parse protobuf mutated YUL code
+3 -1
View File
@@ -27,6 +27,7 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <libyul/AssemblyStack.h>
#include <liblangutil/DebugInfoSelection.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatter.h>
@@ -58,7 +59,8 @@ pair<shared_ptr<Block>, shared_ptr<AsmAnalysisInfo>> parse(string const& _source
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none()
solidity::frontend::OptimiserSettings::none(),
DebugInfoSelection::Default()
);
if (stack.parseAndAnalyze("--INPUT--", _source))
{