Adapted tests due to more precise Yul source locations.

Also added support for -1 source index, referencing original scanner's source location.
This commit is contained in:
Christian Parpart
2021-07-09 11:50:48 +02:00
parent 132fa46faa
commit 5e4868d5d6
2 changed files with 26 additions and 2 deletions
+4 -2
View File
@@ -131,11 +131,13 @@ void Parser::fetchSourceLocationFromComment()
m_locationOverride = SourceLocation{};
if (!sourceIndex || !start || !end)
m_errorReporter.syntaxError(6367_error, commentLocation, "Invalid value in source location mapping. Could not parse location specification.");
else if (!((start < 0 && end < 0) || (start >= 0 && *start <= *end)))
else if (!((*start < 0 && *end < 0) || (*start >= 0 && *start <= *end)))
m_errorReporter.syntaxError(5798_error, commentLocation, "Invalid value in source location mapping. Start offset larger than end offset.");
else if (sourceIndex == -1 && (0 <= *start && *start <= *end)) // Use source index -1 to indicate original source.
m_locationOverride = SourceLocation{*start, *end, ParserBase::currentLocation().source};
else if (!(sourceIndex >= 0 && m_charStreamMap->count(static_cast<unsigned>(*sourceIndex))))
m_errorReporter.syntaxError(2674_error, commentLocation, "Invalid source mapping. Source index not defined via @use-src.");
else if (sourceIndex >= 0)
else
{
shared_ptr<CharStream> charStream = m_charStreamMap->at(static_cast<unsigned>(*sourceIndex));
solAssert(charStream, "");