[clang] [clang-tools-extra] [clangd] Fix crash with null check for Token at Loc (PR #94528)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 08:32:47 PDT 2024
================
@@ -1354,6 +1354,8 @@ maybeFindIncludeReferences(ParsedAST &AST, Position Pos,
ReferencesResult::Reference Result;
const auto *Token = AST.getTokens().spelledTokenAt(Loc);
+ if (!Token)
----------------
usx95 wrote:
Done.
> also, what's the conclusion of investigation around don't really rely on spelledTokenAt failing when it's called with a random offset into the token?
I relied on the tests here. Also, the usages of `spelledTokenCotaining` does not seem to relying on getting a `nullptr` if the location is inside a token, as compared to strictly at the beginning of tok.
https://github.com/llvm/llvm-project/pull/94528
More information about the cfe-commits
mailing list