[PATCH] D95935: [clang][CodeComplete] Fix crash on ParenListExprs
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 3 03:46:16 PST 2021
kadircet created this revision.
kadircet added a reviewer: hokein.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95935
Files:
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/function-overloads.cpp
clang/unittests/Sema/CodeCompleteTest.cpp
Index: clang/unittests/Sema/CodeCompleteTest.cpp
===================================================================
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -488,6 +488,7 @@
auto y = new decltype(&1)(^);
// GNU decimal type extension is not supported in clang.
auto z = new _Decimal128(^);
+ void foo() { (void)(foo)(^); }
)cpp";
EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
}
Index: clang/test/CodeCompletion/function-overloads.cpp
===================================================================
--- clang/test/CodeCompletion/function-overloads.cpp
+++ clang/test/CodeCompletion/function-overloads.cpp
@@ -21,6 +21,8 @@
void test_adl() {
NS::X x;
g(x, x);
+ (void)(f)(1, 2, 3);
+ (void)(test, test, test, f)(1, 2, 3);
}
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
@@ -31,6 +33,10 @@
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:7 %s -o - | \
// RUN: FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:13 %s -o - | \
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:31 %s -o - | \
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5597,12 +5597,16 @@
QualType Sema::ProduceCallSignatureHelp(Scope *S, Expr *Fn,
ArrayRef<Expr *> Args,
SourceLocation OpenParLoc) {
- if (!CodeCompleter)
+ if (!CodeCompleter || !Fn)
return QualType();
+ // If we have a ParenListExpr for LHS, peel it off by chosing the last expr.
+ if (auto *PLE = llvm::dyn_cast<ParenListExpr>(Fn))
+ Fn = PLE->getExpr(PLE->getNumExprs() - 1);
+
// FIXME: Provide support for variadic template functions.
// Ignore type-dependent call expressions entirely.
- if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args))
+ if (Fn->isTypeDependent() || anyNullArguments(Args))
return QualType();
// In presence of dependent args we surface all possible signatures using the
// non-dependent args in the prefix. Afterwards we do a post filtering to make
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95935.321047.patch
Type: text/x-patch
Size: 2686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210203/28581c97/attachment.bin>
More information about the cfe-commits
mailing list