Control flow side effects on non-disambiguated source.

This commit is contained in:
chriseth
2021-11-04 16:32:11 +01:00
parent 25c41546ee
commit 776ae466bc
9 changed files with 128 additions and 87 deletions
+9 -12
View File
@@ -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