r312785 - Don't show deleted function (constructor) candidates for code completion

Erik Verbruggen via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 03:23:08 PDT 2017


Author: erikjv
Date: Fri Sep  8 03:23:08 2017
New Revision: 312785

URL: http://llvm.org/viewvc/llvm-project?rev=312785&view=rev
Log:
Don't show deleted function (constructor) candidates for code completion

In case of copy constructor is implicitly deleted it's still shown.
PR34402 describes a way to reproduce that.

Patch by Ivan Donchevskii!

Differential Revision: https://reviews.llvm.org/D37435

Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/complete-constructor-params.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=312785&r1=312784&r2=312785&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Sep  8 03:23:08 2017
@@ -4286,9 +4286,12 @@ static void mergeCandidatesWithResults(S
         });
 
     // Add the remaining viable overload candidates as code-completion results.
-    for (auto &Candidate : CandidateSet)
+    for (auto &Candidate : CandidateSet) {
+      if (Candidate.Function && Candidate.Function->isDeleted())
+        continue;
       if (Candidate.Viable)
         Results.push_back(ResultCandidate(Candidate.Function));
+    }
   }
 }
 

Modified: cfe/trunk/test/Index/complete-constructor-params.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-constructor-params.cpp?rev=312785&r1=312784&r2=312785&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-constructor-params.cpp (original)
+++ cfe/trunk/test/Index/complete-constructor-params.cpp Fri Sep  8 03:23:08 2017
@@ -18,6 +18,20 @@ int main() {
   int(42);
 }
 
+struct Foo {
+    Foo() = default;
+    Foo(const Foo&) = delete;
+};
+
+struct Bar {
+    Foo f;
+};
+
+void function() {
+    Bar b1;
+    Bar b2(b1);
+}
+
 // RUN: c-index-test -code-completion-at=%s:11:10 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S<int> &}{RightParen )} (1)
 // CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter int}{Comma , }{Placeholder U}{Comma , }{Placeholder U}{RightParen )} (1)
@@ -138,3 +152,6 @@ int main() {
 // CHECK-CC10-NEXT: Class name
 // CHECK-CC10-NEXT: Nested name specifier
 // CHECK-CC10-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:32:12 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC11 %s
+// CHECK-CC11-NOT: OverloadCandidate:{Text Bar}{LeftParen (}{CurrentParameter const Bar &}{RightParen )} (1)




More information about the cfe-commits mailing list