This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix a selection tree crash for unmatched-bracket code.
ClosedPublic

Authored by hokein on Jan 26 2022, 11:47 PM.

Diff Detail

Event Timeline

hokein created this revision.Jan 26 2022, 11:47 PM
hokein requested review of this revision.Jan 26 2022, 11:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2022, 11:47 PM
sammccall accepted this revision.Jan 27 2022, 12:01 AM

Wow, nice find!

I'd argue the bug is probably rather in TokenBuffer::expandedTokens(SourceRange) that produced this span. The idea that it might *rarely* include the EOF token seems like a magnet for bugs like these.

(Of course it's a special case of a more general "recovery location points at an unrelated token" problem)...

Even if we want to fix it in TokenBuffer, doing it right before the release cut might be risky. So:

  • fix it here
  • or fix it in TokenBuffer
  • or fix it here and then change after the branch cut

I'm happy with any of these options, up to you.

This revision is now accepted and ready to land.Jan 27 2022, 12:01 AM