diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-01-22 17:18:28 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-01-22 17:18:28 +0000 |
commit | b8f231a42cbe8deb4113811a0b8bada39be54ecc (patch) | |
tree | 60c155aab095c475b21a66b739c352bc932e9c4f /clang/lib/Lex/Preprocessor.cpp | |
parent | 29aced1baed029fa3f68c103ca203546033d0b6f (diff) | |
download | bcm5719-llvm-b8f231a42cbe8deb4113811a0b8bada39be54ecc.tar.gz bcm5719-llvm-b8f231a42cbe8deb4113811a0b8bada39be54ecc.zip |
[CodeComplete] Fix completion in the middle of idents in macro calls
Summary:
This patch removes IdentifierInfo from completion token after remembering
the identifier in the preprocessor.
Prior to this patch, completion token had the IdentifierInfo set to null when
completing at the start of identifier and to the II for completion prefix
when in the middle of identifier.
This patch unifies how code completion token is handled when it is insterted
before the identifier and in the middle of the identifier.
The actual IdentifierInfo can still be obtained from the Preprocessor.
Reviewers: bkramer, arphaman
Reviewed By: bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D42241
llvm-svn: 323133
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 7d789e78011..08469bc0253 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -773,8 +773,13 @@ void Preprocessor::Lex(Token &Result) { } } while (!ReturnedToken); - if (Result.is(tok::code_completion)) + if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) { + // Remember the identifier before code completion token. setCodeCompletionIdentifierInfo(Result.getIdentifierInfo()); + // Set IdenfitierInfo to null to avoid confusing code that handles both + // identifiers and completion tokens. + Result.setIdentifierInfo(nullptr); + } LastTokenWasAt = Result.is(tok::at); } |