Do not set source locations for small internal assembly routines.

This commit is contained in:
chriseth
2020-05-27 18:26:46 +02:00
parent a06ac0f39f
commit eb923af09c
10 changed files with 46 additions and 65 deletions
+15 -2
View File
@@ -46,8 +46,15 @@ public:
None, ForLoopPre, ForLoopPost, ForLoopBody
};
explicit Parser(langutil::ErrorReporter& _errorReporter, Dialect const& _dialect):
ParserBase(_errorReporter), m_dialect(_dialect) {}
explicit Parser(
langutil::ErrorReporter& _errorReporter,
Dialect const& _dialect,
std::optional<langutil::SourceLocation> _locationOverride = {}
):
ParserBase(_errorReporter),
m_dialect(_dialect),
m_locationOverride(std::move(_locationOverride))
{}
/// Parses an inline assembly block starting with `{` and ending with `}`.
/// @param _reuseScanner if true, do check for end of input after the `}`.
@@ -60,6 +67,11 @@ public:
protected:
using ElementaryOperation = std::variant<Literal, Identifier, FunctionCall>;
langutil::SourceLocation currentLocation() const override
{
return m_locationOverride ? *m_locationOverride : ParserBase::currentLocation();
}
/// Creates an inline assembly node with the current source location.
template <class T> T createWithLocation() const
{
@@ -91,6 +103,7 @@ protected:
private:
Dialect const& m_dialect;
std::optional<langutil::SourceLocation> m_locationOverride;
ForLoopComponent m_currentForLoopComponent = ForLoopComponent::None;
bool m_insideFunction = false;
};