[clang-tools-extra] r306705 - [clangd] Check failure of Lexer::getRawToken in GoToDeclaration.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 29 10:11:32 PDT 2017
Author: ibiryukov
Date: Thu Jun 29 10:11:32 2017
New Revision: 306705
URL: http://llvm.org/viewvc/llvm-project?rev=306705&view=rev
Log:
[clangd] Check failure of Lexer::getRawToken in GoToDeclaration.
There was an access to unitialized memory because it wasn't checked.
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=306705&r1=306704&r2=306705&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Jun 29 10:11:32 2017
@@ -400,8 +400,12 @@ SourceLocation ClangdUnit::getBeginningO
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());
More information about the cfe-commits
mailing list