This is an archive of the discontinued LLVM Phabricator instance.

[MC] Fix ICE with non-newline terminated input
ClosedPublic

Authored by scott.linder on Dec 4 2020, 12:54 PM.

Details

Summary

There is an explicit option for the lexer to support this, but we crash
when -preserve-comments is enabled because it checks for
getTok().getString().empty() to detect the case. This doesn't
work currently because the lexer reports this case as a string of length
1, containing a null byte.

Change the lexer to instead report this case via an empty string, as the
null terminator isn't logically a part of the textual input, and the
check for .empty() seems natural and obvious in the calling code.

Diff Detail

Event Timeline

scott.linder created this revision.Dec 4 2020, 12:54 PM
scott.linder requested review of this revision.Dec 4 2020, 12:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2020, 12:54 PM

Alternatively I'm open to fix this in the caller if the (EndOfStatement, "\0") value is correct here. I just didn't see what use the caller would have for a string containing an embedded null here.

niravd accepted this revision.Dec 9 2020, 12:14 PM

LGTM.

This revision is now accepted and ready to land.Dec 9 2020, 12:14 PM
This revision was automatically updated to reflect the committed changes.