Prevent crash when translating yul->ewasm with @use-src annotations

This commit is contained in:
Marenz
2021-11-11 13:43:57 +01:00
parent 969707c5d2
commit 49b4e77d6b
6 changed files with 46 additions and 1 deletions
@@ -137,7 +137,11 @@ void EVMToEwasmTranslator::parsePolyfill()
string(solidity::yul::wasm::polyfill::Logical) +
string(solidity::yul::wasm::polyfill::Memory) +
"}", "");
m_polyfill = Parser(errorReporter, WasmDialect::instance()).parse(charStream);
// Passing an empty SourceLocation() here is a workaround to prevent a crash
// when compiling from yul->ewasm. We're stripping nativeLocation and
// originLocation from the AST (but we only really need to strip nativeLocation)
m_polyfill = Parser(errorReporter, WasmDialect::instance(), langutil::SourceLocation()).parse(charStream);
if (!errors.empty())
{
string message;