diff --git a/liblangutil/CharStream.h b/liblangutil/CharStream.h index 08f86129b..59ddf22d9 100644 --- a/liblangutil/CharStream.h +++ b/liblangutil/CharStream.h @@ -73,9 +73,15 @@ public: CharStream() = default; CharStream(std::string _source, std::string _name): m_source(std::move(_source)), m_name(std::move(_name)) {} + CharStream(std::string _source, std::string _name, bool _importedFromAST): + m_source(std::move(_source)), + m_name(std::move(_name)), + m_importedFromAST(_importedFromAST) + { } size_t position() const { return m_position; } bool isPastEndOfInput(size_t _charsForward = 0) const { return (m_position + _charsForward) >= m_source.size(); } + bool isImportedFromAST() const { return m_importedFromAST; } char get(size_t _charsForward = 0) const { return m_source[m_position + _charsForward]; } char advanceAndGet(size_t _chars = 1); @@ -138,6 +144,7 @@ public: private: std::string m_source; std::string m_name; + bool m_importedFromAST{false}; size_t m_position{0}; }; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 2a8845bde..c53bf9321 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -404,7 +404,8 @@ void CompilerStack::importASTs(map const& _sources) source.ast = src.second; source.charStream = make_shared( util::jsonCompactPrint(m_sourceJsons[src.first]), - src.first + src.first, + true // imported from AST ); m_sources[path] = move(source); } diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 46000bc10..fb0fa565e 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -278,7 +278,11 @@ string AsmPrinter::formatSourceLocation( { sourceIndex = to_string(_nameToSourceIndex.at(*_location.sourceName)); - if (_debugInfoSelection.snippet && _soliditySourceProvider) + if ( + _debugInfoSelection.snippet && + _soliditySourceProvider && + !_soliditySourceProvider->charStream(*_location.sourceName).isImportedFromAST() + ) { solidityCodeSnippet = escapeAndQuoteString( _soliditySourceProvider->charStream(*_location.sourceName).singleLineSnippet(_location)