[PATCH] D46639: [CodeComplete] Provide completion in decls even for incomplete types

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 14 06:54:38 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL332244: [CodeComplete] Provide completion in decls even for incomplete types (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46639

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp


Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -4493,10 +4493,8 @@
     return;
 
   // A complete type is needed to lookup for constructors.
-  if (!isCompleteType(Loc, Type))
-    return;
-
-  CXXRecordDecl *RD = Type->getAsCXXRecordDecl();
+  CXXRecordDecl *RD =
+      isCompleteType(Loc, Type) ? Type->getAsCXXRecordDecl() : nullptr;
   if (!RD) {
     CodeCompleteExpression(S, Type);
     return;
Index: cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp
===================================================================
--- cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp
+++ cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp
@@ -0,0 +1,13 @@
+struct IncompleteType;
+int int_value;
+typedef int int_typedef;
+
+void f(in);
+IncompleteType g(in);
+// Completing should produce results even if types are incomplete.
+// Note that clang is expected to return an error code since 'in' does not resolve.
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:9 %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:6:19 %s -o - | FileCheck %s
+// CHECK: COMPLETION: int{{$}}
+// CHECK: COMPLETION: int_typedef
+// CHECK: COMPLETION: int_value


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46639.146595.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180514/550edf4c/attachment.bin>


More information about the cfe-commits mailing list