This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix a crash in semantic highlighting.
ClosedPublic

Authored by hokein on Feb 7 2023, 3:44 AM.

Details

Summary

We encounter a few internal reports that we're dereference a nullptr.
Unfortunately, no small reproduce testcase for this crash yet, but it makes the
clangd more robost on broken code.

Diff Detail

Event Timeline

hokein created this revision.Feb 7 2023, 3:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 3:44 AM
Herald added a subscriber: arphaman. · View Herald Transcript
hokein requested review of this revision.Feb 7 2023, 3:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 3:44 AM
kadircet accepted this revision.Feb 7 2023, 5:52 AM
kadircet added inline comments.
clang-tools-extra/clangd/SemanticHighlighting.cpp
525–526

can you add a comment here "We might have offsets in the main file that don't correspond to any spelled tokens." i think we should fix that in token buffer spelled token mappings going forward. we're relying on other places around spelledTokenAt returning a valid Token whenever we pass it a main file source location.

This revision is now accepted and ready to land.Feb 7 2023, 5:52 AM
hokein updated this revision to Diff 495496.Feb 7 2023, 5:55 AM
hokein marked an inline comment as done.

add a comment.

This revision was landed with ongoing or failed builds.Feb 7 2023, 5:55 AM
This revision was automatically updated to reflect the committed changes.