-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeComplete] Don't drop ArrayToPointerDecay when doing member completion #134951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
completion Fixes llvm#123146. rdar://138851576
761fd77
to
0fb44d3
Compare
@llvm/pr-subscribers-clang Author: Akira Hatanaka (ahatanak) ChangesFixes #123146. rdar://138851576 Full diff: https://github.com/llvm/llvm-project/pull/134951.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 44a49a6e3148e..bd1fd4dae68a3 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -5740,7 +5740,10 @@ class ConceptInfo {
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>()) {
diff --git a/clang/test/CodeCompletion/member-access.c b/clang/test/CodeCompletion/member-access.c
index fc54993152815..f08d1957fb90a 100644
--- a/clang/test/CodeCompletion/member-access.c
+++ b/clang/test/CodeCompletion/member-access.c
@@ -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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/16064 Here is the relevant piece of the build log for the reference
|
…etion (llvm#134951) Fixes llvm#123146. rdar://138851576
Fixes #123146.
rdar://138851576