mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-26 13:26:22 +00:00
[clangd] Fix a crash in semantic highlighting.
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. Differential Revision: https://reviews.llvm.org/D143486
This commit is contained in:
parent
4da283872a
commit
41a6085252
@ -519,10 +519,11 @@ private:
|
||||
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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user