summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-07-18 15:21:34 +0000
committerIlya Biryukov <ibiryukov@google.com>2019-07-18 15:21:34 +0000
commit5de0c85e88bea9a8cf312c93d9276f13d68af476 (patch)
tree0efaa54c3eeda90d6bb2af845fbf65bcf0118dae
parenta5359b1b0754ff70b0a36917a5e61625c951b408 (diff)
downloadbcm5719-llvm-5de0c85e88bea9a8cf312c93d9276f13d68af476.tar.gz
bcm5719-llvm-5de0c85e88bea9a8cf312c93d9276f13d68af476.zip
[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 llvm-svn: 366448
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp1
-rw-r--r--clang/test/Index/complete-qualified-cached.cpp22
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 7445a94cfe5..783d1f9d091 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -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);
diff --git a/clang/test/Index/complete-qualified-cached.cpp b/clang/test/Index/complete-qualified-cached.cpp
new file mode 100644
index 00000000000..124aba82843
--- /dev/null
+++ b/clang/test/Index/complete-qualified-cached.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
+// -- 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
OpenPOWER on IntegriCloud