]> granicus.if.org Git - clang/commitdiff
[CodeComplete] Only show lambda completions if patterns are requested
authorIlya Biryukov <ibiryukov@google.com>
Thu, 23 May 2019 16:39:26 +0000 (16:39 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Thu, 23 May 2019 16:39:26 +0000 (16:39 +0000)
This is a trivial follow-up to r361461, so sending without review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361510 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaCodeComplete.cpp
test/CodeCompletion/lambdas.cpp

index e6093141ab76c7f080fbb99dd8dd9f2bf2ad6ad3..e6c0b68b8d5fd0215b317697e3cd01b1075356f7 100644 (file)
@@ -4134,6 +4134,8 @@ static const FunctionProtoType *TryDeconstructFunctionLike(QualType T) {
 static void AddLambdaCompletion(ResultBuilder &Results,
                                 llvm::ArrayRef<QualType> Parameters,
                                 const LangOptions &LangOpts) {
+  if (!Results.includeCodePatterns())
+    return;
   CodeCompletionBuilder Completion(Results.getAllocator(),
                                    Results.getCodeCompletionTUInfo());
   // [](<parameters>) {}
index 3467cec0e3bdce56ea64d81753885a796129c3e7..1ab804ad818e6e4394b24edcf3f668bcdbd6760d 100644 (file)
@@ -51,3 +51,12 @@ void test4() {
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:50:35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
   // CHECK-6-NOT: COMPLETION: Pattern : [<#=
 }
+
+void test5() {
+  // Completions are only added when -code-completion-patterns are enabled.
+  function<void()> b = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:57:24 %s -o - | FileCheck -check-prefix=CHECK-7 %s
+  // CHECK-7: COMPLETION: Pattern : [<#=
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:57:24 %s -o - | FileCheck -check-prefix=CHECK-8 %s
+  // CHECK-8-NOT: COMPLETION: Pattern : [<#=
+}