[PATCH] D64918: [ASTUnit] Fix a regression in cached completions

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 06:33:11 PDT 2019


ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64918

Files:
  clang/lib/Frontend/ASTUnit.cpp
  clang/test/Index/complete-qualified-with-preamble.cpp


Index: clang/test/Index/complete-qualified-with-preamble.cpp
===================================================================
--- /dev/null
+++ clang/test/Index/complete-qualified-with-preamble.cpp
@@ -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
+// -- With preambles.
+// RUN: CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:1 %s \
+// RUN: | FileCheck --check-prefix=START-OF-LINE %s
+// -- Without preambles.
+// 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
+// -- With preambles.
+// 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 preambles.
+// RUN: c-index-test -code-completion-at=%s:3:8 %s \
+// RUN: | FileCheck --implicit-check-not=a_namespace --check-prefix=AFTER-QUALIFIER %s
Index: clang/lib/Frontend/ASTUnit.cpp
===================================================================
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -435,7 +435,6 @@
           | (1LL << CodeCompletionContext::CCC_UnionTag)
           | (1LL << CodeCompletionContext::CCC_ClassOrStructTag)
           | (1LL << CodeCompletionContext::CCC_Type)
-          | (1LL << CodeCompletionContext::CCC_Symbol)
           | (1LL << CodeCompletionContext::CCC_SymbolOrNewName)
           | (1LL << CodeCompletionContext::CCC_ParenthesizedExpression);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64918.210548.patch
Type: text/x-patch
Size: 1721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190718/853796e0/attachment-0001.bin>


More information about the cfe-commits mailing list