From ec22f9ea9a1a64cf7329746b7a5def6dd4a55c45 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 23 May 2019 16:39:26 +0000 Subject: [PATCH] [CodeComplete] Only show lambda completions if patterns are requested 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 | 2 ++ test/CodeCompletion/lambdas.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index e6093141ab..e6c0b68b8d 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -4134,6 +4134,8 @@ static const FunctionProtoType *TryDeconstructFunctionLike(QualType T) { static void AddLambdaCompletion(ResultBuilder &Results, llvm::ArrayRef Parameters, const LangOptions &LangOpts) { + if (!Results.includeCodePatterns()) + return; CodeCompletionBuilder Completion(Results.getAllocator(), Results.getCodeCompletionTUInfo()); // []() {} diff --git a/test/CodeCompletion/lambdas.cpp b/test/CodeCompletion/lambdas.cpp index 3467cec0e3..1ab804ad81 100644 --- a/test/CodeCompletion/lambdas.cpp +++ b/test/CodeCompletion/lambdas.cpp @@ -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 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 : [<#= +} -- 2.40.0