diff options
| -rw-r--r-- | clang-tools-extra/clangd/ClangdUnit.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp index 70e36b5000e..9f02187ad12 100644 --- a/clang-tools-extra/clangd/ClangdUnit.cpp +++ b/clang-tools-extra/clangd/ClangdUnit.cpp @@ -400,8 +400,12 @@ SourceLocation ClangdUnit::getBeginningOfIdentifier(const Position &Pos, Pos.character); const SourceManager &SourceMgr = Unit->getSourceManager(); Token Result; - Lexer::getRawToken(PeekBeforeLocation, Result, SourceMgr, - Unit->getASTContext().getLangOpts(), false); + if (Lexer::getRawToken(PeekBeforeLocation, Result, SourceMgr, + Unit->getASTContext().getLangOpts(), false)) { + // getRawToken failed, just use InputLocation. + return InputLocation; + } + if (Result.is(tok::raw_identifier)) { return Lexer::GetBeginningOfToken(PeekBeforeLocation, SourceMgr, Unit->getASTContext().getLangOpts()); |

