Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Pass evmVersion and eofVersion to YulStack in ObjectCompilerTest #15503

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/libyul/ControlFlowSideEffectsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ TestCase::TestResult ControlFlowSideEffectsTest::run(std::ostream& _stream, std:
if (!obj.hasCode())
BOOST_THROW_EXCEPTION(std::runtime_error("Parsing input failed."));

// TODO: Add EOF support
ControlFlowSideEffectsCollector sideEffects(
EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion(), std::nullopt),
EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion()),
Comment on lines +66 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion()),
EVMDialect::strictAssemblyForEVMObjects(
CommonOptions::get().evmVersion(),
CommonOptions::get().eofVersion()
),

You don't need the solidity::test bit in most places already and you can just add using namespace solidity::test in those places that don't have it yet.

obj.code()->root()
);
m_obtainedResult.clear();
Expand Down
5 changes: 2 additions & 3 deletions test/libyul/EVMCodeTransformTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,13 @@ TestCase::TestResult EVMCodeTransformTest::run(std::ostream& _stream, std::strin
return TestResult::FatalError;
}

// TODO: Add EOF support
evmasm::Assembly assembly{solidity::test::CommonOptions::get().evmVersion(), false, std::nullopt, {}};
EthAssemblyAdapter adapter(assembly);
EVMObjectCompiler::compile(
*stack.parserResult(),
adapter,
// TODO: Make sure that why we cannot pass here solidity::test::CommonOptions::get().evmVersion() and assembly.eofVersion()
EVMDialect::strictAssemblyForEVMObjects(EVMVersion{}, std::nullopt),
EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion()),
m_stackOpt,
std::nullopt
);
Expand Down
4 changes: 2 additions & 2 deletions test/libyul/FunctionSideEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ TestCase::TestResult FunctionSideEffects::run(std::ostream& _stream, std::string
if (!obj.hasCode())
BOOST_THROW_EXCEPTION(std::runtime_error("Parsing input failed."));

// TODO: Add EOF support
std::map<YulName, SideEffects> functionSideEffects = SideEffectsPropagator::sideEffects(
EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion(), std::nullopt),
EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion()),
CallGraphGenerator::callGraph(obj.code()->root())
);

Expand Down
4 changes: 2 additions & 2 deletions test/libyul/KnowledgeBaseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class KnowledgeBaseTest
return KnowledgeBase([this](YulName _var) { return util::valueOrNullptr(m_values, _var); });
}

// TODO: Add EOF support
EVMDialect m_dialect{EVMVersion{}, std::nullopt, true};
EVMDialect m_dialect{solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion(), true};
std::shared_ptr<Object> m_object;
SSAValueTracker m_ssaValues;
std::map<YulName, AssignedValue> m_values;
Expand Down
6 changes: 3 additions & 3 deletions test/libyul/ObjectCompilerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using namespace solidity::frontend;
using namespace solidity::frontend::test;

ObjectCompilerTest::ObjectCompilerTest(std::string const& _filename):
TestCase(_filename)
solidity::frontend::test::EVMVersionRestrictedTestCase(_filename)
{
m_source = m_reader.source();
m_optimisationPreset = m_reader.enumSetting<OptimisationPreset>(
Expand All @@ -65,8 +65,8 @@ ObjectCompilerTest::ObjectCompilerTest(std::string const& _filename):
TestCase::TestResult ObjectCompilerTest::run(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted)
{
YulStack stack(
EVMVersion(),
std::nullopt,
solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion(),
YulStack::Language::StrictAssembly,
OptimiserSettings::preset(m_optimisationPreset),
DebugInfoSelection::All()
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/ObjectCompilerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Block;
namespace solidity::yul::test
{

class ObjectCompilerTest: public solidity::frontend::test::TestCase
class ObjectCompilerTest: public solidity::frontend::test::EVMVersionRestrictedTestCase
{
public:
static std::unique_ptr<TestCase> create(Config const& _config)
Expand Down
4 changes: 2 additions & 2 deletions test/libyul/ObjectParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ std::tuple<std::optional<SourceNameMap>, ErrorList> tryGetSourceLocationMapping(

ErrorList errors;
ErrorReporter reporter(errors);
// TODO: Add EOF support
Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(EVMVersion{}, std::nullopt);
Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion());
ObjectParser objectParser{reporter, dialect};
CharStream stream(std::move(source), "");
auto object = objectParser.parse(std::make_shared<Scanner>(stream), false);
Expand Down
172 changes: 86 additions & 86 deletions test/libyul/Parser.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/libyul/YulInterpreterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ std::string YulInterpreterTest::interpret()
{
Interpreter::run(
state,
EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion(), std::nullopt),
EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().eofVersion()),
m_ast->root(),
/*disableExternalCalls=*/ !m_simulateExternalCallsToSelf,
/*disableMemoryTracing=*/ false
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/datacopy.yul
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ object "a" {
data "data1" "Hello, World!"
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":77:92 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/dataoffset_code.yul
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ object "a" {
data "data1" "Hello, World!"
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":44:61 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/dataoffset_data.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ object "a" {
code { sstore(0, dataoffset("data1")) }
data "data1" "Hello, World!"
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":56:75 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/dataoffset_self.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ object "a" {
code { sstore(0, dataoffset("a")) }
data "data1" "Hello, World!"
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":44:59 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/datasize_code.yul
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ object "a" {
data "data1" "Hello, World!"
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":44:59 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/datasize_data.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ object "a" {
code { sstore(0, datasize("data1")) }
data "data1" "Hello, World!"
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":44:61 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/datasize_self.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ object "a" {
code { sstore(0, datasize("a")) }
data "data1" "Hello, World!"
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":36:49 */
Expand Down
1 change: 1 addition & 0 deletions test/libyul/objectCompiler/function_series.yul
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ object "Contract" {
}

// ====
// EVMVersion: >=shanghai
// optimizationPreset: none
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ object "A" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object "A" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ object "A" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ object "A" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ object "A" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ object "a" {
)
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":143:185 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/leading_and_trailing_dots.yul
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
}
g(2)
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":53:54 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/linkersymbol.yul
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ object "a" {
let success := call(gas(), addr, 0, 128, 4, 128, 0)
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":190:191 */
Expand Down
1 change: 1 addition & 0 deletions test/libyul/objectCompiler/long_object_name.yul
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ object "t" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/manySubObjects.yul
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ object "root" {
}
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":59:75 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/metadata.yul
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ object "A" {
data ".metadata" "M2"
data "x" "Hello, World2!"
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":55:68 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/namedObjectCode.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
object "a" {
code { sstore(0, 1) }
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":36:37 */
Expand Down
1 change: 1 addition & 0 deletions test/libyul/objectCompiler/nested_optimizer.yul
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ object "a" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/simple.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
sstore(0, 1)
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":41:42 */
Expand Down
1 change: 1 addition & 0 deletions test/libyul/objectCompiler/simple_optimizer.yul
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
sstore(add(x, 0), z)
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/sourceLocations.yul
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ object "a" {
data "data1" "Hello, World!"
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "abc.sol":0:2 */
Expand Down
2 changes: 2 additions & 0 deletions test/libyul/objectCompiler/subObjectAccess.yul
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ object "A" {
}
}
}
// ====
// EVMVersion: >=shanghai
// ----
// Assembly:
// /* "source":57:72 */
Expand Down
1 change: 1 addition & 0 deletions test/libyul/objectCompiler/verbatim_bug.yul
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object "a" {
}
}
// ====
// EVMVersion: >=shanghai
// optimizationPreset: full
// ----
// Assembly:
Expand Down