From 0f2ba3522fb01713a417d7b66c6c586359d6d130 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 9 Nov 2018 00:21:37 +0100 Subject: [PATCH] Reset yul string repository. --- libsolidity/interface/CompilerStack.cpp | 3 +++ libyul/YulString.h | 12 ++++++++++-- test/libyul/YulOptimizerTest.cpp | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 1f58245f7..e0909eb31 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -47,6 +47,8 @@ #include +#include + #include #include @@ -104,6 +106,7 @@ void CompilerStack::reset(bool _keepSources) m_stackState = Empty; m_sources.clear(); } + yul::YulStringRepository::instance().reset(); m_libraries.clear(); m_evmVersion = EVMVersion(); m_optimize = false; diff --git a/libyul/YulString.h b/libyul/YulString.h index ae01c83f5..a80152394 100644 --- a/libyul/YulString.h +++ b/libyul/YulString.h @@ -35,9 +35,9 @@ namespace yul class YulStringRepository: boost::noncopyable { public: - YulStringRepository(): m_strings{std::make_shared()} + YulStringRepository() { - m_ids[std::string{}] = 0; + reset(); } static YulStringRepository& instance() { @@ -61,6 +61,14 @@ public: return *m_strings.at(_id); } + void reset() + { + m_strings.clear(); + m_ids.clear(); + m_strings.emplace_back(std::make_shared()); + m_ids[std::string{}] = 0; + } + private: std::vector> m_strings; std::map m_ids; diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index d455c8921..383900358 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -90,6 +90,8 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted) { + yul::YulStringRepository::instance().reset(); + assembly::AsmPrinter printer{m_yul}; shared_ptr ast; shared_ptr analysisInfo;