mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Control flow side effects on non-disambiguated source.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <test/libyul/Common.h>
|
||||
|
||||
#include <libyul/Object.h>
|
||||
#include <libyul/AST.h>
|
||||
#include <libyul/ControlFlowSideEffects.h>
|
||||
#include <libyul/ControlFlowSideEffectsCollector.h>
|
||||
#include <libyul/backends/evm/EVMDialect.h>
|
||||
@@ -61,19 +62,15 @@ TestCase::TestResult ControlFlowSideEffectsTest::run(ostream& _stream, string co
|
||||
if (!obj.code)
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Parsing input failed."));
|
||||
|
||||
std::map<YulString, ControlFlowSideEffects> sideEffects =
|
||||
ControlFlowSideEffectsCollector(
|
||||
EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion()),
|
||||
*obj.code
|
||||
).functionSideEffects();
|
||||
|
||||
std::map<std::string, std::string> controlFlowSideEffectsStr;
|
||||
for (auto&& [fun, effects]: sideEffects)
|
||||
controlFlowSideEffectsStr[fun.str()] = toString(effects);
|
||||
|
||||
ControlFlowSideEffectsCollector sideEffects(
|
||||
EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion()),
|
||||
*obj.code
|
||||
);
|
||||
m_obtainedResult.clear();
|
||||
for (auto&& [functionName, effect]: controlFlowSideEffectsStr)
|
||||
m_obtainedResult += functionName + (effect.empty() ? ":" : ": " + effect) + "\n";
|
||||
forEach<FunctionDefinition const>(*obj.code, [&](FunctionDefinition const& _fun) {
|
||||
string effectStr = toString(sideEffects.functionSideEffects().at(&_fun));
|
||||
m_obtainedResult += _fun.name.str() + (effectStr.empty() ? ":" : ": " + effectStr) + "\n";
|
||||
});
|
||||
|
||||
return checkResult(_stream, _linePrefix, _formatted);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
function a() {
|
||||
{
|
||||
function b() { if calldataloda(0) { return(0, 0) } }
|
||||
b()
|
||||
}
|
||||
{
|
||||
function b() { revert(0, 0) }
|
||||
b()
|
||||
}
|
||||
}
|
||||
function b() {
|
||||
leave
|
||||
revert(0, 0)
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// a: can revert
|
||||
// b: can continue
|
||||
Reference in New Issue
Block a user