[CodeComplete] Don't drop ArrayToPointerDecay when doing member completion (#134951)
Fixes https://github.com/llvm/llvm-project/issues/123146. rdar://138851576
This commit is contained in:
@@ -5726,7 +5726,10 @@ private:
|
||||
QualType getApproximateType(const Expr *E, HeuristicResolver &Resolver) {
|
||||
if (E->getType().isNull())
|
||||
return QualType();
|
||||
E = E->IgnoreParenImpCasts();
|
||||
// Don't drop implicit cast if it's an array decay.
|
||||
if (auto *ICE = dyn_cast<ImplicitCastExpr>(E);
|
||||
!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
|
||||
E = E->IgnoreParenImpCasts();
|
||||
QualType Unresolved = E->getType();
|
||||
// Resolve DependentNameType
|
||||
if (const auto *DNT = Unresolved->getAs<DependentNameType>()) {
|
||||
|
||||
@@ -36,3 +36,12 @@ void test4(struct Point *p) {
|
||||
}
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-3):13 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-3):23 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
|
||||
|
||||
float test5(void) {
|
||||
struct Point array[4];
|
||||
return array->x;
|
||||
}
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):17 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
|
||||
// CHECK-CC4: COMPLETION: x : [#float#]x
|
||||
// CHECK-CC4: COMPLETION: y : [#float#]y
|
||||
// CHECK-CC4: COMPLETION: z : [#float#]z
|
||||
|
||||
Reference in New Issue
Block a user