Merge pull request #8121 from ethereum/sourceReferenceExtractorWithoutSource

Handle empty source strings in SourceReferenceExtractor
This commit is contained in:
chriseth
2020-01-09 14:53:03 +01:00
committed by GitHub
2 changed files with 5 additions and 1 deletions
+3
View File
@@ -46,6 +46,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio
if (!_location || !_location->source.get()) // Nothing we can extract here
return SourceReference::MessageOnly(std::move(message));
if (_location->source->source().empty()) // No source text, so we can only extract the source name
return SourceReference::MessageOnly(std::move(message), _location->source->name());
shared_ptr<CharStream> const& source = _location->source;
LineColumn const interest = source->translatePositionToLineColumn(_location->start);
+2 -1
View File
@@ -49,10 +49,11 @@ struct SourceReference
int endColumn = {-1}; ///< Highlighting range-end of text field.
/// Constructs a SourceReference containing a message only.
static SourceReference MessageOnly(std::string _msg)
static SourceReference MessageOnly(std::string _msg, std::string _sourceName = {})
{
SourceReference sref;
sref.message = std::move(_msg);
sref.sourceName = std::move(_sourceName);
return sref;
}
};