Skip to content

Commit

Permalink
Changes to yul proto mutator.
Browse files Browse the repository at this point in the history
  • Loading branch information
bshastry committed Apr 14, 2021
1 parent cf08c9b commit 7c80621
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 9 additions & 1 deletion test/tools/ossfuzz/protoToYul.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ class ProtoConverter
void visit(RetRevStmt const&);
void visit(SelfDestructStmt const&);
void visit(TerminatingStmt const&);
void visit(FunctionCall const&, std::string const&, bool _expression = false);
/// @param _f is the function call to be visited.
/// @param _name is the name of the function called.
/// @param _expression is a flag that is true if the function is called
/// as a single-value expression, false otherwise.
void visit(
FunctionCall const& _f,
std::string const& _name,
bool _expression = false
);
void visit(FunctionDef const&);
void visit(PopStmt const&);
void visit(LeaveStmt const&);
Expand Down
12 changes: 3 additions & 9 deletions test/tools/ossfuzz/protomutators/YulProtoMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ template <typename T>
T YPM::EnumTypeConverter<T>::validEnum(unsigned _seed)
{
auto ret = static_cast<T>(_seed % (enumMax() - enumMin() + 1) + enumMin());
if constexpr (std::is_same_v<std::decay_t<T>, FunctionCall_Returns>)
yulAssert(FunctionCall_Returns_IsValid(ret), "Yul proto mutator: Invalid enum");
else if constexpr (std::is_same_v<std::decay_t<T>, StoreFunc_Storage>)
if constexpr (std::is_same_v<std::decay_t<T>, StoreFunc_Storage>)
yulAssert(StoreFunc_Storage_IsValid(ret), "Yul proto mutator: Invalid enum");
else if constexpr (std::is_same_v<std::decay_t<T>, NullaryOp_NOp>)
yulAssert(NullaryOp_NOp_IsValid(ret), "Yul proto mutator: Invalid enum");
Expand All @@ -131,9 +129,7 @@ T YPM::EnumTypeConverter<T>::validEnum(unsigned _seed)
template <typename T>
unsigned YPM::EnumTypeConverter<T>::enumMax()
{
if constexpr (std::is_same_v<std::decay_t<T>, FunctionCall_Returns>)
return FunctionCall_Returns_Returns_MAX;
else if constexpr (std::is_same_v<std::decay_t<T>, StoreFunc_Storage>)
if constexpr (std::is_same_v<std::decay_t<T>, StoreFunc_Storage>)
return StoreFunc_Storage_Storage_MAX;
else if constexpr (std::is_same_v<std::decay_t<T>, NullaryOp_NOp>)
return NullaryOp_NOp_NOp_MAX;
Expand All @@ -154,9 +150,7 @@ unsigned YPM::EnumTypeConverter<T>::enumMax()
template <typename T>
unsigned YPM::EnumTypeConverter<T>::enumMin()
{
if constexpr (std::is_same_v<std::decay_t<T>, FunctionCall_Returns>)
return FunctionCall_Returns_Returns_MIN;
else if constexpr (std::is_same_v<std::decay_t<T>, StoreFunc_Storage>)
if constexpr (std::is_same_v<std::decay_t<T>, StoreFunc_Storage>)
return StoreFunc_Storage_Storage_MIN;
else if constexpr (std::is_same_v<std::decay_t<T>, NullaryOp_NOp>)
return NullaryOp_NOp_NOp_MIN;
Expand Down

0 comments on commit 7c80621

Please sign in to comment.