AsmParser: Replace m_debugDataOverride with separate variables for location and AST ID

This commit is contained in:
Kamil Śliwak 2021-09-21 14:52:51 +02:00
parent 84ca67c283
commit 9c1d40debf
2 changed files with 6 additions and 6 deletions

View File

@ -80,7 +80,7 @@ std::shared_ptr<DebugData const> Parser::createDebugData() const
case UseSourceLocationFrom::LocationOverride:
return DebugData::create(m_locationOverride);
case UseSourceLocationFrom::Comments:
return m_debugDataOverride;
return DebugData::create(m_locationFromComment, m_astIDFromComment);
}
solAssert(false, "");
}
@ -135,7 +135,7 @@ void Parser::fetchDebugDataFromComment()
string_view commentLiteral = m_scanner->currentCommentLiteral();
match_results<string_view::const_iterator> match;
langutil::SourceLocation sourceLocation = m_debugDataOverride->location;
langutil::SourceLocation sourceLocation = m_locationFromComment;
// Empty for each new node.
optional<int> astID;
@ -163,7 +163,8 @@ void Parser::fetchDebugDataFromComment()
continue;
}
m_debugDataOverride = DebugData::create(sourceLocation, astID);
m_locationFromComment = sourceLocation;
m_astIDFromComment = astID;
}
optional<pair<string_view, SourceLocation>> Parser::parseSrcComment(

View File

@ -61,7 +61,6 @@ public:
ParserBase(_errorReporter),
m_dialect(_dialect),
m_locationOverride{_locationOverride ? *_locationOverride : langutil::SourceLocation{}},
m_debugDataOverride{},
m_useSourceLocationFrom{
_locationOverride ?
UseSourceLocationFrom::LocationOverride :
@ -79,7 +78,6 @@ public:
ParserBase(_errorReporter),
m_dialect(_dialect),
m_sourceNames{std::move(_sourceNames)},
m_debugDataOverride{DebugData::create()},
m_useSourceLocationFrom{
m_sourceNames.has_value() ?
UseSourceLocationFrom::Comments :
@ -154,7 +152,8 @@ private:
std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> m_sourceNames;
langutil::SourceLocation m_locationOverride;
std::shared_ptr<DebugData const> m_debugDataOverride;
langutil::SourceLocation m_locationFromComment;
std::optional<int64_t> m_astIDFromComment;
UseSourceLocationFrom m_useSourceLocationFrom = UseSourceLocationFrom::Scanner;
ForLoopComponent m_currentForLoopComponent = ForLoopComponent::None;
bool m_insideFunction = false;