Author: ibiryukov Date: Mon May 14 06:50:36 2018 New Revision: 332244 URL: http://llvm.org/viewvc/llvm-project?rev=332244&view=rev Log: [CodeComplete] Provide completion in decls even for incomplete types
Summary: This change fixes lack of completions in the following case ('^'designates completion points) : void f(^); struct Incomplete; Incomplete g(^); Reviewers: bkramer, aaron.ballman, sammccall Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46639 Added: cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=332244&r1=332243&r2=332244&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original) +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon May 14 06:50:36 2018 @@ -4493,10 +4493,8 @@ void Sema::CodeCompleteConstructor(Scope 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; Added: cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp?rev=332244&view=auto ============================================================================== --- cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp (added) +++ cfe/trunk/test/CodeCompletion/incomplete-ret-type.cpp Mon May 14 06:50:36 2018 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits