1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:18:14 +00:00

LibCpp: Return empty TranslationUnit from Parser::parse() if no tokens exist

Fixes #5704.
Fixes #5825.
Fixes #5827.
This commit is contained in:
Linus Groh 2021-03-16 18:45:51 +01:00 committed by Andreas Kling
parent 8e84ca6b16
commit 6c8185151e

View file

@ -75,6 +75,8 @@ void Parser::initialize_program_tokens(const StringView& program)
NonnullRefPtr<TranslationUnit> Parser::parse()
{
SCOPE_LOGGER();
if (m_tokens.is_empty())
return create_root_ast_node({}, {});
auto unit = create_root_ast_node(m_tokens.first().start(), m_tokens.last().end());
while (!done()) {
if (match_comment()) {