[PATCH] D143486: [clangd] Fix a crash in semantic highlighting.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 05:55:17 PST 2023
hokein updated this revision to Diff 495496.
hokein marked an inline comment as done.
hokein added a comment.
add a comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143486/new/
https://reviews.llvm.org/D143486
Files:
clang-tools-extra/clangd/SemanticHighlighting.cpp
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -519,10 +519,11 @@
Loc = getHighlightableSpellingToken(Loc, SourceMgr);
if (Loc.isInvalid())
return std::nullopt;
-
+ // We might have offsets in the main file that don't correspond to any
+ // spelled tokens.
const auto *Tok = TB.spelledTokenAt(Loc);
- assert(Tok);
-
+ if (!Tok)
+ return std::nullopt;
return halfOpenToRange(SourceMgr,
Tok->range(SourceMgr).toCharRange(SourceMgr));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143486.495496.patch
Type: text/x-patch
Size: 698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230207/1bc11d7f/attachment.bin>
More information about the cfe-commits
mailing list