mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12789 from ethereum/yulFuzzerCustomMutation
Permit control flow mutations in global scope of a Yul program.
This commit is contained in:
commit
e19c366532
@ -73,6 +73,7 @@ static addControlFlow<SwitchStmt> c4;
|
|||||||
static addControlFlow<FunctionDef> c5;
|
static addControlFlow<FunctionDef> c5;
|
||||||
static addControlFlow<CaseStmt> c6;
|
static addControlFlow<CaseStmt> c6;
|
||||||
static addControlFlow<Code> c7;
|
static addControlFlow<Code> c7;
|
||||||
|
static addControlFlow<Program> c8;
|
||||||
|
|
||||||
Literal* YPM::intLiteral(unsigned _value)
|
Literal* YPM::intLiteral(unsigned _value)
|
||||||
{
|
{
|
||||||
@ -261,6 +262,24 @@ Block* YPM::basicBlock(T* _msg)
|
|||||||
return _msg->mutable_case_block();
|
return _msg->mutable_case_block();
|
||||||
else if constexpr (std::is_same_v<T, Code>)
|
else if constexpr (std::is_same_v<T, Code>)
|
||||||
return _msg->mutable_block();
|
return _msg->mutable_block();
|
||||||
|
else if constexpr (std::is_same_v<T, Program>)
|
||||||
|
return globalBlock(_msg);
|
||||||
else
|
else
|
||||||
static_assert(AlwaysFalse<T>::value, "Yul proto mutator: non-exhaustive visitor.");
|
static_assert(AlwaysFalse<T>::value, "Yul proto mutator: non-exhaustive visitor.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Block* YPM::globalBlock(Program* _program)
|
||||||
|
{
|
||||||
|
switch (_program->program_oneof_case())
|
||||||
|
{
|
||||||
|
case Program::kBlock:
|
||||||
|
return _program->mutable_block();
|
||||||
|
case Program::kObj:
|
||||||
|
return _program->mutable_obj()->mutable_code()->mutable_block();
|
||||||
|
case Program::PROGRAM_ONEOF_NOT_SET:
|
||||||
|
{
|
||||||
|
_program->set_allocated_block(new Block());
|
||||||
|
return _program->mutable_block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -103,5 +103,7 @@ struct YulProtoMutator
|
|||||||
/// Obtain a basic block in a for stmt uniformly
|
/// Obtain a basic block in a for stmt uniformly
|
||||||
/// at random
|
/// at random
|
||||||
static Block* randomBlock(ForStmt* _msg);
|
static Block* randomBlock(ForStmt* _msg);
|
||||||
|
/// Obtain a basic block in global scope.
|
||||||
|
static Block* globalBlock(Program* _program);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user