[PATCH] D42241: [CodeComplete] Fix completion in the middle of idents in macro calls
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 09:20:03 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323133: [CodeComplete] Fix completion in the middle of idents in macro calls (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D42241
Files:
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/test/CodeCompletion/inside-macros.cpp
Index: cfe/trunk/test/CodeCompletion/inside-macros.cpp
===================================================================
--- cfe/trunk/test/CodeCompletion/inside-macros.cpp
+++ cfe/trunk/test/CodeCompletion/inside-macros.cpp
@@ -0,0 +1,13 @@
+#define ID(X) X
+
+void test(bool input_var) {
+ ID(input_var) = true;
+ // Check that input_var shows up when completing at the start, in the middle
+ // and at the end of the identifier.
+ //
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | FileCheck %s
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | FileCheck %s
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | FileCheck %s
+
+ // CHECK: input_var
+}
Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -773,8 +773,13 @@
}
} 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42241.130914.patch
Type: text/x-patch
Size: 1427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180122/ab9689eb/attachment.bin>
More information about the llvm-commits
mailing list