r366448 - [ASTUnit] Fix a regression in cached completions
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 08:21:34 PDT 2019
Author: ibiryukov
Date: Thu Jul 18 08:21:34 2019
New Revision: 366448
URL: http://llvm.org/viewvc/llvm-project?rev=366448&view=rev
Log:
[ASTUnit] Fix a regression in cached completions
Summary:
After r345152 cached completions started adding namespaces after
nested name specifiers, e.g. in `some_name::^`
The CCC_Symbol indicates the completed item cannot be a namespace (it is
described as being "a type, a function or a variable" in the comments).
Therefore, 'nested specifier' completions should only be added from cache
when the context is CCC_SymbolOrNewName (which roughly seems to indicate
that a nested name specifier is allowed).
Fixes https://bugs.llvm.org/show_bug.cgi?id=42646
Reviewers: kadircet, sammccall
Reviewed By: kadircet, sammccall
Subscribers: arphaman, nik, sammccall, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64918
Added:
cfe/trunk/test/Index/complete-qualified-cached.cpp
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=366448&r1=366447&r2=366448&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jul 18 08:21:34 2019
@@ -435,7 +435,6 @@ void ASTUnit::CacheCodeCompletionResults
| (1LL << CodeCompletionContext::CCC_UnionTag)
| (1LL << CodeCompletionContext::CCC_ClassOrStructTag)
| (1LL << CodeCompletionContext::CCC_Type)
- | (1LL << CodeCompletionContext::CCC_Symbol)
| (1LL << CodeCompletionContext::CCC_SymbolOrNewName)
| (1LL << CodeCompletionContext::CCC_ParenthesizedExpression);
Added: cfe/trunk/test/Index/complete-qualified-cached.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-qualified-cached.cpp?rev=366448&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-qualified-cached.cpp (added)
+++ cfe/trunk/test/Index/complete-qualified-cached.cpp Thu Jul 18 08:21:34 2019
@@ -0,0 +1,22 @@
+namespace a_namespace {};
+class Class { static void foo(); };
+Class::
+// Completion for a_namespace should be available at the start of the line.
+// START-OF-LINE: a_namespace
+// START-OF-LINE: Class
+// -- Using cached completions.
+// RUN: CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:1 %s \
+// RUN: | FileCheck --check-prefix=START-OF-LINE %s
+// -- Without cached completions.
+// RUN: c-index-test -code-completion-at=%s:3:1 %s \
+// RUN: | FileCheck --check-prefix=START-OF-LINE %s
+//
+//
+// ... and should not be available after 'Class::^'
+// AFTER-QUALIFIER: Class
+// -- Using cached completions.
+// RUN: CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:8 %s \
+// RUN: | FileCheck --implicit-check-not=a_namespace --check-prefix=AFTER-QUALIFIER %s
+// -- Without cached completions.
+// RUN: c-index-test -code-completion-at=%s:3:8 %s \
+// RUN: | FileCheck --implicit-check-not=a_namespace --check-prefix=AFTER-QUALIFIER %s
More information about the cfe-commits
mailing list