[PATCH] D39730: Enabling constructor code completion

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 7 05:33:52 PST 2017

jkorous-apple created this revision.
Herald added a subscriber: eraman.

It seems like constructor code completion was intentionally disabled ages ago in this commit (and refactored later):

commit 33224e61bfca370850abae89bbd415a4dabe07fa
Author: Douglas Gregor <dgregor at apple.com>
Date:   Fri Sep 18 17:42:29 2009 +0000

  For code completion in C++ member access expressions and tag names,
  look into the current scope for anything that could start a
  nested-names-specifier. These results are ranked worse than any of the
  results actually found in the lexical scope.
  Perform a little more pruning of the result set, eliminating
  constructors, __va_list_tag, and any duplication of declarations in
  the result set. For the latter, implemented

I am not sure if there is actually anything relying on the fact that constructors are not included in code completion results. The only test that seems affected is probably not really concerned about these.




Index: test/Index/complete-cxx-inline-methods.cpp
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -26,6 +26,8 @@
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
 // CHECK:      CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
+// CHECK-NEXT: CXXConstructor:{TypedText Vec}{LeftParen (}{RightParen )} (34)
+// CHECK-NEXT: CXXConstructor:{TypedText Vec}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
Index: lib/Sema/SemaCodeComplete.cpp
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -975,10 +975,6 @@
   bool AsNestedNameSpecifier = false;
   if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
-  // C++ constructors are never found by name lookup.
-  if (isa<CXXConstructorDecl>(R.Declaration))
-    return;
   if (Hiding && CheckHiddenResult(R, CurContext, Hiding))

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39730.121878.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171107/49d818fe/attachment.bin>

More information about the cfe-commits mailing list