From dff774d82fcc045fbc4ae847f14e98162367ffcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 15 May 2023 14:19:40 +0200 Subject: [PATCH] Overload MSizeFinder::containsMSize() for Yul objects --- libyul/optimiser/Semantics.cpp | 13 +++++++++++++ libyul/optimiser/Semantics.h | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libyul/optimiser/Semantics.cpp b/libyul/optimiser/Semantics.cpp index 12349394a..d87c20574 100644 --- a/libyul/optimiser/Semantics.cpp +++ b/libyul/optimiser/Semantics.cpp @@ -94,6 +94,19 @@ bool MSizeFinder::containsMSize(Dialect const& _dialect, Block const& _ast) return finder.m_msizeFound; } +bool MSizeFinder::containsMSize(Dialect const& _dialect, Object const& _object) +{ + if (containsMSize(_dialect, *_object.code)) + return true; + + for (shared_ptr const& node: _object.subObjects) + if (auto const* object = dynamic_cast(node.get())) + if (containsMSize(_dialect, *object)) + return true; + + return false; +} + void MSizeFinder::operator()(FunctionCall const& _functionCall) { ASTWalker::operator()(_functionCall); diff --git a/libyul/optimiser/Semantics.h b/libyul/optimiser/Semantics.h index 32b9c9b58..762c80110 100644 --- a/libyul/optimiser/Semantics.h +++ b/libyul/optimiser/Semantics.h @@ -21,10 +21,11 @@ #pragma once -#include -#include -#include #include +#include +#include +#include +#include #include @@ -143,6 +144,7 @@ class MSizeFinder: public ASTWalker { public: static bool containsMSize(Dialect const& _dialect, Block const& _ast); + static bool containsMSize(Dialect const& _dialect, Object const& _object); using ASTWalker::operator(); void operator()(FunctionCall const& _funCall) override;