[PATCH] D77570: [clang][CodeComplete] Dont perform fallback completion for incomplete member ref
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 6 11:26:52 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0731132888a0: [clang][CodeComplete] Dont perform fallback completion for incomplete member ref (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77570/new/
https://reviews.llvm.org/D77570
Files:
clang/lib/Parse/ParseExpr.cpp
clang/test/CodeCompletion/incomplete-member.cpp
Index: clang/test/CodeCompletion/incomplete-member.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeCompletion/incomplete-member.cpp
@@ -0,0 +1,8 @@
+struct IncompleteType;
+
+void foo() {
+ IncompleteType *f;
+ f->x;
+}
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:6 %s -o - | FileCheck %s -allow-empty
+// CHECK-NOT: COMPLETION:
Index: clang/lib/Parse/ParseExpr.cpp
===================================================================
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2018,12 +2018,19 @@
return ParsePostfixExpressionSuffix(Base);
}
- LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), Base,
- OpLoc, OpKind, ObjectType,
+ LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), Base, OpLoc,
+ OpKind, ObjectType,
MayBePseudoDestructor);
- if (LHS.isInvalid())
+ if (LHS.isInvalid()) {
+ // Clang will try to perform expression based completion as a
+ // fallback, which is confusing in case of member references. So we
+ // stop here without any completions.
+ if (Tok.is(tok::code_completion)) {
+ cutOffParsing();
+ return ExprError();
+ }
break;
-
+ }
ParseOptionalCXXScopeSpecifier(
SS, ObjectType, LHS.get() && LHS.get()->containsErrors(),
/*EnteringContext=*/false, &MayBePseudoDestructor);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77570.255421.patch
Type: text/x-patch
Size: 1645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/1b902f32/attachment-0001.bin>
More information about the cfe-commits
mailing list