forked from OSchip/llvm-project
[clang][CodeComplete] Dont perform fallback completion for incomplete member ref
Summary: Clang performs expression based completion whenever it can't figure out base of a member reference expression. It might be quite confusing in cases like incomplete types. This patch disables that fallback. Unfortunately `ParsePostfixExpressionSuffix` is quite tangled and this patch adds more to it. Reviewers: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77570
This commit is contained in:
parent
97aa593a83
commit
0731132888
|
@ -2018,12 +2018,19 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
|
||||||
return ParsePostfixExpressionSuffix(Base);
|
return ParsePostfixExpressionSuffix(Base);
|
||||||
}
|
}
|
||||||
|
|
||||||
LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), Base,
|
LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), Base, OpLoc,
|
||||||
OpLoc, OpKind, ObjectType,
|
OpKind, ObjectType,
|
||||||
MayBePseudoDestructor);
|
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;
|
break;
|
||||||
|
}
|
||||||
ParseOptionalCXXScopeSpecifier(
|
ParseOptionalCXXScopeSpecifier(
|
||||||
SS, ObjectType, LHS.get() && LHS.get()->containsErrors(),
|
SS, ObjectType, LHS.get() && LHS.get()->containsErrors(),
|
||||||
/*EnteringContext=*/false, &MayBePseudoDestructor);
|
/*EnteringContext=*/false, &MayBePseudoDestructor);
|
||||||
|
|
|
@ -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:
|
Loading…
Reference in New Issue