[PATCH] D143486: [clangd] Fix a crash in semantic highlighting.

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 7 05:52:06 PST 2023


kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:524
     const auto *Tok = TB.spelledTokenAt(Loc);
-    assert(Tok);
-
+    if (!Tok)
+      return std::nullopt;
----------------
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143486/new/

https://reviews.llvm.org/D143486



More information about the cfe-commits mailing list